-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Using utilruntime.Must() for adding schemes #1462
Merged
k8s-ci-robot
merged 2 commits into
kubernetes-sigs:master
from
christopherhein:chore/utilruntime-schemes
Apr 10, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but could you add in the first comment one example of scenario that is solved/attended with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not directly experiencing issues from this but from a best practices side in most other implementations of
AddingToScheme()
they implementutilruntime.Must()
to ensure panics causing the controller to crash. https://github.com/search?q=org%3Akubernetes+utilruntime.Must&type=Code and https://github.com/search?q=org%3Akubernetes-sigs+utilruntime.Must&type=CodePotentially it doesn't matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @christopherhein,
I checked the Must impl here, and it just causes a panic error.
See here that it is not used in the biggest part of the places where the addSchema is used in the example provided. Also, if it is a good practice then:
Note that the errors returned has been explicitly ignored in the Kubebuilder projects, and then I was curious if you face any issue that justifies it.
Also, start to cause an panic error in all these scenarios may not be the expected behaviour. For example, will the panic occurs if the CRD required not be found in the cluster? What are the possible errors/scenarios where an error can be returned from it? Would be required to kill the project in all these circumstances?
Did you checked that already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it's reasonable to just let the controller fail if it can't even add scheme.
@droot @DirectXMan12 Thoughts?
From my understanding no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @camilamacedo86 sorry for the delayed response here. For now I've put in a PR to also add documentation to the scheme - kubernetes-sigs/controller-runtime#894
I had looked into a handful of the other implementation and most will cause Panics already for example if you register all the schemes from `client-go this https://github.com/kubernetes/client-go/blob/master/kubernetes/scheme/register.go#L133 will panic if there are issues.
I discussed this yesterday with @DirectXMan12 and they'd mentioned that this "either a) it was an oversight, or b) that pattern turned up after we had started writing our examples" and "we really should be checking the return value"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the errors usually come from errors in the conversion or defaulting registration since I've been able to repro panics by doing things like registering schemes of CRDs with the same GVK as standard k8s objects.