Repository navigation
cmd/k8s-operator: fix base truncating for extra long Service names - #10825
Merged
Merged
Conversation
irbekrm
force-pushed
the
irbekrm/longnames2
branch
from
January 11, 2024 18:01
5a66e0b to
0530e98
Compare
maisem
reviewed
Jan 11, 2024
StatefulSet names for ingress/egress proxies are calculated using Kubernetes name generator and the parent resource name as a base. The name generator also cuts the base, but has a higher max cap. This commit fixes a bug where, if we get a shortened base back from the generator, we cut off too little as the base that we have cut will be passed into the generator again, which will then itself cut less because the base is shorter- so we end up with a too long name again. Updates #10807 Signed-off-by: Irbe Krumina <[email protected]>
irbekrm
force-pushed
the
irbekrm/longnames2
branch
from
January 11, 2024 18:58
0530e98 to
2ac20d1
Compare
maisem
reviewed
Jan 11, 2024
maisem
reviewed
Jan 11, 2024
maisem
reviewed
Jan 11, 2024
maisem
approved these changes
Jan 11, 2024
irbekrm
force-pushed
the
irbekrm/longnames2
branch
from
January 11, 2024 19:35
edc97bc to
204f1fd
Compare
Co-authored-by: Maisem Ali <[email protected]> Signed-off-by: Irbe Krumina <[email protected]> Signed-off-by: Irbe Krumina <[email protected]>
irbekrm
force-pushed
the
irbekrm/longnames2
branch
from
January 11, 2024 19:47
204f1fd to
f25fab2
Compare
This was referenced Jan 11, 2024
Asutorufa
pushed a commit
to Asutorufa/tailscale
that referenced
this pull request
Jan 19, 2024
…ailscale#10825) cmd/k8s-operator: fix base truncating for extra long Service names StatefulSet names for ingress/egress proxies are calculated using Kubernetes name generator and the parent resource name as a base. The name generator also cuts the base, but has a higher max cap. This commit fixes a bug where, if we get a shortened base back from the generator, we cut off too little as the base that we have cut will be passed into the generator again, which will then itself cut less because the base is shorter- so we end up with a too long name again. Updates tailscale#10807 Co-authored-by: Maisem Ali <[email protected]> Signed-off-by: Irbe Krumina <[email protected]>
chen8945
pushed a commit
to Ckid-Home/tailscale
that referenced
this pull request
Jul 31, 2024
…ailscale#10825) cmd/k8s-operator: fix base truncating for extra long Service names StatefulSet names for ingress/egress proxies are calculated using Kubernetes name generator and the parent resource name as a base. The name generator also cuts the base, but has a higher max cap. This commit fixes a bug where, if we get a shortened base back from the generator, we cut off too little as the base that we have cut will be passed into the generator again, which will then itself cut less because the base is shorter- so we end up with a too long name again. Updates tailscale#10807 Co-authored-by: Maisem Ali <[email protected]> Signed-off-by: Irbe Krumina <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
StatefulSet names for ingress/egress proxies are calculated using Kubernetes name generator and the parent resource name as a base.
We currently try pre-calculate how long the generated name will be and cut the base it is to be longer than 52 chars, see #10343.
Problem
The name generator also cuts the base, but has a higher max cap. This commit fixes a bug where, if we get a shortened base back from the generator, we cut off too little as the base that we have cut will be passed into the generator again, which will then itself cut less because the base is shorter- so we end up with a too long name again.
Fix
This PR fixes it by cutting recursively to ensure that, if the cut base produces a longer name again after being put through the name generator, we cut again till we ensure that the generated name will definitely be no longer than 52 chars.
Notes
The longest
Servicename supported before this fix is 54 chars. I have tested that with the contents of this PR vs latest release and verified that both produced the same base (so that the change in this PR does not calculate different names for existing StatefulSets)Updates #10807