-
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
✨ clusterctl alpha rollout pause/resume for MachineDeployments #4054
✨ clusterctl alpha rollout pause/resume for MachineDeployments #4054
Conversation
Hi @Arvinderpal. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
@wfernandes @vincepri PTAL. |
@Arvinderpal Thanks for this PR! I'll take a look at this first thing next week 🙂 |
/ok-to-test |
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 the PR @Arvinderpal. Just some minor comments 🙂
cmd/clusterctl/client/rollout.go
Outdated
clusterClient, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: options.Kubeconfig}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// If the option specifying the Namespace is empty, try to detect it. | ||
if options.Namespace == "" { | ||
currentNamespace, err := clusterClient.Proxy().CurrentNamespace() | ||
if err != nil { | ||
return err | ||
} | ||
options.Namespace = currentNamespace | ||
} | ||
|
||
if len(options.Resources) == 0 { | ||
return fmt.Errorf("required resource not specified") | ||
} | ||
normalized := normalizeResources(options.Resources) | ||
tuples, err := util.ResourceTypeAndNameArgs(normalized...) | ||
if err != nil { | ||
return err | ||
} |
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.
This code seems duplicated in every method. I suggest refactoring it to consolidate this.
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.
Refactored it.
@@ -32,7 +32,7 @@ func Test_clusterctlClient_RolloutRestart(t *testing.T) { | |||
client *fakeClient | |||
} | |||
type args struct { | |||
options RolloutRestartOptions | |||
options RolloutOptions |
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.
Let's refactor this test so that we can assert on each of the rollout behaviors - pause, resume, restart.
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.
Done. PTAL
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.
@wfernandes Thank you for the review. I think I have addressed all your comments.
cmd/clusterctl/client/rollout.go
Outdated
clusterClient, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: options.Kubeconfig}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// If the option specifying the Namespace is empty, try to detect it. | ||
if options.Namespace == "" { | ||
currentNamespace, err := clusterClient.Proxy().CurrentNamespace() | ||
if err != nil { | ||
return err | ||
} | ||
options.Namespace = currentNamespace | ||
} | ||
|
||
if len(options.Resources) == 0 { | ||
return fmt.Errorf("required resource not specified") | ||
} | ||
normalized := normalizeResources(options.Resources) | ||
tuples, err := util.ResourceTypeAndNameArgs(normalized...) | ||
if err != nil { | ||
return err | ||
} |
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.
Refactored it.
@@ -32,7 +32,7 @@ func Test_clusterctlClient_RolloutRestart(t *testing.T) { | |||
client *fakeClient | |||
} | |||
type args struct { | |||
options RolloutRestartOptions | |||
options RolloutOptions |
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.
Done. PTAL
a829333
to
67d64f1
Compare
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.
Just a clarification. Thanks.
cmd/clusterctl/client/rollout.go
Outdated
clusterClient, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: options.Kubeconfig}) | ||
if err != nil { | ||
return err | ||
} | ||
tuples, err := getResourceTuples(clusterClient, options) | ||
if err != nil { | ||
return nil |
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.
Umm...is this correct? Or should this be return err
? It also looks like the tests all passed having this logic in so if this is indeed meant to be return err
then we should have a unit test that asserts this. Thanks!
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 pointing that out! The fakeClient was not calling the individual funcs for the subcommands.
I also had to separate these tests -- for example, the RolloutResume will throw an error if the md is not paused, while the RolloutRestart will do the opposite if it is paused, so the same test cases cannot be passed to all of them.
There are additional tests in the lower level funcs that check for functional correctness. Is it okay if we keep these tests relatively simple?
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.
yeah...that's fine. I just wanted to ensure that if I changed this to return nil
and run the tests in the client
pkg, then I would see a failing test for the right reason. 🙂
f0b137d
to
43afe6c
Compare
/lgtm |
Thanks @wfernandes |
/milestone v0.4.0 |
@Arvinderpal If you'd like to submit the PR for the |
@wfernandes That's a good idea. I'll open an |
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.
@vincepri Thanks for the review. I have incorporated your suggestions.
for MachineDeployments.
43afe6c
to
b769eab
Compare
/lgtm |
@vincepri Can we merge this? |
) | ||
|
||
// NewCmdRolloutPause returns a Command instance for 'rollout pause' sub command | ||
func NewCmdRolloutPause(cfgFile string) *cobra.Command { |
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.
are you planning to add docs for the pause/resume command in a separate PR?
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 actually don't see any docs for the rollout command in https://github.com/kubernetes-sigs/cluster-api/tree/master/docs/book/src/clusterctl/commands, are we tracking that in an issue?
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.
@CecileRobertMichon There is a tracking issue and docs is in the list: #3439
If it's okay with you, I want to wait for a few more rollout subcommands to merge before opening a PR for the docs.
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.
/approve
/hold
/assign @CecileRobertMichon
to remove the hold if everything looks 👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
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.
/hold cancel
/retest |
@Arvinderpal: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
What this PR does / why we need it:
Adds command and client for the
clusterctl alpha rollout pause/resume
.Tracking Issue:
#3439