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

oc: add -o revision in rollout latest #11357

Merged
merged 3 commits into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -11674,6 +11674,8 @@ _oc_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -16238,6 +16238,8 @@ _openshift_cli_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down Expand Up @@ -26529,6 +26531,8 @@ _openshift_kube_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--allow-verification-with-non-compliant-keys")
flags+=("--alsologtostderr")
flags+=("--application-metrics-count-limit=")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -11835,6 +11835,8 @@ _oc_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
4 changes: 4 additions & 0 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -16399,6 +16399,8 @@ _openshift_cli_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down Expand Up @@ -26690,6 +26692,8 @@ _openshift_kube_rollout_status()
flags+=("--recursive")
flags+=("-R")
local_nonpersistent_flags+=("--recursive")
flags+=("--revision=")
local_nonpersistent_flags+=("--revision=")
flags+=("--allow-verification-with-non-compliant-keys")
flags+=("--alsologtostderr")
flags+=("--application-metrics-count-limit=")
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/oc-rollout-status.1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Watch the status of the latest rollout, until it's done.
\fB\-R\fP, \fB\-\-recursive\fP=false
Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.

.PP
\fB\-\-revision\fP=0
Pin to a specific revision for showing its status. Defaults to 0 (last revision).


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/openshift-cli-rollout-status.1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Watch the status of the latest rollout, until it's done.
\fB\-R\fP, \fB\-\-recursive\fP=false
Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.

.PP
\fB\-\-revision\fP=0
Pin to a specific revision for showing its status. Defaults to 0 (last revision).


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/openshift-kube-rollout-status.1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Watch the status of current rollout, until it's done.
\fB\-R\fP, \fB\-\-recursive\fP=false
Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.

.PP
\fB\-\-revision\fP=0
Pin to a specific revision for showing its status. Defaults to 0 (last revision).


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
Expand Down
15 changes: 10 additions & 5 deletions pkg/cmd/cli/cmd/rollout/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ type RolloutLatestOptions struct {
typer runtime.ObjectTyper
infos []*resource.Info

out io.Writer
shortOutput bool
again bool
out io.Writer
output string
again bool

oc client.Interface
kc kclient.Interface
Expand Down Expand Up @@ -108,7 +108,7 @@ func (o *RolloutLatestOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command
}

o.out = out
o.shortOutput = kcmdutil.GetFlagString(cmd, "output") == "name"
o.output = kcmdutil.GetFlagString(cmd, "output")
o.again = kcmdutil.GetFlagBool(cmd, "again")

return nil
Expand Down Expand Up @@ -166,6 +166,11 @@ func (o RolloutLatestOptions) RunRolloutLatest() error {

info.Refresh(dc, true)

kcmdutil.PrintSuccess(o.mapper, o.shortOutput, o.out, info.Mapping.Resource, info.Name, "rolled out")
if o.output == "revision" {
fmt.Fprintf(o.out, fmt.Sprintf("%d", dc.Status.LatestVersion))
return nil
}

kcmdutil.PrintSuccess(o.mapper, o.output == "name", o.out, info.Mapping.Resource, info.Name, "rolled out")
return nil
}
9 changes: 7 additions & 2 deletions pkg/deploy/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ type DeploymentConfigStatusViewer struct {
var _ kubectl.StatusViewer = &DeploymentConfigStatusViewer{}

// Status returns a message describing deployment status, and a bool value indicating if the status is considered done
func (s *DeploymentConfigStatusViewer) Status(namespace, name string) (string, bool, error) {
func (s *DeploymentConfigStatusViewer) Status(namespace, name string, desiredRevision int64) (string, bool, error) {
config, err := s.dn.DeploymentConfigs(namespace).Get(name)
if err != nil {
return "", false, err
}
latestRevision := config.Status.LatestVersion

if config.Status.LatestVersion == 0 {
if latestRevision == 0 {
switch {
case deployutil.HasImageChangeTrigger(config):
return fmt.Sprintf("Deployment config %q waiting on image update\n", name), false, nil
Expand All @@ -40,6 +41,10 @@ func (s *DeploymentConfigStatusViewer) Status(namespace, name string) (string, b
}
}

if desiredRevision > 0 && latestRevision != desiredRevision {
return "", false, fmt.Errorf("desired revision (%d) is different from the running revision (%d)", desiredRevision, latestRevision)
}

cond := deployutil.GetDeploymentCondition(config.Status, deployapi.DeploymentProgressing)

if config.Generation <= config.Status.ObservedGeneration {
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ os::cmd::try_until_success 'oc get rc/failing-dc-1'
os::cmd::expect_success 'oc logs -f dc/failing-dc'
os::cmd::expect_failure 'oc rollout status dc/failing-dc'
os::cmd::expect_success_and_text 'oc logs dc/failing-dc' 'test pre hook executed'
os::cmd::expect_success 'oc rollout latest dc/failing-dc --again'
os::cmd::expect_success_and_text 'oc rollout latest failing-dc --again -o revision' '2'
os::cmd::expect_success_and_text 'oc logs --version=1 dc/failing-dc' 'test pre hook executed'
os::cmd::expect_success_and_text 'oc logs --previous dc/failing-dc' 'test pre hook executed'
# Make sure --since-time adds the right query param, and actually returns logs
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions vendor/k8s.io/kubernetes/pkg/kubectl/rollout_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.