kcp-dev/kcp

bug: Syncer namespace with label value exceeding 63 characters

MatousJobanek opened this issue · 8 comments

Describe the bug

When generating the syncer namespace manifests, the kubectl kcp workload sync uses the current workspace path and the workspace name for workload.kcp.io/logical-cluster label. However, this can easily exceed 63 characters (mainly in home workspaces) which is the limit for label values.
Creating such a namespace fails with:

Error from server (Invalid): error when creating "/tmp/appstudio-controllers-compute-syncer.yaml": Namespace "kcp-syncer-appstudio-controllers-compute-29kuqsah" is invalid: metadata.labels: Invalid value: "root_users_qj_jc_rh-sso-mjobanek-kcp_redhat-appstudio-internal-compute": must be no more than 63 characters

This makes any testing in some home workspace almost impossible

Steps To Reproduce

  1. go to your home workspace
  2. if the path is not long enough, then create a sub-workspace with some longer name
  3. go to the sub-workspace
  4. run kubectl kcp workload sync
  5. try to apply the generated manifests to your cluster

Expected Behaviour

the sync command should not create a label with such a long value

Additional Context

No response

ncdc commented

/help
/good-first-issue

@ncdc:
This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/help
/good-first-issue

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/test-infra repository.

Hi @ncdc if no one has started with this one yet, can I work on this?

ncdc commented

@apoorvajagtap sure thing, thanks!

/assign @apoorvajagtap

Hello @ncdc @MatousJobanek I was able to reproduce the issue. In order to proceed, I would like to have your inputs on a preferred value for workload.kcp.io/logical-cluster. As per the current design, it basically concatenates the name of parent workspaces with the current one, and assigns the same string as value:

$ bin/kubectl-kcp workspace current                                                                 
Current workspace is "root:telcops:kcp-syncer-appstudio-controllers-compute-trial1-trial2-trial2".
---
apiVersion: v1
kind: Namespace
metadata:
  name: kcpsyncbd40dcd9607bfa1554233fb41af30c96314b56c285044d0616ae8637
  labels:
    workload.kcp.io/logical-cluster: root_telcops_kcp-syncer-appstudio-controllers-compute-trial1-trial2-trial2
    workload.kcp.io/workload-cluster: mycluster2

So, what should be the preferred pattern to opt for a unique value?

  1. Should we truncate/remove the parent workspace names? (If we follow this, then the value might not be unique for the workspaces that belong to separate parent workspaces but has the same name)
  2. Should we limit the number of characters for a workspace itself (a value that is less than 63)?
  3. Or, can we use a combination of parent workspaces & name of workload_cluster, instead of just the workspaces? (for e.g., in the current scenario, assigning the value as "root_telcops_mycluster2")
ncdc commented

Neither workload.kcp.io/logical-cluster nor workload.kcp.io/sync-target is currently used by our code for anything. Maybe we should make these annotations instead?

ncdc commented

Discussed in community call today. Let's remove these.