-
Notifications
You must be signed in to change notification settings - Fork 130
Cleanup deprecated types and functions, Use modern go methods #1038
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
base: master
Are you sure you want to change the base?
Conversation
187789a
to
dd870dc
Compare
Integration Test logs:
|
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.
Thanks for this PR @takoverflow! very helpful and very much needed
I have a few queries, please address them.
Also, you need to re-generate pkg/client/listers/machine/v1alpha1/expansion_generated.go
as I see they're still using interface{}
), | ||
machineSetQueue: workqueue.NewTypedRateLimitingQueueWithConfig( | ||
workqueue.DefaultTypedControllerRateLimiter[string](), | ||
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"}, |
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.
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"}, | |
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machineset"}, |
), | ||
machineSetQueue: workqueue.NewTypedRateLimitingQueueWithConfig( | ||
workqueue.DefaultTypedControllerRateLimiter[string](), | ||
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"}, |
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.
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"}, | |
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machineset"}, |
// important when we start apiserver and controller manager at the same time. | ||
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) { | ||
immediatePoll := true | ||
err := wait.PollUntilContextTimeout(context.Background(), time.Second, 10*time.Second, immediatePoll, func(context.Context) (bool, error) { |
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.
wait.PollImmediate
is still used in pkg/controller/deployment_util.go
and cmd/machine-controller-manager/app/controllermanager.go
Can you update these places too?
} | ||
data := map[string][]byte{ | ||
bootstraptokenapi.BootstrapTokenDescriptionKey: []byte(fmt.Sprintf("A bootstrap token for machine %q generated by MachineControllerManager.", machine.Name)), | ||
bootstraptokenapi.BootstrapTokenDescriptionKey: fmt.Appendf(nil, "A bootstrap token for machine %q generated by MachineControllerManager.", machine.Name), |
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.
Could this not cause a panic? I ask as Appendf expects a byte array as the first argument and passing nil may potentially cause a panic
Alternatively you could pass an empty byte array
userDataSecret = &corev1.Secret{ | ||
Data: map[string][]byte{ | ||
"userData": []byte(fmt.Sprintf(userDataTemplate, "<<BOOTSTRAP_TOKEN>>", "<<MACHINE_NAME>>")), | ||
"userData": fmt.Appendf(nil, userDataTemplate, "<<BOOTSTRAP_TOKEN>>", "<<MACHINE_NAME>>"), |
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.
Same as above and 3 more places in this file
What this PR does / why we need it:
This PR substitutes usages of all the deprecated functions and types with their
recommended equivalents:
TypedRateLimitingQueue
instead ofRateLimitingQueue
PollUntilContextTimeout
instead of deprecatedPoll
andPollImmediate
functionsAlongwith it, also some cleanup was done that included (but not limited to):
any
instead ofinterface{}
maps.Copy()
, modernrange
for loops etcAnd some unused functions were removed from
controller_suite_test.go
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Would recommended looking at the PR commit by commit for easier reviewing.
Release note: