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

Reprocess services when an ip is available because of a service change #1645

Merged
merged 3 commits into from Oct 20, 2022

Conversation

fedepaol
Copy link
Member

When a service changes (i.e. changing the servicetype) and the IP is revoked, we reprocess the services so that the newly available ip is assigned.
Fixes #1586

@@ -303,6 +303,7 @@ jobs:
sed -i 's/quay.io\/metallb\/controller:main/quay.io\/metallb\/controller:dev-amd64/g' bin/metallb-operator.yaml
sed -i 's/native/frr/g' bin/metallb-operator.yaml
kubectl apply -f bin/metallb-operator.yaml
sleep 30s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this use some kubectl wait instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too late, I already yolo-ed this in another PR because it was blocking all the PRs :P

Copy link
Member

@oribon oribon Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that it has already bitten us? 😅
https://github.com/metallb/metallb/actions/runs/3272314767/jobs/5383305208
or this is unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope I think it's the same. Let me see if I can do the same trick we did in #1648 to wait until the webhook is ready before applying the metallb resource.

if !c.convergeBalancer(l, name, svc) {
return controllers.SyncStateError
}
if wasAllocated && c.ips.Pool(name) == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind adding a comment what's wasAllocated and that it is possibly being changed by c.ConvergeBalancer?
otherwise this if looks a bit confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I understand that. I spent a good amount of time and I can assure the previous versions were even worse. Let me try to find something better, if not I'll restort to commenting

Comment on lines 30 to 50
ginkgo.AfterEach(func() {
if ginkgo.CurrentGinkgoTestDescription().Failed {
k8s.DumpInfo(Reporter, ginkgo.CurrentGinkgoTestDescription().TestText)
}

// Clean previous configuration.
err := ConfigUpdater.Clean()
framework.ExpectNoError(err)
})

f = framework.NewDefaultFramework("assignement")
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged

ginkgo.BeforeEach(func() {
cs = f.ClientSet

ginkgo.By("Clearing any previous configuration")
err := ConfigUpdater.Clean()
framework.ExpectNoError(err)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated note (for another pr): we should probably have a function that wraps these instead of copying in each e2e file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that. The size is small enough that we could save 2/3 lines at most

admissionapi "k8s.io/pod-security-admission/api"
)

var _ = ginkgo.Describe("IP Assignement", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: assignement -> assignment

gomega.Eventually(func() int {
s, err := cs.CoreV1().Services(svc1.Namespace).Get(context.Background(), svc1.Name, metav1.GetOptions{})
framework.ExpectNoError(err)
return len(s.Status.LoadBalancer.Ingress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about checking that the freed ip was assigned instead of checking the length? feels a bit more natural imo

return len(s.Status.LoadBalancer.Ingress)
}, 5*time.Second, 1*time.Second).Should(gomega.BeZero())

ginkgo.By("Changing the service type so the ip is free to be used again")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about testing that the ip is freed when the service is deleted as well if we're already addressing this scenario?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iirc the case was already handled and is not affected by the fix in this PR. In any case I have already all the infrastructure in place, so it won't hurt adding a new test.

@fedepaol fedepaol force-pushed the fix/changeservicetypefreesip branch 2 times, most recently from 125eebc to d923996 Compare October 18, 2022 14:45
@fedepaol
Copy link
Member Author

@oribon I think I applied the requested changes

If we stop associating the current service with a pool, we need to
reprocess all the services because the newly available ip could be used
by another service.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Adding a test that verifies that changing the service type makes an ip
available and reprocess eventual existing services with
externalIP=pending.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Copy link
Member

@oribon oribon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@fedepaol fedepaol merged commit 7b76a26 into metallb:main Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LoadBalancer Service External-IP <pending> status
2 participants