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

Bug 2100220: Fix completed pods releasing IP address on update #1158

Merged
merged 2 commits into from Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go-controller/pkg/ovn/obj_retry.go
Expand Up @@ -1469,7 +1469,7 @@ func (oc *Controller) WatchResource(objectsToRetry *retryObjs) (*factory.Handler
// [step 1b] The object is in a terminal state: delete it from the cluster,
// delete its retry entry and return. This only applies to pod watchers
// (pods + dynamic network policy handlers watching pods).
oc.processObjectInTerminalState(objectsToRetry, old, oldKey, resourceEventUpdate)
oc.processObjectInTerminalState(objectsToRetry, newer, newKey, resourceEventUpdate)
return

} else if !hasUpdateFunc {
Expand Down
14 changes: 7 additions & 7 deletions go-controller/pkg/ovn/pods_test.go
Expand Up @@ -431,7 +431,7 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
)

myPod2, err := fakeOvn.fakeClient.KubeClient.CoreV1().Pods(t.namespace).Create(context.TODO(),
newPod(t2.namespace, t2.podName, t2.nodeName, t2.podIP), metav1.CreateOptions{})
newPod(t2.namespace, t2.podName, t2.nodeName, ""), metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Eventually(func() string {
return getPodAnnotations(fakeOvn.fakeClient.KubeClient, t2.namespace, t2.podName)
Expand All @@ -458,12 +458,12 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
return err != nil || !info.expires.IsZero()
}, 2).Should(gomega.BeTrue())

ginkgo.By("Freed IP should now allow mypod2 to come up")
fakeOvn.controller.retryPods.requestRetryObjs()
// there should also be no entry for this pod in the retry cache
gomega.Eventually(func() bool {
return fakeOvn.controller.retryPods.getObjRetryEntry(myPod2Key) == nil
}, retryObjInterval+time.Second).Should(gomega.BeTrue())
ginkgo.By("Freed IP should now allow mypod2 to come up")
fakeOvn.controller.retryPods.requestRetryObjs()
gomega.Eventually(func() string {
return getPodAnnotations(fakeOvn.fakeClient.KubeClient, t2.namespace, t2.podName)
}, 2).Should(gomega.MatchJSON(t2.getAnnotationsJson()))
Expand Down Expand Up @@ -535,7 +535,7 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
)

myPod2, err := fakeOvn.fakeClient.KubeClient.CoreV1().Pods(t.namespace).Create(context.TODO(),
newPod(t2.namespace, t2.podName, t2.nodeName, t2.podIP), metav1.CreateOptions{})
newPod(t2.namespace, t2.podName, t2.nodeName, ""), metav1.CreateOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Eventually(func() string {
return getPodAnnotations(fakeOvn.fakeClient.KubeClient, t2.namespace, t2.podName)
Expand All @@ -561,12 +561,13 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
return err != nil || !info.expires.IsZero()
}, 2).Should(gomega.BeTrue())

ginkgo.By("Freed IP should now allow mypod2 to come up")
fakeOvn.controller.retryPods.requestRetryObjs()
// there should also be no entry for this pod in the retry cache
gomega.Eventually(func() bool {
return fakeOvn.controller.retryPods.getObjRetryEntry(myPod2Key) == nil
}, retryObjInterval+time.Second).Should(gomega.BeTrue())
ginkgo.By("Freed IP should now allow mypod2 to come up")
fakeOvn.controller.retryPods.requestRetryObjs()

gomega.Eventually(func() string {
return getPodAnnotations(fakeOvn.fakeClient.KubeClient, t2.namespace, t2.podName)
}, 2).Should(gomega.MatchJSON(t2.getAnnotationsJson()))
Expand All @@ -576,7 +577,6 @@ var _ = ginkgo.Describe("OVN Pod Operations", func() {
myPod2, err = fakeOvn.fakeClient.KubeClient.CoreV1().Pods(t.namespace).Get(context.TODO(),
t2.podName, metav1.GetOptions{})
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(myPod2.Status.PodIP).To(gomega.Equal(t2.podIP))

ginkgo.By("Updating the completed pod should not free the IP")
patch := struct {
Expand Down