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

crd-bumper: A tool to bump a repo's CRD versions. #189

Merged
merged 16 commits into from
Aug 27, 2024
Merged

Conversation

roehrich-hpe
Copy link
Contributor

See Kubebuilder's "Tutorial: Multi-Version API"
(https://book.kubebuilder.io/multiversion-tutorial/tutorial) for a description of the mechanism.

This tool implements the hub-and-spoke model of CRD versioning. See Kubebuilder's "Hubs, spokes, and other wheel metaphors" (https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts) for a description of the model.

See Kubebuilder's "Tutorial: Multi-Version API"
(https://book.kubebuilder.io/multiversion-tutorial/tutorial)
for a description of the mechanism.

This tool implements the hub-and-spoke model of CRD versioning. See
Kubebuilder's "Hubs, spokes, and other wheel metaphors"
(https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts)
for a description of the model.

Signed-off-by: Dean Roehrich <[email protected]>
Signed-off-by: Dean Roehrich <[email protected]>
Signed-off-by: Dean Roehrich <[email protected]>
Signed-off-by: Dean Roehrich <[email protected]>
```console
git clone [email protected]:NearNodeFlash/lustre-fs-operator.git
cd lustre-fs-operator
crd-bumper.py --most-recent-spoke v1alpha1 --prev-ver v1beta1 --new-ver v1beta2 all
Copy link
Contributor

@bdevcich bdevcich Aug 22, 2024

Choose a reason for hiding this comment

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

The instructions above assume you're in this directory, so do we need to add the cloned folders to .gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the tool does the clone for you, and clones it under workingspace/lustre-fs-operator (in this case). That dir is already covered by .gitignore.

@bdevcich
Copy link
Contributor

I'd recommend running all this python code through black:

$ black --check .
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/copyright.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/fileutil.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/project.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/make_cmd.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/crd-bumper.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/controllers.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/git_cli.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/create_apis.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/webhooks.py
would reformat /Users/blakedevcich/src/rabbit/nnf-deploy/tools/crd-bumper/pkg/conversion_gen.py

Oh no! 💥 💔 💥
10 files would be reformatted, 1 file would be left unchanged.

No other changes.

Signed-off-by: Dean Roehrich <[email protected]>
@roehrich-hpe
Copy link
Contributor Author

I'd recommend running all this python code through black:

Done.

roehrich-hpe and others added 3 commits August 23, 2024 08:48
@ajfloeder
Copy link
Contributor

How does versioned CRDs change the development process from the case where CRDs can be modified without regard version.
Would I be responsible for knowing I'm about to create a new version of the CRD and use this tool before I implement that new version? OR
Would I develop my new CRD completely, then use this tool to bump the version and create the conversion routines?

@roehrich-hpe
Copy link
Contributor Author

roehrich-hpe commented Aug 23, 2024

How does versioned CRDs change the development process from the case where CRDs can be modified without regard version. Would I be responsible for knowing I'm about to create a new version of the CRD and use this tool before I implement that new version? OR Would I develop my new CRD completely, then use this tool to bump the version and create the conversion routines?

In DWS and lustre-fs-operator, we created a second API version 16 months ago. Think about how you have been making changes in those repos since then. When you make a change there, you're changing the most current API version (the hub), and letting 'make test' tell you when you need to add a conversion routine to the previous version (the spoke).

I think we do need to document some guidelines, some best practices. Just thinking about our experiences in writing the conversion routines, and what sorts of things add to the complexity of those routines, it seems best to not rename a field, or change the type of a field. That's just one example.

@roehrich-hpe
Copy link
Contributor Author

How does versioned CRDs change the development process from the case where CRDs can be modified without regard version. Would I be responsible for knowing I'm about to create a new version of the CRD and use this tool before I implement that new version? OR Would I develop my new CRD completely, then use this tool to bump the version and create the conversion routines?

In DWS and lustre-fs-operator, we created a second API version 16 months ago. Think about how you have been making changes in those repos since then. When you make a change there, you're changing the most current API version (the hub), and letting 'make test' tell you when you need to add a conversion routine to the previous version (the spoke).

I think we do need to document some guidelines, some best practices. Just thinking about our experiences in writing the conversion routines, and what sorts of things add to the complexity of those routines, it seems best to not rename a field, or change the type of a field. That's just one example.

Another example: if the field has a +kubebuilder:default, then be very careful about changing the default value. If the hub and the spoke have different defaults, give some consideration about how to handle the conversion routine.

@bdevcich
Copy link
Contributor

Another example: if the field has a +kubebuilder:default, then be very careful about changing the default value. If the hub and the spoke have different defaults, give some consideration about how to handle the conversion routine.

I could see this sort of thing come up when changing defaults in Nnf*Profile resources. Especially with tweaking data movement.

Signed-off-by: Dean Roehrich <[email protected]>
Copy link
Contributor

@bdevcich bdevcich left a comment

Choose a reason for hiding this comment

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

Bravo! 👏

Signed-off-by: Dean Roehrich <[email protected]>
Signed-off-by: Dean Roehrich <[email protected]>
@roehrich-hpe roehrich-hpe merged commit 017bef4 into master Aug 27, 2024
1 check passed
@roehrich-hpe roehrich-hpe deleted the crd-bumper branch August 27, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants