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

Allow non-IPs in service spec to avoid noop updates #5663

Merged
merged 6 commits into from
May 25, 2022

Conversation

pebrc
Copy link
Collaborator

@pebrc pebrc commented May 12, 2022

Fixes #5657

We are copying parts of the service spec populated on the service side into the expected service spec to avoid unnecessary updates of services. For some reason that is unfortunately not documented an exception was made for the ClusterIP[s] values that not valid IPs like None.

By not including those we always update the service on each reconciliation.

Prior relevant work on in this area:
#2691
#4929

I am still investigating It is unclear to me why we made this exclusion originally. I have not been able to create a situation where this became a problem. It seems None is perfectly acceptable to create a headless service, as expected.

@botelastic botelastic bot added the triage label May 12, 2022
@pebrc pebrc added the >enhancement Enhancement of existing functionality label May 12, 2022
@botelastic botelastic bot removed the triage label May 12, 2022
@pebrc pebrc marked this pull request as ready for review May 12, 2022 13:32
@pebrc pebrc added the v2.3.0 label May 19, 2022
Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

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

It is unclear to me why we made this exclusion originally.

Same 🤷‍♂️

Doing some tests I noticed that InternalTrafficPolicy is set by the api server starting K8S 1.22 (documentation states that it is beta since v1.23 but I can clearly see it enabled by default on v1.22.9-gke.1300):

  v1.ServiceSpec{
        ... // 16 identical fields
        AllocateLoadBalancerNodePorts: nil,
        LoadBalancerClass:             nil,
-       InternalTrafficPolicy:         nil,
+       InternalTrafficPolicy:         &"Cluster",
  }

@@ -285,7 +288,7 @@ func Test_applyServerSideValues(t *testing.T) {
}},
},
{
name: "Reconciled ClusterIP[s] is not used if the reconciled ClusterIP[s] are not valid IPs",
name: "Reconciled ClusterIP[s] is also used if the reconciled ClusterIP[s] are not valid IPs",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what we are testing now with this case. It's equivalent to the previous case 'Reconciled ClusterIP/ClusterIPs/Type/SessionAffinity is used if expected ClusterIP/Type/SessionAffinity is empty'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not quite because this test would have failed in the previous implementation because None is not a valid IP address. This test documents this new behaviour.

pebrc and others added 2 commits May 25, 2022 17:14
@pebrc pebrc requested a review from thbkrkr May 25, 2022 15:32
Copy link
Contributor

@thbkrkr thbkrkr left a comment

Choose a reason for hiding this comment

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

LGTM

@pebrc pebrc merged commit 8e5ac97 into elastic:main May 25, 2022
fantapsody pushed a commit to fantapsody/cloud-on-k8s that referenced this pull request Feb 7, 2023
We are copying parts of the service spec populated on the service side into the expected service spec to avoid unnecessary updates of services. For some reason that is unfortunately not documented an exception was made for the ClusterIP[s] values that not valid IPs like None. By not including those we always update the service on each reconciliation. This change addresses this gap and a similar one for internalTrafficPolicy

Co-authored-by: Michael Morello <[email protected]>
Co-authored-by: Thibault Richard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v2.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Operator updates services on each reconciliation
3 participants