You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid value: "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-6db48787fc": must be no more than 63 characters #10284
Expected: it should create a stateseful even when the original service's name is too long using the defined hostname
Actual:
tailscale 3s Warning FailedCreate statefulset/ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp create Pod ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-0 in StatefulSet ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp failed error: Pod "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-0" is invalid: metadata.labels: Invalid value: "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-6db48787fc": must be no more than 63 characters
Are there any recent changes that introduced the issue?
tailscale 3s Warning FailedCreate statefulset/ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp create Pod ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-0 in StatefulSet ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp failed error: Pod "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-0" is invalid: metadata.labels: Invalid value: "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-6db48787fc": must be no more than 63 characters
I think this error is about the autogenerated controller-revision-hash label value that by default contains the name of the StatefulSet + a hash so ends up being longer than the max allowed value of Kubernetes labels - see kubernetes/kubernetes#64023.
Our code should not have an issue with long Service names - we use kube name generator that ensures that the value gets truncated and remains unique.
I am not sure why the tailscale.com/hostname isn't used here
There is no uniqueness enforcement on hostnames when they are applied. If there are multiple tailnet devices attempting to use the same hostname, the names will get an integer suffix, but the operator has no way of discovering that at a time of creating cluster resources.
Doesn't this mean that if the Service name is prometheus-kube-prometheus-prometheus-thanos (44 chars), adding ts- (3 chars) and 5n9pp (5 chars) then this issue will occur?
Doesn't this mean that if the Service name is prometheus-kube-prometheus-prometheus-thanos (44 chars), adding ts- (3 chars) and 5n9pp (5 chars) then this issue will occur?
It will occur yes. My comment was a bit unclear- I myself originally assumed that the too-long value was generated somewhere in our code and argued against that assumption.
I think we should be fine cutting names for longer Services. It shouldn't break anyone since those wouldn't have worked anyway.
Activity
irbekrm commentedon Nov 20, 2023
I think this error is about the autogenerated
controller-revision-hashlabel value that by default contains the name of the StatefulSet + a hash so ends up being longer than the max allowed value of Kubernetes labels - see kubernetes/kubernetes#64023.Our code should not have an issue with long
Servicenames - we use kube name generator that ensures that the value gets truncated and remains unique.There is no uniqueness enforcement on hostnames when they are applied. If there are multiple tailnet devices attempting to use the same hostname, the names will get an integer suffix, but the operator has no way of discovering that at a time of creating cluster resources.
irbekrm commentedon Nov 20, 2023
I guess we can solve it by shortening the StatefulSet name, similar to how tekton folks have done it tektoncd/pipeline@b01d860
Although- that would be a somewhat breaking change if folks are already relying on those names
Shaked commentedon Nov 20, 2023
@irbekrm
I have pointed to the same line of code in my original issue:
tailscale/cmd/k8s-operator/sts.go
Line 182 in c82fd12
This comes from line 174, which is the service name:
tailscale/cmd/k8s-operator/svc.go
Lines 173 to 178 in dd8bc9b
Doesn't this mean that if the
Servicename isprometheus-kube-prometheus-prometheus-thanos(44 chars), addingts-(3 chars) and5n9pp(5 chars) then this issue will occur?irbekrm commentedon Nov 20, 2023
It will occur yes. My comment was a bit unclear- I myself originally assumed that the too-long value was generated somewhere in our code and argued against that assumption.
I think we should be fine cutting names for longer Services. It shouldn't break anyone since those wouldn't have worked anyway.
cmd/k8s-operator: truncate long StatefulSet name prefixes
cmd/k8s-operator: truncate long StatefulSet name prefixes
cmd/k8s-operator: truncate long StatefulSet name prefixes
cmd/k8s-operator: truncate long StatefulSet name prefixes
cmd/k8s-operator: truncate long StatefulSet name prefixes (#10343)
irbekrm commentedon Nov 26, 2023
Thank you for spotting the bug and creating the issue @Shaked .
This was fixed in #10343 and the latest operator tag
unstable-v1.55.68has the fix.