diff --git a/e2e/client/types.go b/e2e/client/types.go index 17cfdee8..9b6d40ec 100644 --- a/e2e/client/types.go +++ b/e2e/client/types.go @@ -230,14 +230,14 @@ func podMeta(podName string, namespace string, label map[string]string, annotati } func dynamicNetworksAnnotation(pod *corev1.Pod, newIfaceConfigs ...*nettypes.NetworkSelectionElement) string { + var currentNetworkSelectionElements []*nettypes.NetworkSelectionElement currentNetworkSelectionElementsString, wasFound := pod.ObjectMeta.Annotations[nettypes.NetworkAttachmentAnnot] - if !wasFound { - return "" - } - - currentNetworkSelectionElements, err := annotations.ParsePodNetworkAnnotations(currentNetworkSelectionElementsString, pod.GetNamespace()) - if err != nil { - return "" + if wasFound { + var err error + currentNetworkSelectionElements, err = annotations.ParsePodNetworkAnnotations(currentNetworkSelectionElementsString, pod.GetNamespace()) + if err != nil { + return "" + } } updatedNetworkSelectionElements := append( diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index a7077b47..ab80eb27 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -173,7 +173,7 @@ var _ = Describe("Multus dynamic networks controller", func() { }) }) - XContext("a provisioned pod featuring *only* the cluster's default network", func() { + Context("a provisioned pod featuring *only* the cluster's default network", func() { var pod *corev1.Pod BeforeEach(func() { diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index f5dd87a1..d8ec69c4 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -347,7 +347,10 @@ func (pnc *PodNetworksController) updatePodNetworkStatus(pod *corev1.Pod, newIfa func networkSelectionElements(podAnnotations map[string]string, podNamespace string) ([]*nadv1.NetworkSelectionElement, error) { podNetworks, ok := podAnnotations[nadv1.NetworkAttachmentAnnot] if !ok { - return nil, fmt.Errorf("the pod is missing the \"%s\" annotation on its annotations: %+v", nadv1.NetworkAttachmentAnnot, podAnnotations) + return []*nadv1.NetworkSelectionElement{}, nil + } + if podNetworks == "" { + podNetworks = "[]" } podNetworkSelectionElements, err := annotations.ParsePodNetworkAnnotations(podNetworks, podNamespace) if err != nil {