Browse code

deploy: set condition reason correctly for new RCs

Michail Kargakis authored on 2016/10/27 18:22:39
Showing 3 changed files
... ...
@@ -196,7 +196,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig)
196 196
 		c.recorder.Eventf(config, kapi.EventTypeWarning, "DeploymentCleanupFailed", "Couldn't clean up deployments: %v", err)
197 197
 	}
198 198
 
199
-	cond := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionTrue, deployutil.NewRcAvailableReason, msg)
199
+	cond := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionTrue, deployutil.NewReplicationControllerReason, msg)
200 200
 	return c.updateStatus(config, existingDeployments, *cond)
201 201
 }
202 202
 
... ...
@@ -41,6 +41,7 @@ var _ = g.Describe("deploymentconfigs", func() {
41 41
 		tagImagesFixture                = exutil.FixturePath("testdata", "deployments", "tag-images-deployment.yaml")
42 42
 		readinessFixture                = exutil.FixturePath("testdata", "deployments", "readiness-test.yaml")
43 43
 		envRefDeploymentFixture         = exutil.FixturePath("testdata", "deployments", "deployment-with-ref-env.yaml")
44
+		ignoresDeployersFixture         = exutil.FixturePath("testdata", "deployments", "deployment-ignores-deployer.yaml")
44 45
 	)
45 46
 
46 47
 	g.Describe("when run iteratively [Conformance]", func() {
... ...
@@ -302,6 +303,7 @@ var _ = g.Describe("deploymentconfigs", func() {
302 302
 			o.Expect(out).To(o.ContainSubstring("hello bar"))
303 303
 		})
304 304
 	})
305
+
305 306
 	g.Describe("with multiple image change triggers [Conformance]", func() {
306 307
 		g.AfterEach(func() {
307 308
 			failureTrap(oc, "example", g.CurrentGinkgoTestDescription().Failed)
... ...
@@ -782,4 +784,44 @@ var _ = g.Describe("deploymentconfigs", func() {
782 782
 			o.Expect(waitForLatestCondition(oc, name, deploymentRunTimeout, deploymentRunning)).NotTo(o.HaveOccurred())
783 783
 		})
784 784
 	})
785
+
786
+	g.Describe("ignores deployer and lets the config with a NewReplicationControllerCreated reason [Conformance]", func() {
787
+		g.AfterEach(func() {
788
+			failureTrap(oc, "database", g.CurrentGinkgoTestDescription().Failed)
789
+		})
790
+
791
+		g.It("should let the deployment config with a NewReplicationControllerCreated reason", func() {
792
+			_, name, err := createFixture(oc, ignoresDeployersFixture)
793
+			o.Expect(err).NotTo(o.HaveOccurred())
794
+
795
+			g.By("verifying that the deployment config is bumped to the first version")
796
+			err = wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) {
797
+				dc, _, _, err := deploymentInfo(oc, name)
798
+				if err != nil {
799
+					return false, nil
800
+				}
801
+				return dc.Status.LatestVersion == 1, nil
802
+			})
803
+			if err == wait.ErrWaitTimeout {
804
+				err = fmt.Errorf("deployment config %q never incremented to the first version", name)
805
+			}
806
+			o.Expect(err).NotTo(o.HaveOccurred())
807
+
808
+			g.By("verifying that the deployment config has the desired condition and reason")
809
+			var conditions []deployapi.DeploymentCondition
810
+			err = wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) {
811
+				dc, _, _, err := deploymentInfo(oc, name)
812
+				if err != nil {
813
+					return false, nil
814
+				}
815
+				conditions = dc.Status.Conditions
816
+				cond := deployutil.GetDeploymentCondition(dc.Status, deployapi.DeploymentProgressing)
817
+				return cond != nil && cond.Reason == deployutil.NewReplicationControllerReason, nil
818
+			})
819
+			if err == wait.ErrWaitTimeout {
820
+				err = fmt.Errorf("deployment config %q never updated its conditions: %#v", name, conditions)
821
+			}
822
+			o.Expect(err).NotTo(o.HaveOccurred())
823
+		})
824
+	})
785 825
 })
786 826
new file mode 100644
... ...
@@ -0,0 +1,23 @@
0
+apiVersion: v1
1
+kind: DeploymentConfig
2
+metadata:
3
+  annotations:
4
+    deploy.openshift.io/deployer-pod.ignore: "true"
5
+  name: database
6
+spec:
7
+  replicas: 1
8
+  selector:
9
+    name: database
10
+  template:
11
+    metadata:
12
+      labels:
13
+        name: database
14
+    spec:
15
+      terminationGracePeriodSeconds: 0
16
+      containers:
17
+      - image: "docker.io/centos:centos7"
18
+        imagePullPolicy: IfNotPresent
19
+        name: myapp
20
+        command:
21
+        - /bin/sleep
22
+        - "10000"