Browse code

React to new --revision flag in rollout status

Michail Kargakis authored on 2016/10/14 01:36:23
Showing 8 changed files
... ...
@@ -11674,6 +11674,8 @@ _oc_rollout_status()
11674 11674
     flags+=("--recursive")
11675 11675
     flags+=("-R")
11676 11676
     local_nonpersistent_flags+=("--recursive")
11677
+    flags+=("--revision=")
11678
+    local_nonpersistent_flags+=("--revision=")
11677 11679
     flags+=("--as=")
11678 11680
     flags+=("--certificate-authority=")
11679 11681
     flags_with_completion+=("--certificate-authority")
... ...
@@ -16238,6 +16238,8 @@ _openshift_cli_rollout_status()
16238 16238
     flags+=("--recursive")
16239 16239
     flags+=("-R")
16240 16240
     local_nonpersistent_flags+=("--recursive")
16241
+    flags+=("--revision=")
16242
+    local_nonpersistent_flags+=("--revision=")
16241 16243
     flags+=("--as=")
16242 16244
     flags+=("--certificate-authority=")
16243 16245
     flags_with_completion+=("--certificate-authority")
... ...
@@ -26529,6 +26531,8 @@ _openshift_kube_rollout_status()
26529 26529
     flags+=("--recursive")
26530 26530
     flags+=("-R")
26531 26531
     local_nonpersistent_flags+=("--recursive")
26532
+    flags+=("--revision=")
26533
+    local_nonpersistent_flags+=("--revision=")
26532 26534
     flags+=("--allow-verification-with-non-compliant-keys")
26533 26535
     flags+=("--alsologtostderr")
26534 26536
     flags+=("--application-metrics-count-limit=")
... ...
@@ -11835,6 +11835,8 @@ _oc_rollout_status()
11835 11835
     flags+=("--recursive")
11836 11836
     flags+=("-R")
11837 11837
     local_nonpersistent_flags+=("--recursive")
11838
+    flags+=("--revision=")
11839
+    local_nonpersistent_flags+=("--revision=")
11838 11840
     flags+=("--as=")
11839 11841
     flags+=("--certificate-authority=")
11840 11842
     flags_with_completion+=("--certificate-authority")
... ...
@@ -16399,6 +16399,8 @@ _openshift_cli_rollout_status()
16399 16399
     flags+=("--recursive")
16400 16400
     flags+=("-R")
16401 16401
     local_nonpersistent_flags+=("--recursive")
16402
+    flags+=("--revision=")
16403
+    local_nonpersistent_flags+=("--revision=")
16402 16404
     flags+=("--as=")
16403 16405
     flags+=("--certificate-authority=")
16404 16406
     flags_with_completion+=("--certificate-authority")
... ...
@@ -26690,6 +26692,8 @@ _openshift_kube_rollout_status()
26690 26690
     flags+=("--recursive")
26691 26691
     flags+=("-R")
26692 26692
     local_nonpersistent_flags+=("--recursive")
26693
+    flags+=("--revision=")
26694
+    local_nonpersistent_flags+=("--revision=")
26693 26695
     flags+=("--allow-verification-with-non-compliant-keys")
26694 26696
     flags+=("--alsologtostderr")
26695 26697
     flags+=("--application-metrics-count-limit=")
... ...
@@ -25,6 +25,10 @@ Watch the status of the latest rollout, until it's done.
25 25
 \fB\-R\fP, \fB\-\-recursive\fP=false
26 26
     Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.
27 27
 
28
+.PP
29
+\fB\-\-revision\fP=0
30
+    Pin to a specific revision for showing its status. Defaults to 0 (last revision).
31
+
28 32
 
29 33
 .SH OPTIONS INHERITED FROM PARENT COMMANDS
30 34
 .PP
... ...
@@ -25,6 +25,10 @@ Watch the status of the latest rollout, until it's done.
25 25
 \fB\-R\fP, \fB\-\-recursive\fP=false
26 26
     Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.
27 27
 
28
+.PP
29
+\fB\-\-revision\fP=0
30
+    Pin to a specific revision for showing its status. Defaults to 0 (last revision).
31
+
28 32
 
29 33
 .SH OPTIONS INHERITED FROM PARENT COMMANDS
30 34
 .PP
... ...
@@ -25,6 +25,10 @@ Watch the status of current rollout, until it's done.
25 25
 \fB\-R\fP, \fB\-\-recursive\fP=false
26 26
     Process the directory used in \-f, \-\-filename recursively. Useful when you want to manage related manifests organized within the same directory.
27 27
 
28
+.PP
29
+\fB\-\-revision\fP=0
30
+    Pin to a specific revision for showing its status. Defaults to 0 (last revision).
31
+
28 32
 
29 33
 .SH OPTIONS INHERITED FROM PARENT COMMANDS
30 34
 .PP
... ...
@@ -24,13 +24,14 @@ type DeploymentConfigStatusViewer struct {
24 24
 var _ kubectl.StatusViewer = &DeploymentConfigStatusViewer{}
25 25
 
26 26
 // Status returns a message describing deployment status, and a bool value indicating if the status is considered done
27
-func (s *DeploymentConfigStatusViewer) Status(namespace, name string) (string, bool, error) {
27
+func (s *DeploymentConfigStatusViewer) Status(namespace, name string, desiredRevision int64) (string, bool, error) {
28 28
 	config, err := s.dn.DeploymentConfigs(namespace).Get(name)
29 29
 	if err != nil {
30 30
 		return "", false, err
31 31
 	}
32
+	latestRevision := config.Status.LatestVersion
32 33
 
33
-	if config.Status.LatestVersion == 0 {
34
+	if latestRevision == 0 {
34 35
 		switch {
35 36
 		case deployutil.HasImageChangeTrigger(config):
36 37
 			return fmt.Sprintf("Deployment config %q waiting on image update\n", name), false, nil
... ...
@@ -40,6 +41,10 @@ func (s *DeploymentConfigStatusViewer) Status(namespace, name string) (string, b
40 40
 		}
41 41
 	}
42 42
 
43
+	if desiredRevision > 0 && latestRevision != desiredRevision {
44
+		return "", false, fmt.Errorf("desired revision (%d) is different from the running revision (%d)", desiredRevision, latestRevision)
45
+	}
46
+
43 47
 	cond := deployutil.GetDeploymentCondition(config.Status, deployapi.DeploymentProgressing)
44 48
 
45 49
 	if config.Generation <= config.Status.ObservedGeneration {