oc: add rollout cancel#10731
Conversation
| allErrs := []error{} | ||
| err := opts.Complete(f, args, out) | ||
| if err != nil { | ||
| allErrs = append(allErrs, err) |
There was a problem hiding this comment.
We shouldn't do this. That's the problem you need to fix for rollout pause and rollout resume upstream in kubernetes/kubernetes#31234
c432680 to
0635840
Compare
|
|
||
| func (o *RolloutCancelOptions) Complete(f *clientcmd.Factory, args []string, out io.Writer) error { | ||
| if len(args) > 1 { | ||
| return errors.New("only one deployment config name is supported as argument.") |
There was a problem hiding this comment.
Don't the rest of the rollout commands support multiple arguments?
There was a problem hiding this comment.
yeah, I think I want to rework this to follow the upstream pattern.
|
@openshift/cli-review this is part of #9298 |
|
Needs a test in hack/test-cmd.sh |
f191bbe to
68e784e
Compare
| } | ||
|
|
||
| // cancel cancels any deployment process in progress for config. | ||
| // TODO: this code will be deprecated |
There was a problem hiding this comment.
Are we already going to cmd.Flags().MarkDeprecated in --cancel, or not yet?
There was a problem hiding this comment.
@fabianofranz I think we can do that now.
|
Might need to review the help info in |
|
@fabianofranz right, if we mark the |
a27e506 to
114e5fb
Compare
|
@Kargakis @fabianofranz marked I will follow up with documentation PR when this is merged. |
| e2e.Logf("%02d: cancelling deployment", i) | ||
| if out, err := oc.Run("deploy").Args("dc/deployment-simple", "--cancel").Output(); err != nil { | ||
| if out, err := oc.Run("rollout").Args("cancel", "dc/deployment-simple").Output(); err != nil { | ||
| // TODO: we should fix this |
There was a problem hiding this comment.
A different issue but do we want to retry cancel on update conflicts? Better yet should we use PATCH for cancel?
There was a problem hiding this comment.
@Kargakis i think I like the PATCH approach... we should get it merged in upstream... i will spawn an issue and do it as follow up.
There was a problem hiding this comment.
upstream does not have rollout cancel
|
[test] |
|
@openshift/cli-review PTAL |
90d3a2c to
b93a2be
Compare
| } | ||
| rc.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue | ||
| rc.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser | ||
| if _, err := o.Client.ReplicationControllers(rc.Namespace).Update(rc); err != nil { |
There was a problem hiding this comment.
Maybe we should retry on conflicts until we switch to patch?
There was a problem hiding this comment.
i can wrap it with RetryOnConflict and add TODO
There was a problem hiding this comment.
scratch that... switching this command to client set and patch \o/
49794cd to
6e3284f
Compare
|
@Kargakis updated to use PATCH (and addressed your comments) |
| } | ||
|
|
||
| patches := set.CalculatePatches([]*resource.Info{&resource.Info{Object: rc, Mapping: mapping}}, o.Encoder, func(rcInfo *resource.Info) (bool, error) { | ||
| deployment, ok := rcInfo.Object.(*kapi.ReplicationController) |
There was a problem hiding this comment.
Can you not use "deployment" for a rc?
There was a problem hiding this comment.
i see what you mean now
| cmd.Flags().MarkDeprecated("latest", fmt.Sprintf("use '%s rollout latest' instead", fullName)) | ||
| cmd.Flags().BoolVar(&options.retryDeploy, "retry", false, "Retry the latest failed deployment.") | ||
| cmd.Flags().BoolVar(&options.cancelDeploy, "cancel", false, "Cancel the in-progress deployment.") | ||
| cmd.Flags().MarkDeprecated("cancel", fmt.Sprintf("use %s rollout cancel instead", fullName)) |
There was a problem hiding this comment.
add single quotes around the command
| cmd.Flags().BoolVar(&options.cancelDeploy, "cancel", false, "Cancel the in-progress deployment.") | ||
| cmd.Flags().MarkDeprecated("cancel", fmt.Sprintf("use %s rollout cancel instead", fullName)) | ||
| cmd.Flags().BoolVar(&options.enableTriggers, "enable-triggers", false, "Enables all image triggers for the deployment config.") | ||
| cmd.Flags().MarkDeprecated("enable-triggers", fmt.Sprintf("use %s set triggers instead", fullName)) |
There was a problem hiding this comment.
add single quotes around the command
| return nil, err | ||
| } | ||
| if len(deployments.Items) == 0 { | ||
| return nil, fmt.Errorf("there have been no deployments for %s/%s\n", namespace, name) |
There was a problem hiding this comment.
s/deployments/replication controllers/
| maybeCancelling = " (cancelling)" | ||
| } | ||
| timeAt := strings.ToLower(units.HumanDuration(time.Now().Sub(latest.CreationTimestamp.Time))) | ||
| fmt.Fprintf(o.Out, "No deployments are in progress (latest deployment #%d %s%s %s ago)\n", |
There was a problem hiding this comment.
No rollouts are in progress (latest rollout ... )
|
|
||
| for _, deployment := range deployments.Items { | ||
| status := deployutil.DeploymentStatusFor(&deployment) | ||
| switch status { |
There was a problem hiding this comment.
Should we print something in case a rollout for a rc is terminated?
There was a problem hiding this comment.
we did not for oc deploy --cancel
There was a problem hiding this comment.
Actually we do
$ oc deploy --cancel dc/router
No deployments are in progress (latest deployment #1 complete 4 minutes ago)
but it's already covered in your code.
| return | ||
| } | ||
| kcmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "cancelling") | ||
| cancelled = true |
There was a problem hiding this comment.
This will change to true if the latest rollout for a DC is cancelled but what if you have an additional DC with the latest rollout still ongoing?
There was a problem hiding this comment.
2 parallel rollouts for 1 dc?
There was a problem hiding this comment.
@Kargakis we reset this to false for each DC
There was a problem hiding this comment.
i reworked this to be more clean and do not shadow the cancelled variable in the function
011d784 to
74bcc22
Compare
|
LGTM [merge] |
74bcc22 to
682df97
Compare
|
[test] |
682df97 to
fbf199e
Compare
fbf199e to
800451f
Compare
800451f to
ba3450c
Compare
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12180/) (Image: devenv-rhel7_5513) |
|
flakes: #11024 && yum [merge] |
|
Evaluated for origin merge up to ba3450c |
|
[test] |
|
Evaluated for origin test up to ba3450c |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12180/) (Base Commit: f2427b8) |
This moves the code responsible for cancellation to
cmd/cli/rollback/cancel.goand add new sub-command foroc rollout. It also provides compatibility helper foroc deploy --cancel:Fixes: #11225
@Kargakis @fabianofranz PTAL