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

[feature request] Make CloneSet and StatefulSet Support the generateName setting #1627

Open
iambocai opened this issue May 24, 2024 · 7 comments · May be fixed by #1635
Open

[feature request] Make CloneSet and StatefulSet Support the generateName setting #1627

iambocai opened this issue May 24, 2024 · 7 comments · May be fixed by #1635
Assignees

Comments

@iambocai
Copy link

What would you like to be added:

To make CloneSet and StatefulSet support the GenerateName setting.

Why is this needed:

Currently, CloneSet rigidly uses {workloadName}-{randomID} when generating pod.Name. There is a risk here as workload names can be up to 253 bytes long, while pod names are limited to 63 bytes. Therefore, if the user-defined workload name exceeds 57 bytes, the resulting pod name will exceed the limit and become unusable. The general solution to this problem is to specify GenerateName, but our current implementation of CloneSet does not support this feature. This leaves users facing such issues with no option but to shorten the workload name, which compromises readability and is not a good solution from a management standpoint. Therefore, I hope that support for the GenerateName setting can be incorporated.

pod.Name = fmt.Sprintf("%s-%s", cs.Name, id)

The requirements for StatefulSet would be similar.

@Radeity
Copy link

Radeity commented May 27, 2024

Hi @furykerry , I can work on this issue, can you assign me?

@furykerry
Copy link
Member

/assign @Radeity

@Radeity
Copy link

Radeity commented May 27, 2024

Hi @iambocai , I've tested this issue, actually, the limit is not pod name, but the length of label name & label value.

For this issue, there's already a feature gate to handle it, you can set CloneSetShortHash to true, and then you can use longer cs name.

Related code logic:

// Note that controller-revision-hash defaults to be "{CLONESET_NAME}-{HASH}",
// and it will be "{HASH}" if CloneSetShortHash feature-gate has been enabled.
// But pod-template-hash should always be the short format.
shortHash := GetShortHash(hash)
if utilfeature.DefaultFeatureGate.Enabled(features.CloneSetShortHash) {
obj.GetLabels()[apps.ControllerRevisionHashLabelKey] = shortHash
} else {
obj.GetLabels()[apps.ControllerRevisionHashLabelKey] = hash
}

Thus, it seems like no need to make any changes to codes. cc @furykerry

@furykerry
Copy link
Member

@Radeity although short cloneset hash can be helpful to break the name length limit, it is still beneficial to support generateName field which is a more common way to handle this problem

@Radeity
Copy link

Radeity commented May 28, 2024

Hi @furykerry , thanks for your reply. If I understand correctly, in this feat, we should support to use CloneSet/StatefulSet's GenerateName as the prefix of their children's pod name, and keep suffix of pod name unchanged (like availableID in CloneSet, ordinal of StatefulSet)?

@furykerry
Copy link
Member

yes, just replace the prefix with generateName if available

Copy link

stale bot commented Aug 28, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 28, 2024
@stale stale bot closed this as completed Sep 5, 2024
@furykerry furykerry removed the wontfix This will not be worked on label Sep 5, 2024
@furykerry furykerry reopened this Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants