-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Defaulting functions do not get called #1038
Comments
This should fix the issue, please re-open if not. |
The actual problem is not the missing defaulter functions generated. Already did this manually. The problem is that those functions don't get called by the client. The current workaround is to call them explicitly: Is this the way it is supposed to be used? |
@baichinger Hello. I've looked into this and I think I found what might be causing the issues. I found some examples of defaulters here: https://github.com/kubernetes/gengo/tree/master/examples/defaulter-gen/_output_tests All of the projects that have defaulters include this function in their func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
} I imported your project, added that function to your v1alpha1 package's |
It does not make any difference if the functions gets registered either by |
@baichinger Just weighing in on this, I think the correct behavior for the controller-runtime client is to return exactly what is there on the server, without adding defaults to the CR. The recommended way to default CRDs is via mutating admission webhooks. The controller-runtime has APIs to help setup admission webhooks so I would defer to that for now. We don't have a workflow for webhooks in the SDK right now but we'll most likely utilize the same APIs to help users setup webhooks for defaulting. @theishshah @AlexNPavel With that being said I don't see a use case for running the defaulter-gen in the SDK so I think we might need to revert #1050 Related: #269 |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/close |
@baichinger: Closing this issue. In response to this:
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. |
Bug Report
What did you do?
The generated defaulting functions for the CRD do not get called. Code generation was done via
RegisterDefaults
gets invoked during startup. The registered functionSetObjectDefaults_OneAgent
does not.What did you expect to see?
Defaulting function
SetObjectDefaults_OneAgent
gets called.What did you see instead? Under which circumstances?
Functions do not get called. This causes a panic later on during reconciliation as fields are not setup as expected.
Environment
operator-sdk version:
v0.4.0
Kubernetes version information:
v1.9.11, v1.13.1
Kubernetes cluster kind:
kubeadm
Are you writing your operator in ansible, helm, or go?
Golang
Additional context
Defaulters did work in previous version of operator-sdk (v0.0.5).
The text was updated successfully, but these errors were encountered: