Skip to content
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

✨ ClusterClass: Introduce NamingStrategy and allow generating names using go templates #9340

Merged

Conversation

chrischdi
Copy link
Member

@chrischdi chrischdi commented Aug 30, 2023

What this PR does / why we need it:

Introduces the NamingStrategy struct at the ClusterClass level for:

  • ControlPlane
  • MachineDeployments
  • MachinePools

Also introduces a new package which exposes functions and a interface to generate names.

TODO: improve this message here to have more details

TODO:

  • improve godocs
    • add examples of which template data struct to expect on the godocs
    • review all new godocs
  • unit tests

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #9323

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 30, 2023
@chrischdi
Copy link
Member Author

/test help

@k8s-ci-robot
Copy link
Contributor

@chrischdi: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-build-main
  • /test pull-cluster-api-e2e-main
  • /test pull-cluster-api-test-main
  • /test pull-cluster-api-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-apidiff-main
  • /test pull-cluster-api-e2e-full-dualstack-and-ipv6-main
  • /test pull-cluster-api-e2e-full-main
  • /test pull-cluster-api-e2e-informing-main
  • /test pull-cluster-api-e2e-mink8s-main
  • /test pull-cluster-api-e2e-scale-main-experimental
  • /test pull-cluster-api-e2e-workload-upgrade-1-28-latest-main
  • /test pull-cluster-api-test-mink8s-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-apidiff-main
  • pull-cluster-api-build-main
  • pull-cluster-api-e2e-informing-main
  • pull-cluster-api-e2e-main
  • pull-cluster-api-test-main
  • pull-cluster-api-verify-main

In response to this:

/test help

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.

@chrischdi
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@chrischdi
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@chrischdi
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

api/v1beta1/clusterclass_types.go Outdated Show resolved Hide resolved
internal/controllers/topology/cluster/desired_state.go Outdated Show resolved Hide resolved
internal/controllers/topology/names/namegenerator.go Outdated Show resolved Hide resolved
internal/test/builder/builders.go Outdated Show resolved Hide resolved
internal/controllers/topology/names/namegenerator.go Outdated Show resolved Hide resolved
internal/webhooks/clusterclass.go Outdated Show resolved Hide resolved
internal/webhooks/clusterclass.go Outdated Show resolved Hide resolved
internal/controllers/topology/names/namegenerator.go Outdated Show resolved Hide resolved
api/v1beta1/clusterclass_types.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 5, 2023
@chrischdi chrischdi force-pushed the pr-topology-namestrategy branch 8 times, most recently from 4716186 to 83fe2ea Compare September 6, 2023 07:05
@chrischdi
Copy link
Member Author

/test help

@k8s-ci-robot
Copy link
Contributor

@chrischdi: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-cluster-api-build-main
  • /test pull-cluster-api-e2e-main
  • /test pull-cluster-api-test-main
  • /test pull-cluster-api-verify-main

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-apidiff-main
  • /test pull-cluster-api-e2e-full-dualstack-and-ipv6-main
  • /test pull-cluster-api-e2e-full-main
  • /test pull-cluster-api-e2e-mink8s-main
  • /test pull-cluster-api-e2e-scale-main-experimental
  • /test pull-cluster-api-e2e-workload-upgrade-1-28-latest-main
  • /test pull-cluster-api-test-mink8s-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-apidiff-main
  • pull-cluster-api-build-main
  • pull-cluster-api-e2e-main
  • pull-cluster-api-test-main
  • pull-cluster-api-verify-main

In response to this:

/test help

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.

@chrischdi
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

Quote from the issue:

We would like to propose to cherry-pick this back into v1.5 (based on "Enhancements or additions to experimental Cluster API features"

/cherry-pick release-1.5

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.

@sbueringer
Copy link
Member

/assign @killianmuldoon @fabriziopandini

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 13, 2023
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Congrats on the very straightforward implementation - I thought it would be much more complex.

Just a couple of nits and a follow up from my side.

@@ -25,7 +25,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine as a follow-up, but we should document how to do this in the ClusterClass docs.

Copy link
Member

Choose a reason for hiding this comment

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

Which part of the docs do you think would this fit into?

I think for other fields we usually didn't write docs apart from godocs / descriptions for the CRD

(follow-up sounds fine in any case)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd do this in a follow-up PR :-)

Copy link
Member

Choose a reason for hiding this comment

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

Yup let's just discuss first what we want to document where before we do it ;)

internal/controllers/topology/cluster/desired_state.go Outdated Show resolved Hide resolved
internal/controllers/topology/cluster/desired_state.go Outdated Show resolved Hide resolved
@sbueringer
Copy link
Member

Thx!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 13, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 72034d79b1f268864c572e80cbf2a52c62eb6e0a

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 13, 2023
@k8s-ci-robot k8s-ci-robot merged commit 49e7f68 into kubernetes-sigs:main Sep 13, 2023
20 of 21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Sep 13, 2023
@k8s-infra-cherrypick-robot

@sbueringer: #9340 failed to apply on top of branch "release-1.5":

Applying: ClusterClass: Introduce NamingStrategy and allow generating names using go templates
Using index info to reconstruct a base tree...
M	api/v1alpha4/conversion.go
M	api/v1alpha4/zz_generated.conversion.go
M	api/v1beta1/clusterclass_types.go
M	api/v1beta1/zz_generated.deepcopy.go
M	api/v1beta1/zz_generated.openapi.go
M	config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml
M	internal/controllers/topology/cluster/desired_state.go
M	internal/controllers/topology/cluster/desired_state_test.go
M	internal/test/builder/builders.go
M	internal/test/builder/zz_generated.deepcopy.go
M	internal/webhooks/clusterclass.go
M	internal/webhooks/clusterclass_test.go
Falling back to patching base and 3-way merge...
Auto-merging internal/webhooks/clusterclass_test.go
CONFLICT (content): Merge conflict in internal/webhooks/clusterclass_test.go
Auto-merging internal/webhooks/clusterclass.go
Auto-merging internal/test/builder/zz_generated.deepcopy.go
CONFLICT (content): Merge conflict in internal/test/builder/zz_generated.deepcopy.go
Auto-merging internal/test/builder/builders.go
CONFLICT (content): Merge conflict in internal/test/builder/builders.go
Auto-merging internal/controllers/topology/cluster/desired_state_test.go
Auto-merging internal/controllers/topology/cluster/desired_state.go
CONFLICT (content): Merge conflict in internal/controllers/topology/cluster/desired_state.go
Auto-merging config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml
CONFLICT (content): Merge conflict in config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml
Auto-merging api/v1beta1/zz_generated.openapi.go
CONFLICT (content): Merge conflict in api/v1beta1/zz_generated.openapi.go
Auto-merging api/v1beta1/zz_generated.deepcopy.go
CONFLICT (content): Merge conflict in api/v1beta1/zz_generated.deepcopy.go
Auto-merging api/v1beta1/clusterclass_types.go
CONFLICT (content): Merge conflict in api/v1beta1/clusterclass_types.go
Auto-merging api/v1alpha4/zz_generated.conversion.go
Auto-merging api/v1alpha4/conversion.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 ClusterClass: Introduce NamingStrategy and allow generating names using go templates
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

Quote from the issue:

We would like to propose to cherry-pick this back into v1.5 (based on "Enhancements or additions to experimental Cluster API features"

/cherry-pick release-1.5

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants