Skip to content

oc: add rollout cancel#10731

Merged
openshift-bot merged 4 commits into
openshift:masterfrom
mfojtik:rollout-cancel
Dec 9, 2016
Merged

oc: add rollout cancel#10731
openshift-bot merged 4 commits into
openshift:masterfrom
mfojtik:rollout-cancel

Conversation

@mfojtik

@mfojtik mfojtik commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

This moves the code responsible for cancellation to cmd/cli/rollback/cancel.go and add new sub-command for oc rollout. It also provides compatibility helper for oc deploy --cancel:

$ oc deploy --latest dc/demo-app
Started deployment #6
Use 'oc logs -f dc/demo-app' to track its progress.

$ oc rollout cancel dc/demo-app
Cancelled deployment #6

// To verify the old cancel works
$ oc deploy --latest dc/demo-app
Started deployment #7
Use 'oc logs -f dc/demo-app' to track its progress.

$ oc deploy --cancel dc/demo-app
Cancelled deployment #7

Fixes: #11225

@Kargakis @fabianofranz PTAL

@mfojtik mfojtik added this to the 1.3.1 milestone Aug 31, 2016
Comment thread pkg/cmd/cli/cmd/rollout/rollout.go Outdated
allErrs := []error{}
err := opts.Complete(f, args, out)
if err != nil {
allErrs = append(allErrs, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't do this. That's the problem you need to fix for rollout pause and rollout resume upstream in kubernetes/kubernetes#31234

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed (here).

@mfojtik mfojtik force-pushed the rollout-cancel branch 2 times, most recently from c432680 to 0635840 Compare September 5, 2016 09:11
Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated

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.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't the rest of the rollout commands support multiple arguments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, I think I want to rework this to follow the upstream pattern.

@0xmichalis

Copy link
Copy Markdown
Contributor

@openshift/cli-review this is part of #9298

@0xmichalis

Copy link
Copy Markdown
Contributor

Needs a test in hack/test-cmd.sh

@mfojtik mfojtik force-pushed the rollout-cancel branch 2 times, most recently from f191bbe to 68e784e Compare September 5, 2016 15:14
Comment thread pkg/cmd/cli/cmd/deploy.go
}

// cancel cancels any deployment process in progress for config.
// TODO: this code will be deprecated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we already going to cmd.Flags().MarkDeprecated in --cancel, or not yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fabianofranz I think we can do that now.

@fabianofranz

Copy link
Copy Markdown
Contributor

Might need to review the help info in oc deploy (remove references to "cancel" and possibly point to oc rollout, etc).

@smarterclayton smarterclayton modified the milestones: 1.3.1, 1.4.0 Sep 19, 2016
@mfojtik

mfojtik commented Oct 5, 2016

Copy link
Copy Markdown
Contributor Author

@fabianofranz right, if we mark the --cancel as deprecated, we need to replace all references to it everywhere.

@mfojtik mfojtik force-pushed the rollout-cancel branch 2 times, most recently from a27e506 to 114e5fb Compare October 5, 2016 11:55
@mfojtik

mfojtik commented Oct 5, 2016

Copy link
Copy Markdown
Contributor Author

@Kargakis @fabianofranz marked --cancel as deprecated (i hope everywhere). PTAL

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A different issue but do we want to retry cancel on update conflicts? Better yet should we use PATCH for cancel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

upstream does not have rollout cancel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mfojtik

mfojtik commented Oct 5, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@mfojtik

mfojtik commented Oct 5, 2016

Copy link
Copy Markdown
Contributor Author

@openshift/cli-review PTAL

@mfojtik mfojtik force-pushed the rollout-cancel branch 4 times, most recently from 90d3a2c to b93a2be Compare October 10, 2016 11:00
Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated
}
rc.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue
rc.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser
if _, err := o.Client.ReplicationControllers(rc.Namespace).Update(rc); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should retry on conflicts until we switch to patch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i can wrap it with RetryOnConflict and add TODO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

scratch that... switching this command to client set and patch \o/

@mfojtik

mfojtik commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

@Kargakis updated to use PATCH (and addressed your comments)

Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated
}

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you not use "deployment" for a rc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i see what you mean now

Comment thread pkg/cmd/cli/cmd/deploy.go Outdated
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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add single quotes around the command

Comment thread pkg/cmd/cli/cmd/deploy.go Outdated
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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add single quotes around the command

Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated
return nil, err
}
if len(deployments.Items) == 0 {
return nil, fmt.Errorf("there have been no deployments for %s/%s\n", namespace, name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/deployments/replication controllers/

Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated
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",

@0xmichalis 0xmichalis Dec 7, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No rollouts are in progress (latest rollout ... )


for _, deployment := range deployments.Items {
status := deployutil.DeploymentStatusFor(&deployment)
switch status {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we print something in case a rollout for a rc is terminated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we did not for oc deploy --cancel

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread pkg/cmd/cli/cmd/rollout/cancel.go Outdated
return
}
kcmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "cancelling")
cancelled = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

2 parallel rollouts for 1 dc?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 DCs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Kargakis we reset this to false for each DC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now I see, ok

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i reworked this to be more clean and do not shadow the cancelled variable in the function

@mfojtik mfojtik force-pushed the rollout-cancel branch 2 times, most recently from 011d784 to 74bcc22 Compare December 7, 2016 14:17
@0xmichalis

Copy link
Copy Markdown
Contributor

LGTM [merge]

@mfojtik

mfojtik commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@openshift-bot

openshift-bot commented Dec 8, 2016

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12180/) (Image: devenv-rhel7_5513)

@mfojtik

mfojtik commented Dec 8, 2016

Copy link
Copy Markdown
Contributor Author

flakes: #11024 && yum

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to ba3450c

@mfojtik

mfojtik commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to ba3450c

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12180/) (Base Commit: f2427b8)

@openshift-bot openshift-bot merged commit 5e81dae into openshift:master Dec 9, 2016
@mfojtik mfojtik deleted the rollout-cancel branch September 5, 2018 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants