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

🌱 Add input validations for controllers #11327

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

Karthik-K-N
Copy link
Contributor

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 23, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 23, 2024
@Karthik-K-N
Copy link
Contributor Author

Started with cluster controller based on the review comments will proceed to others. Please take a look when you get chance @sbueringer. Thank you.

@@ -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) {
Copy link
Member

@chrischdi chrischdi Oct 23, 2024

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)

Copy link
Member

@sbueringer sbueringer Oct 23, 2024

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

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 24, 2024
@sbueringer
Copy link
Member

/retest

@Karthik-K-N
Copy link
Contributor Author

Not sure is this failure related to my change!

@sbueringer
Copy link
Member

sbueringer commented Oct 24, 2024

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

@Karthik-K-N
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

Copy link
Member

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!

@sbueringer sbueringer added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. area/util Issues or PRs related to utils labels Oct 25, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Oct 25, 2024
@sbueringer
Copy link
Member

Thank you very much!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 25, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0f52913260a1313626993e4d2f62a3ea5c4caaaf

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 25, 2024
@k8s-ci-robot k8s-ci-robot merged commit e5cbc4a into kubernetes-sigs:main Oct 25, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Oct 25, 2024
@sbueringer
Copy link
Member

@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 if r.ClusterCache == nil { that we have in machine_controller.go and machinehealthcheck_controller.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/util Issues or PRs related to utils cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants