Skip to content

Conversation

mboutet
Copy link
Contributor

@mboutet mboutet commented Jul 4, 2025

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 the fullname 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 version bumped in Chart.yaml according to semver. This is not necessary when the changes only affect README.md files.
  • Variables are documented in the values.yaml and added to the README.md using readme-generator-for-helm
  • Title of the pull request follows this pattern [bitnami/<name_of_the_chart>] Descriptive title
  • All commits signed off and in agreement of Developer Certificate of Origin (DCO)

@github-actions github-actions bot added redis triage Triage is needed labels Jul 4, 2025
@github-actions github-actions bot requested a review from carrodher July 4, 2025 14:07
@mboutet mboutet changed the title Ensure that Redis resources are less than 63 chars [bitnami/redis] Ensure that Redis resources are less than 63 chars Jul 4, 2025
@mboutet mboutet marked this pull request as ready for review July 4, 2025 14:12
@mboutet mboutet marked this pull request as draft July 4, 2025 14:46
@mboutet
Copy link
Contributor Author

mboutet commented Jul 4, 2025

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.

@mboutet mboutet marked this pull request as ready for review July 4, 2025 18:20
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels Jul 5, 2025
@github-actions github-actions bot removed the triage Triage is needed label Jul 5, 2025
@github-actions github-actions bot removed the request for review from carrodher July 5, 2025 11:14
@github-actions github-actions bot requested a review from jotamartos July 5, 2025 11:14
@mboutet mboutet marked this pull request as draft July 9, 2025 18:15
@mboutet
Copy link
Contributor Author

mboutet commented Jul 9, 2025

~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 controller-revision-hash label in the end.

@mboutet mboutet force-pushed the truncate-long-redis-name branch from 72849ad to b3ceebb Compare July 14, 2025 17:33
@mboutet mboutet closed this Jul 14, 2025
@mboutet mboutet force-pushed the truncate-long-redis-name branch from b3ceebb to 8623aff Compare July 14, 2025 17:34
@mboutet mboutet reopened this Jul 14, 2025
@github-actions github-actions bot added triage Triage is needed and removed solved labels Jul 14, 2025
@github-actions github-actions bot requested a review from carrodher July 14, 2025 17:41
Comment on lines +8 to +31
{{/*
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 -}}
Copy link
Contributor Author

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.

@carrodher carrodher removed their request for review July 15, 2025 07:39
@carrodher carrodher removed their assignment Jul 15, 2025
@carrodher carrodher removed the triage Triage is needed label Jul 15, 2025
Signed-off-by: Bitnami Bot <[email protected]>
Copy link
Contributor

@jotamartos jotamartos left a 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.

Comment on lines +33 to +38
{{/*
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 -}}
Copy link
Contributor

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

Suggested change
{{/*
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.

Copy link
Contributor Author

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.

Copy link
Contributor

@jotamartos jotamartos Aug 6, 2025

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?

Copy link

github-actions bot commented Aug 1, 2025

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.

@github-actions github-actions bot added the stale 15 days without activity label Aug 1, 2025
mboutet and others added 2 commits August 1, 2025 09:06
@github-actions github-actions bot removed the stale 15 days without activity label Aug 2, 2025
@jotamartos
Copy link
Contributor

Sorry @mboutet, I didn't receive the notification about your comments. Will review everything again and update the PR

@jotamartos
Copy link
Contributor

Hi @mboutet,

I just updated the thread with more information. Let me know if it's clear now.

Copy link

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.

@github-actions github-actions bot added the stale 15 days without activity label Aug 22, 2025
mboutet and others added 2 commits August 22, 2025 11:26
@github-actions github-actions bot removed the stale 15 days without activity label Aug 23, 2025
Copy link

github-actions bot commented Sep 7, 2025

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.

@github-actions github-actions bot added the stale 15 days without activity label Sep 7, 2025
mboutet and others added 2 commits September 8, 2025 09:17
@github-actions github-actions bot removed the stale 15 days without activity label Sep 9, 2025
Copy link

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.

@github-actions github-actions bot added the stale 15 days without activity label Sep 25, 2025
mboutet and others added 2 commits September 25, 2025 15:07
@github-actions github-actions bot removed the stale 15 days without activity label Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
redis verify Execute verification workflow for these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bitnami/redis] Long release name breaks statefulset pods
4 participants