-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Add input validations for controllers #11327
🌱 Add input validations for controllers #11327
Conversation
Started with cluster controller based on the review comments will proceed to others. Please take a look when you get chance @sbueringer. Thank you. |
2f3ded6
to
9c90a00
Compare
@@ -87,6 +87,10 @@ type Reconciler struct { | |||
} | |||
|
|||
func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { | |||
if r.Client == nil || r.APIReader == nil || r.ClusterCache == nil || r.RemoteConnectionGracePeriod == time.Duration(0) { |
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.
@sbueringer we spoke about having at least 180s for RemoteConnectionGracePeriod. Is this a good chance to check for this here or was this a different thing?
(note not sure if I mix up things)
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'll do this as part of my PR and I'm going to enforce it directly on the flag (maybe additionally in these places, but I'll take care of that)
Goal of this PR is mostly to safeguard against cases where ClusterCache etc is nil or grace period is not set at all. So that we don't have to check e.g. ClusterCache for nil in other parts of the reconciler code
9c90a00
to
728ca8a
Compare
/retest |
Not sure is this failure related to my change! |
It probably is. Looks like CAPD is not coming up. Maybe you can check if we are missing one of the fields we're now validating in the Docker provider |
Will do. |
@@ -63,7 +62,6 @@ const ( | |||
// DockerMachinePoolReconciler reconciles a DockerMachinePool object. | |||
type DockerMachinePoolReconciler struct { | |||
Client client.Client | |||
Scheme *runtime.Scheme |
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 see its not used in the Reconiler so removed it instead of passing mgr.GetScheme() from main.go.
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.
Makes sense, thx for checking!
Thank you very much! /lgtm |
LGTM label has been added. Git tree hash: 0f52913260a1313626993e4d2f62a3ea5c4caaaf
|
[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 |
@Karthik-K-N Now that we ensure that all required fields are set after SetupWithManager we can go ahead and remove the two occurences of |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes # One of the tasks of #11272