Fix extended networking service tests to retry updates on conflict
@@ -12,6 +12,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kapiv1 "k8s.io/kubernetes/pkg/api/v1"
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
+ "k8s.io/kubernetes/pkg/client/retry"
e2e "k8s.io/kubernetes/test/e2e/framework"
. "github.com/onsi/ginkgo"
@@ -115,13 +116,22 @@ func waitForEndpoint(c kclientset.Interface, ns, name string) error {
func launchWebserverService(f *e2e.Framework, serviceName string, nodeName string) (serviceAddr string) {
e2e.LaunchWebserverPod(f, serviceName, nodeName)
+
// FIXME: make e2e.LaunchWebserverPod() set the label when creating the pod
+ err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
podClient := f.ClientSet.CoreV1().Pods(f.Namespace.Name)
pod, err := podClient.Get(serviceName, metav1.GetOptions{})
- expectNoError(err)
+ if err != nil {
+ return err
+ }
+ if pod.ObjectMeta.Labels == nil {
pod.ObjectMeta.Labels = make(map[string]string)
+ }
pod.ObjectMeta.Labels["name"] = "web"
- podClient.Update(pod)
+ _, err = podClient.Update(pod)
+ return err
+ })
+ expectNoError(err)
servicePort := 8080
service := &kapiv1.Service{
