karmada
karmada copied to clipboard
work may failed to create k8s resource due to label value over length limit
What happened:
The work
created k8s resource, comes with a work.karmada.io/name
label, which value is generated by this method, during mergeLabel
, for back referencing work by k8s resource.
However, a name of a k8s object has a limit of length 253
, it's not likely someone will create such a long named object, since it's really hard to remember, and hard to type in. But, limit of label values is far shorter than limit of name length, which is 63
, and labels sometimes is generated by program, for referencing, not for typing or naming, it's easy to reach the limit.
And this happend in karmada.
https://github.com/karmada-io/karmada/blob/d27faeac953043c2274bb8787bbbaaafa7d0dcd6/pkg/util/names/names.go#L77-L99
What you expected to happen:
Since name of k8s object didn't reach the limit of name (253), karmada should succefully propagate it to member cluster.
How to reproduce it (as minimally and precisely as possible):
Propatate a k8s resource to member cluster with a name longer than 52 (plus -0123456789
suffix will reach the 63
limit)
Anything else we need to know?:
Environment:
- Karmada version:
- kubectl-karmada or karmadactl version (the result of
kubectl-karmada version
orkarmadactl version
): - Others:
func mergeLabel(workload *unstructured.Unstructured, workNamespace string, binding metav1.Object, scope apiextensionsv1.ResourceScope) map[string]string {
var workLabel = make(map[string]string)
util.MergeLabel(workload, workv1alpha1.WorkNamespaceLabel, workNamespace)
util.MergeLabel(workload, workv1alpha1.WorkNameLabel, names.GenerateWorkName(workload.GetKind(), workload.GetName(), workload.GetNamespace()))
util.MergeLabel(workload, util.ManagedByKarmadaLabel, util.ManagedByKarmadaLabelValue)
...
return workLabel
}
Indeed
It's a kind of known issue. see https://github.com/karmada-io/karmada/issues/1741.
My idea is to move labels to annotation, but we need to analyze how these labels are used by the system and work out a backward-compatible solution.
https://github.com/karmada-io/karmada/pull/3812#issuecomment-1680128010
FYI
It has fixed by #4865 /close
@XiShanYongYe-Chang: Closing this issue.
In response to this:
It has fixed by #4865 /close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.