Skip to content

fix: Handle long cluster names #845

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

Merged
merged 9 commits into from
Aug 13, 2024
Merged

Conversation

jimmidyson
Copy link
Member

@jimmidyson jimmidyson commented Aug 7, 2024

This commit starts fixing a bug that means
addons fail to be fully deployed if the cluster name
is longer than 44 characters. This is caused by the name
of the HCP being over 63 characters. This name is then
used in HRP labels which have a maximum length of 63
characters, so the HRPs are rejected by the API server
when CAAPH applies them.

The fix is to add a UUID annotation to all Cluster resources,
enforce this as immutable, and use that UUID in HCP names.

@jimmidyson jimmidyson marked this pull request as draft August 7, 2024 17:00
@github-actions github-actions bot added the fix label Aug 7, 2024
@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch 3 times, most recently from effb100 to 1ff9063 Compare August 8, 2024 13:15
@jimmidyson jimmidyson marked this pull request as ready for review August 8, 2024 14:09
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, going to test this locally

@jimmidyson jimmidyson enabled auto-merge (squash) August 8, 2024 16:06
@dkoshkin
Copy link
Contributor

dkoshkin commented Aug 8, 2024

I think this change introduced a bug with the cluster-autoscaler.
The labels are now more generic and don't contain the cluster name, so the deployment would now select Pods from multiple clusters.

apiVersion: v1
items:
- apiVersion: v1
  kind: Pod
  metadata:
    creationTimestamp: "2024-08-08T16:13:34Z"
    generateName: cluster-autoscaler-dkoshkin-super-long-cluster-name-that-should-57d568bc87-
    labels:
      app.kubernetes.io/instance: cluster-autoscaler
      app.kubernetes.io/name: clusterapi-cluster-autoscaler
      pod-template-hash: 57d568bc87
    name: cluster-autoscaler-dkoshkin-super-long-cluster-name-that-sh99px
    namespace: default
    ownerReferences:
    - apiVersion: apps/v1
      blockOwnerDeletion: true
      controller: true
      kind: ReplicaSet
      name: cluster-autoscaler-dkoshkin-super-long-cluster-name-that-should-57d568bc87
      uid: b98473af-39e4-412c-932a-b7d54ee3893f
    resourceVersion: "965"
    uid: 1d12f4de-60f8-4683-bf8d-94806b035a8e
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    meta.helm.sh/release-name: cluster-autoscaler
    meta.helm.sh/release-namespace: default
  creationTimestamp: "2024-08-08T16:13:24Z"
  generation: 1
  labels:
    app.kubernetes.io/instance: cluster-autoscaler
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: clusterapi-cluster-autoscaler
    helm.sh/chart: cluster-autoscaler-9.37.0
  name: cluster-autoscaler-dkoshkin-super-long-cluster-name-that-should
  namespace: default
  resourceVersion: "468"
  uid: d16fdc42-7fec-4d80-b376-2d140d630741
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/instance: cluster-autoscaler
      app.kubernetes.io/name: clusterapi-cluster-autoscaler

See example from main

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2024-08-08T16:03:08Z"
  generateName: cluster-autoscaler-dkoshkin-super-long-cluster-name-9794bc897-
  labels:
    app.kubernetes.io/instance: cluster-autoscaler-dkoshkin-super-long-cluster-name
    app.kubernetes.io/name: clusterapi-cluster-autoscaler
    pod-template-hash: 9794bc897
  name: cluster-autoscaler-dkoshkin-super-long-cluster-name-9794bcs55bf
  namespace: default
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicaSet
    name: cluster-autoscaler-dkoshkin-super-long-cluster-name-9794bc897
    uid: c6596f40-7244-43fe-b306-3dbcfb745c79
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    meta.helm.sh/release-name: cluster-autoscaler-dkoshkin-super-long-cluster-name
    meta.helm.sh/release-namespace: default
  creationTimestamp: "2024-08-08T16:02:58Z"
  generation: 1
  labels:
    app.kubernetes.io/instance: cluster-autoscaler-dkoshkin-super-long-cluster-name
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: clusterapi-cluster-autoscaler
    helm.sh/chart: cluster-autoscaler-9.37.0
  name: cluster-autoscaler-dkoshkin-super-long-cluster-name
  namespace: default
  resourceVersion: "559"
  uid: 215d0c21-e9a5-493f-b399-69196a157845
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/instance: cluster-autoscaler-dkoshkin-super-long-cluster-name
      app.kubernetes.io/name: clusterapi-cluster-autoscaler

@jimmidyson
Copy link
Member Author

Yes you're right @dkoshkin it does introduce that CA bug - fixing (somehow!).

@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch 3 times, most recently from 0a3b6c6 to 06bd5d8 Compare August 8, 2024 21:25
@jimmidyson
Copy link
Member Author

@dkoshkin Please try with latest commit. Using md5 sum of cluster namespace/name as helm release suffix.

@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch 2 times, most recently from d1fa818 to dcd84a0 Compare August 9, 2024 09:07
@jimmidyson
Copy link
Member Author

Fixed up again. @dkoshkin Please review when you get a mo.

@jimmidyson jimmidyson requested a review from dkoshkin August 9, 2024 09:33
dlipovetsky
dlipovetsky previously approved these changes Aug 9, 2024
@dlipovetsky dlipovetsky force-pushed the jimmi/fix-hcp-naming-labels branch 2 times, most recently from ce47a7b to 3e62e85 Compare August 9, 2024 17:36
dkoshkin
dkoshkin previously approved these changes Aug 9, 2024
@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch from 983e89f to 69a1780 Compare August 12, 2024 18:58
@github-actions github-actions bot added fix and removed fix labels Aug 12, 2024
@dkoshkin dkoshkin dismissed their stale review August 12, 2024 19:58

Testing more changes

@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch 2 times, most recently from 651e249 to faac093 Compare August 12, 2024 21:35
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work here, this was a hard one!

Copy link
Contributor

@faiq faiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good work.

jimmidyson and others added 7 commits August 13, 2024 10:30
This commit starts fixing a bug that means
addons fail to be fully deployed if the cluster name
is longer than 44 characters. This is caused by the name
of the HCP being over 63 characters. This name is then
used in HRP labels which have a maximum length of 63
characters, so the HRPs are rejected by the API server
when CAAPH applies them.

The fix is to use generate name and labels on the
HCP to ensure uniqueness by lookup rather than by using
a deterministic name.
@jimmidyson jimmidyson force-pushed the jimmi/fix-hcp-naming-labels branch from 62a2dba to 366044e Compare August 13, 2024 09:31
@jimmidyson jimmidyson merged commit eeeb5c2 into main Aug 13, 2024
15 checks passed
@jimmidyson jimmidyson deleted the jimmi/fix-hcp-naming-labels branch August 13, 2024 11:37
@github-actions github-actions bot mentioned this pull request Aug 13, 2024
jimmidyson pushed a commit that referenced this pull request Aug 13, 2024
🤖 I have created a release *beep* *boop*
---


## 0.13.7 (2024-08-13)

<!-- Release notes generated using configuration in .github/release.yaml
at main -->

## What's Changed
### Fixes 🔧
* fix: Deterministic ordering of lifecycle hooks by @jimmidyson in
#847
* fix: reorder lifecycle handlers with serviceloadbalancer being last by
@dkoshkin in
#848
* fix: update mindthegap by @faiq in
#852
* fix: Handle long cluster names by @jimmidyson in
#845


**Full Changelog**:
v0.13.6...v0.13.7

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants