-
Notifications
You must be signed in to change notification settings - Fork 10.2k
[bitnami/redis] Ensure that Redis resources are less than 63 chars #34803
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
base: main
Are you sure you want to change the base?
Conversation
Testing on my end, but encountering few issues with my changes, so I'm setting the PR as draft for now. EDIT: I think it's good now. |
~Actually, I think there's still an issue with one label having a too long value, but this label comes from the common bitnami chart, so I would have to fix it there :/ ~ It was the value of the |
72849ad
to
b3ceebb
Compare
b3ceebb
to
8623aff
Compare
Signed-off-by: Maxence Boutet <[email protected]>
{{/* | ||
Return the proper Redis master fullname. | ||
The 0000000000 is to take into account the 10-charaters hash that the StatefulSet | ||
appends to the name of the StatefulSet in the pod's controller-revision-hash label. | ||
A label value can only have 63 characters. | ||
*/}} | ||
{{- define "redis.master.fullname" -}} | ||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-master-0000000000" | len)) | int) | trimSuffix "-") "master" -}} | ||
{{- end -}} | ||
{{/* | ||
Return the proper Redis replicas fullname | ||
*/}} | ||
{{- define "redis.replicas.fullname" -}} | ||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-replicas-0000000000" | len)) | int) | trimSuffix "-") "replicas" -}} | ||
{{- end -}} | ||
{{/* | ||
Return the proper Redis sentinel fullname | ||
*/}} | ||
{{- define "redis.sentinel.fullname" -}} | ||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-node-0000000000" | len)) | int) | trimSuffix "-") "node" -}} | ||
{{- end -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Service
also uses this helper, it could result in it being recreated for some users. Truncating the equivalent of 0000000000
is only strictly needed for the Statefulset
in reality.
Signed-off-by: Bitnami Bot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. Please take a look at my comment to follow the standard approach to truncate the strings and how you can improve the common functions to follow your approach.
{{/* | ||
Return the proper Redis headless fullname | ||
*/}} | ||
{{- define "redis.headless.fullname" -}} | ||
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-headless" | len)) | int) | trimSuffix "-") "headless" -}} | ||
{{- end -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea and see it as a good improvement. However, all our solutions use a simpler method
{{/* | |
Return the proper Redis headless fullname | |
*/}} | |
{{- define "redis.headless.fullname" -}} | |
{{- printf "%s-%s" ((include "common.names.fullname" .) | trunc ((sub 63 ("-headless" | len)) | int) | trimSuffix "-") "headless" -}} | |
{{- end -}} | |
{{/* | |
Return the proper Redis headless fullname | |
*/}} | |
{{- define "redis.headless.fullname" -}} | |
{{ printf "%s-headless" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} | |
{{- end -}} |
I'd follow that approach here (and the other methods) too.
However, the common.names.fullname function can be improve to truncate the strings the way you are suggesting.
https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_names.tpl#L26
You can update that function to accept another string to perform the "sub" method. That way, that function can be added to other charts as well and the whole community will benefit from that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I think it's a good idea, it would also change the signature of common.names.fullname
in a backward incompatible manner, no? Unless conditional logic is added to common.names.fullname
to accept both the current and new signature with the custom string to use to calculate the additional truncation. I don't mind doing that, but before I do, I just want to make sure if we're agreeing on the approach of having common.names.fullname
handle both signatures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simply suggested to improve the function to accept a new parameter to perform the "sub" method. The function won't do anything unless you set that new parameter. You can later update the function in the Redis' chart and increase the version to a new major so we avoid issues when updating between minor versions. Sounds good?
This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thank you for your contribution. |
Signed-off-by: Maxence Boutet <[email protected]>
Signed-off-by: Bitnami Bot <[email protected]>
Sorry @mboutet, I didn't receive the notification about your comments. Will review everything again and update the PR |
Hi @mboutet, I just updated the thread with more information. Let me know if it's clear now. |
This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thank you for your contribution. |
Signed-off-by: Maxence Boutet <[email protected]>
Signed-off-by: Bitnami Bot <[email protected]>
This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thank you for your contribution. |
Signed-off-by: Maxence Boutet <[email protected]>
Signed-off-by: Bitnami Bot <[email protected]>
This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thank you for your contribution. |
Signed-off-by: Maxence Boutet <[email protected]>
Signed-off-by: Bitnami Bot <[email protected]>
Description of the change
Make sure to truncate the Statefulsets and Services' name to 63 characters.
Benefits
This guarantees that all the resources are created successfully.
Possible drawback
None, as I made sure to truncate the original
fullname
while keeping the differentiating suffix as-is (to prevent resource name clash in case thefullname
is really long).Applicable issues
Additional information
I bumped the major version as it could technically cause resources to be recreated due a change in the
metadata.name
of some Statefulsets and Services. In practice, however, it should not happen as the truncation only happens if really needed, so users already using the chart without issues won't get any truncation. On the other hand, the major bump is also warranted due to the complexity of the chart and the regression risk of this PR even though I tried to not miss anything.Checklist
Chart.yaml
according to semver. This is not necessary when the changes only affect README.md files.README.md
using readme-generator-for-helm