Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sandbox-release-4.17] SDN-5297: 4.17 sandbox merge 11-21-2024 #2363

Open
wants to merge 3 commits into
base: sandbox-release-4.17
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions go-controller/pkg/ovn/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ func (oc *DefaultNetworkController) ensurePod(oldPod, pod *kapi.Pod, addPort boo
return nil
}

// skip the pods on no host subnet nodes
// Add podIPs on no host subnet Nodes to the namespace address_set
switchName := pod.Spec.NodeName
if oc.lsManager.IsNonHostSubnetSwitch(switchName) {
return nil
return oc.ensureRemotePodIP(oldPod, pod, addPort)
}

if oc.isPodScheduledinLocalZone(pod) {
Expand Down Expand Up @@ -183,11 +183,7 @@ func (oc *DefaultNetworkController) ensureLocalZonePod(oldPod, pod *kapi.Pod, ad
return nil
}

// ensureRemoteZonePod tries to set up remote zone pod bits required to interconnect it.
// - Adds the remote pod ips to the pod namespace address set for network policy and egress gw
//
// It returns nil on success and error on failure; failure indicates the pod set up should be retried later.
func (oc *DefaultNetworkController) ensureRemoteZonePod(oldPod, pod *kapi.Pod, addPort bool) error {
func (oc *DefaultNetworkController) ensureRemotePodIP(oldPod, pod *kapi.Pod, addPort bool) error {
if (addPort || (oldPod != nil && len(pod.Status.PodIPs) != len(oldPod.Status.PodIPs))) && !util.PodWantsHostNetwork(pod) {
podIfAddrs, err := util.GetPodCIDRsWithFullMask(pod, oc.NetInfo)
if err != nil {
Expand All @@ -199,6 +195,17 @@ func (oc *DefaultNetworkController) ensureRemoteZonePod(oldPod, pod *kapi.Pod, a
return fmt.Errorf("failed to add remote pod %s/%s to namespace: %w", pod.Namespace, pod.Name, err)
}
}
return nil
}

// ensureRemoteZonePod tries to set up remote zone pod bits required to interconnect it.
// - Adds the remote pod ips to the pod namespace address set for network policy and egress gw
//
// It returns nil on success and error on failure; failure indicates the pod set up should be retried later.
func (oc *DefaultNetworkController) ensureRemoteZonePod(oldPod, pod *kapi.Pod, addPort bool) error {
if err := oc.ensureRemotePodIP(oldPod, pod, addPort); err != nil {
return err
}

//FIXME: Update comments & reduce code duplication.
// check if this remote pod is serving as an external GW.
Expand Down
51 changes: 51 additions & 0 deletions go-controller/pkg/ovn/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2529,5 +2529,56 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
err := app.Run([]string{app.Name})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
})

ginkgo.It("should correctly handle a pod running on a no host subnet node", func() {
app.Action = func(ctx *cli.Context) error {
testNs := "namespace1"
testPodIP := "10.128.1.3"
namespaceT := *newNamespace(testNs)
myPod := newPod(testNs, "myPod", node2Name, testPodIP)
myPod.Status.Phase = v1.PodRunning
initialDB = libovsdbtest.TestSetup{
NBData: []libovsdbtest.TestData{},
}
fakeOvn.startWithDBSetup(initialDB,
&v1.NamespaceList{
Items: []v1.Namespace{
namespaceT,
},
},
&v1.NodeList{
Items: []v1.Node{
// Add a hybrid overlay node
{
ObjectMeta: metav1.ObjectMeta{
Name: nodeName,
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Status: v1.ConditionTrue,
},
},
},
},
},
},
&v1.PodList{
Items: []v1.Pod{*myPod},
},
)
fakeOvn.controller.lsManager.AddOrUpdateSwitch(myPod.Spec.NodeName, nil)
err := fakeOvn.controller.WatchPods()
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// check that the pod IP is added to the namespace AS
fakeOvn.asf.ExpectAddressSetWithAddresses(testNs, []string{testPodIP})

return nil
}
err := app.Run([]string{app.Name})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
})
})
})