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

Multiple version in CRD Support #879

Merged
merged 7 commits into from
Jan 31, 2022
Merged

Multiple version in CRD Support #879

merged 7 commits into from
Jan 31, 2022

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Jan 28, 2022

No description provided.

metadata:
name: mvcv1
labels:
version: v1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add an example to show what happens if one of the label is missing and the Spec is incompatible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To cover that we would need to add a conversion web-hook, build it and etc, what would be a relatively significant effort. Without conversion hook that would fail, but that is expected; it would not be a bug; We can create a separate example to cover that, here just plan to add an integration test.

But the goal should not be to "test Kubernetes", maybe show best practices also. But that again not sure if it should go to core JOSDK. The current goal is to showcase features of sdk, and show how operators are implement / tested, not best practices - that is already covered in kubernetes.

On the other hand I recognize that this might be not trivial case. So I would propose to create a separate issues, first discuss where to put such sample - with conversion hook - and implement it after.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the SDK should not simply fails if there are no labels and no conversion webhooks, but should gracefully handle the situation.

Consider the following scenario:

  • the webhook is not in place
  • a user creates a CR without labels
  • the operator will start crashing

I do believe that this is not the desired nor expected behaviour.

Copy link
Collaborator Author

@csviri csviri Jan 28, 2022

Choose a reason for hiding this comment

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

@andreaTP I updated the sample, pls check last commit. Now every CR that has no label is processed only by v1 reconciler. Maybe this is a better example this way to shed a light how this is meant. (The integration test is not there yet)

Basically we can create a separate issues and discuss the graceful handling of error case. But this is not how it is meant, if there is missing conversion hook and the custom resources are not compatible without it, it is a bug in the system. These are typed APIs for a reason.

What I can imagin is if a CR received what we are not able to par, we log an error, but no means should reach the reconciler.

Copy link
Collaborator Author

@csviri csviri Jan 28, 2022

Choose a reason for hiding this comment

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

a user creates a CR without labels

This can be easily prevented by a validation hook. (But again changed the example so its more aware of this situtation)

Copy link
Collaborator

Choose a reason for hiding this comment

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

To me this sounds like this should not be part of the SDK at all if it's possible for a user to crash the operator just by using a specially crafted CR, webhooks or no webhooks because that basically means that you're trying to bypass the type system and I don't think that this should be encouraged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just an integration test that test if multiple versions of CR and Controllers can be created. (btw this changed a little bit since). Nothing more.

I think our goal should be in general to support all the possible use cases that Kubernetes supports. Unfortunately K8S is quite open how to use this feature (the multiple versions of CR in CRD). So in my opinion this approach is how it makes sense, thus to allow registering controller for different versions. From that point only the users responsibility to figure out the rest, get conversion hooks in place etc.

I think we should have a separate sample eventually in combination with the other framework (now called admission-controller-framework) - that will support conversion hooks - a complete setup.

I think it's totall valid to use labels for canary testing and add labels to the CRs only if user want it to be used with an other version of controller. But again this is just a test, don't want to set a patter. We could simplify it and just remove the labels, create as simple IT as possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But also open to suggestions to alternatives how to support and/or test this.

@sonarcloud
Copy link

sonarcloud bot commented Jan 28, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@csviri csviri marked this pull request as ready for review January 28, 2022 13:38
@csviri csviri requested a review from metacosm January 28, 2022 13:38
@csviri csviri linked an issue Jan 28, 2022 that may be closed by this pull request
@csviri csviri self-assigned this Jan 28, 2022
@metacosm metacosm merged commit 9d3dfd8 into main Jan 31, 2022
@metacosm metacosm deleted the multi-crd branch January 31, 2022 17:20
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.

Support multiple versions of a CRD
3 participants