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

🐛 Check MachineConfig spec for full equality with Rke2CPSpec #325

Conversation

Danil-Grigorev
Copy link
Contributor

What this PR does / why we need it:

We need to ensure that any change of RKE2ConfigTemplate is causing CP machines re-rollout.

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 #307

Special notes for your reviewer:

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@Danil-Grigorev Danil-Grigorev added the kind/bug Something isn't working label May 16, 2024
@Danil-Grigorev Danil-Grigorev changed the title Check MachineConfig spec for full equality with Rke2CPSpec 🐛 Check MachineConfig spec for full equality with Rke2CPSpec May 16, 2024
@Danil-Grigorev Danil-Grigorev force-pushed the re-rollout-cp-on-commands-change branch 2 times, most recently from fdd44aa to 2a7f097 Compare May 17, 2024 08:04
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev Danil-Grigorev force-pushed the re-rollout-cp-on-commands-change branch from 2a7f097 to da42f22 Compare May 17, 2024 08:30
Copy link
Contributor

@salasberryfin salasberryfin left a comment

Choose a reason for hiding this comment

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

LGTM. Just a question on checking the object type.

Comment on lines +308 to +311
m, ok := o.(*clusterv1.Machine)
if !ok {
panic(fmt.Sprintf("Expected a Machine but got a %T", o))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this explicit check required? Isn't it guaranteed that the object the controller watches is of type clusterv1.Machine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly just copied from kubeadm provider implementation at this point, but this should be guarantied in most of the cases, and is guarantied when using generic watches. Though the desired UX for using generic watches expects to replace all For/Owns methods with Watches. This is inconvenient and does not worth the effort. To eliminate the need for an explicit type casting, a set of helper methods can be introduced upstream to connect non generic controller with generic EventMappers of Predicates.

Comment on lines +328 to +331
c, ok := o.(*clusterv1.Cluster)
if !ok {
panic(fmt.Sprintf("Expected a Cluster but got a %T", o))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as with Machine.

@Danil-Grigorev Danil-Grigorev merged commit 98db7f6 into rancher-sandbox:main May 20, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no control plane node rolling update is triggered on a change of preRKE2Commands
3 participants