Skip to content

Invalid value: "ts-prometheus-kube-prometheus-prometheus-thanos-5n9pp-6db48787fc": must be no more than 63 characters #10284

Closed

Description

@Shaked

What is the issue?

It's not possible to use cluster egress https://tailscale.com/kb/1236/kubernetes-operator/#cluster-egress when the service's name is too long. When using a 3rd party chart/manifests, it's not always possible to control the name of the service, which might be too long before applying TS' code.

The problem occurs because of the usage of sts.ParentResourceName. I am not sure why the tailscale.com/hostname isn't used here:

https://github.com/tailscale/tailscale/blob/main/cmd/k8s-operator/sts.go#L182

It would be great to be able to override the name in cases like this.

Steps to reproduce

  1. Create a service with a long name like prometheus-kube-prometheus-prometheus-thanos
  2. Apply TS annotations:
tailscale.com/expose: true
tailscale.com/hostname: thanos-name
  1. Check kubernetes events

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?

No response

OS

No response

OS version

No response

Tailscale version

latest chart

Other software

No response

Bug report

No response

Activity

  1. added
    L2 Few
    P3 Can't get started
    T5 Usability
    on Nov 17, 2023
  2. irbekrm commented on Nov 20, 2023

    @irbekrm
    Contributor

    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.

  3. self-assigned this
    on Nov 20, 2023
  4. irbekrm commented on Nov 20, 2023

    @irbekrm
    Contributor

    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

  5. Shaked commented on Nov 20, 2023

    @Shaked
    Author

    @irbekrm

    I have pointed to the same line of code in my original issue:

    GenerateName: "ts-" + sts.ParentResourceName + "-",

    This comes from line 174, which is the service name:

    sts := &tailscaleSTSConfig{
    ParentResourceName: svc.Name,
    ParentResourceUID: string(svc.UID),
    Hostname: hostname,
    Tags: tags,
    ChildResourceLabels: crl,

    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?

  6. irbekrm commented on Nov 20, 2023

    @irbekrm
    Contributor

    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.

  7. irbekrm commented on Nov 26, 2023

    @irbekrm
    Contributor

    Thank you for spotting the bug and creating the issue @Shaked .

    This was fixed in #10343 and the latest operator tag unstable-v1.55.68 has the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

L2 FewP3 Can't get startedT5 Usabilitybugkubernetes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions