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

When services share IP, modifying any service should fail instead of allocating new IP #1230

Merged
merged 2 commits into from
Mar 2, 2022

Conversation

msherif1234
Copy link
Contributor

@msherif1234 msherif1234 commented Feb 17, 2022

Users prefer seeing errors when modify services that are sharing the sameIP
using "allow-shared-ip" annotation than getting newly allocated serviceIP

Unit-test (using new test case in controller component to repro the issue)

  • before the fix
=== RUN   TestControllerSvcAdddressSharing
    controller_test.go:76: k8s Info event "IPAllocated": Assigned IP ["4.5.6.0"]
    controller_test.go:76: k8s Info event "IPAllocated": Assigned IP ["4.5.6.1"]
  • after the fix
=== RUN   TestControllerSvcAdddressSharing
    controller_test.go:76: k8s Info event "IPAllocated": Assigned IP ["4.5.6.0"]
    controller_test.go:80: k8s Warning event "svcCannotShareKey": current IP not allowed by config:can't change sharing key for "test2", address also in use by test1: services can't share key


Signed-off-by: Mohamed Mahmoud mmahmoud@redhat.com

Copy link
Contributor

@rata rata left a comment

Choose a reason for hiding this comment

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

On a cursory look, this LGTM. Quite what we discussed on slack, thanks! :)

Status: statusAssigned([]string{"4.5.6.0"}),
}
if c.SetBalancer(l, "test2", svc2, k8s.EpsOrSlices{}) != k8s.SyncStateError {
t.Fatalf("SetBalancer failed")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: setBalancer did fail, we just expected it to fail

Comment on lines +101 to +106
if errors.Is(err, allocator.ErrCannotShareKey) {
c.client.Errorf(svc, "svcCannotShareKey", "current IP not allowed by config:%s", err)
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment explaining why we want to return here? Either link to an issue (there is not, right? We just talked on slack, I guess?) or explain the situation briefly

…allocating newIP

Users prefer seeing errors when modify services that are sharing the sameIP
using "allow-shared-ip" annotation than getting newly allocated serviceIP

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
@msherif1234 msherif1234 changed the title When services share IP, modifying any service should fail instead of allocating new svc IP When services share IP, modifying any service should fail instead of allocating new IP Feb 21, 2022
@fedepaol
Copy link
Member

fedepaol commented Mar 2, 2022

LGTM

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.

3 participants