Browse code

Support readiness checking on recreate strategy

The recreate strategy did not previously use readiness checks. This
commit adds support for them in order to make the new mid check pass
(failing-dc-mid.yaml relies on recreate readiness failing in order to
fail the deployment).

Clayton Coleman authored on 2016/02/02 13:12:13
Showing 25 changed files
... ...
@@ -18263,6 +18263,11 @@
18263 18263
    "v1.RecreateDeploymentStrategyParams": {
18264 18264
     "id": "v1.RecreateDeploymentStrategyParams",
18265 18265
     "properties": {
18266
+     "timeoutSeconds": {
18267
+      "type": "integer",
18268
+      "format": "int64",
18269
+      "description": "the time to wait for updates before giving up"
18270
+     },
18266 18271
      "pre": {
18267 18272
       "$ref": "v1.LifecycleHook",
18268 18273
       "description": "a hook executed before the strategy starts the deployment"
... ...
@@ -13,6 +13,7 @@ import (
13 13
 	kvalidation "k8s.io/kubernetes/pkg/api/validation"
14 14
 	"k8s.io/kubernetes/pkg/capabilities"
15 15
 	"k8s.io/kubernetes/pkg/runtime"
16
+	"k8s.io/kubernetes/pkg/util/yaml"
16 17
 
17 18
 	"github.com/openshift/origin/pkg/api/latest"
18 19
 	"github.com/openshift/origin/pkg/api/validation"
... ...
@@ -51,6 +52,12 @@ func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error
51 51
 		if err != nil {
52 52
 			return err
53 53
 		}
54
+		if ext == ".yaml" {
55
+			data, err = yaml.ToJSON(data)
56
+			if err != nil {
57
+				return err
58
+			}
59
+		}
54 60
 		fn(name, path, data)
55 61
 		return nil
56 62
 	})
... ...
@@ -1729,6 +1729,12 @@ func deepCopy_api_LifecycleHook(in deployapi.LifecycleHook, out *deployapi.Lifec
1729 1729
 }
1730 1730
 
1731 1731
 func deepCopy_api_RecreateDeploymentStrategyParams(in deployapi.RecreateDeploymentStrategyParams, out *deployapi.RecreateDeploymentStrategyParams, c *conversion.Cloner) error {
1732
+	if in.TimeoutSeconds != nil {
1733
+		out.TimeoutSeconds = new(int64)
1734
+		*out.TimeoutSeconds = *in.TimeoutSeconds
1735
+	} else {
1736
+		out.TimeoutSeconds = nil
1737
+	}
1732 1738
 	if in.Pre != nil {
1733 1739
 		out.Pre = new(deployapi.LifecycleHook)
1734 1740
 		if err := deepCopy_api_LifecycleHook(*in.Pre, out.Pre, c); err != nil {
... ...
@@ -242,9 +242,18 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
242 242
 		},
243 243
 		func(j *deploy.DeploymentStrategy, c fuzz.Continue) {
244 244
 			c.FuzzNoCustom(j)
245
+			j.RecreateParams, j.RollingParams, j.CustomParams = nil, nil, nil
245 246
 			strategyTypes := []deploy.DeploymentStrategyType{deploy.DeploymentStrategyTypeRecreate, deploy.DeploymentStrategyTypeRolling, deploy.DeploymentStrategyTypeCustom}
246 247
 			j.Type = strategyTypes[c.Rand.Intn(len(strategyTypes))]
247 248
 			switch j.Type {
249
+			case deploy.DeploymentStrategyTypeRecreate:
250
+				params := &deploy.RecreateDeploymentStrategyParams{}
251
+				c.Fuzz(params)
252
+				if params.TimeoutSeconds == nil {
253
+					s := int64(120)
254
+					params.TimeoutSeconds = &s
255
+				}
256
+				j.RecreateParams = params
248 257
 			case deploy.DeploymentStrategyTypeRolling:
249 258
 				params := &deploy.RollingDeploymentStrategyParams{}
250 259
 				randInt64 := func() *int64 {
... ...
@@ -284,8 +293,6 @@ func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, se
284 284
 					params.MaxUnavailable = intstr.FromString(fmt.Sprintf("%d%%", c.RandUint64()))
285 285
 				}
286 286
 				j.RollingParams = params
287
-			default:
288
-				j.RollingParams = nil
289 287
 			}
290 288
 		},
291 289
 		func(j *deploy.DeploymentCauseImageTrigger, c fuzz.Continue) {
... ...
@@ -3132,6 +3132,12 @@ func autoconvert_api_RecreateDeploymentStrategyParams_To_v1_RecreateDeploymentSt
3132 3132
 	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
3133 3133
 		defaulting.(func(*deployapi.RecreateDeploymentStrategyParams))(in)
3134 3134
 	}
3135
+	if in.TimeoutSeconds != nil {
3136
+		out.TimeoutSeconds = new(int64)
3137
+		*out.TimeoutSeconds = *in.TimeoutSeconds
3138
+	} else {
3139
+		out.TimeoutSeconds = nil
3140
+	}
3135 3141
 	if in.Pre != nil {
3136 3142
 		out.Pre = new(deployapiv1.LifecycleHook)
3137 3143
 		if err := convert_api_LifecycleHook_To_v1_LifecycleHook(in.Pre, out.Pre, s); err != nil {
... ...
@@ -3668,6 +3674,12 @@ func autoconvert_v1_RecreateDeploymentStrategyParams_To_api_RecreateDeploymentSt
3668 3668
 	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
3669 3669
 		defaulting.(func(*deployapiv1.RecreateDeploymentStrategyParams))(in)
3670 3670
 	}
3671
+	if in.TimeoutSeconds != nil {
3672
+		out.TimeoutSeconds = new(int64)
3673
+		*out.TimeoutSeconds = *in.TimeoutSeconds
3674
+	} else {
3675
+		out.TimeoutSeconds = nil
3676
+	}
3671 3677
 	if in.Pre != nil {
3672 3678
 		out.Pre = new(deployapi.LifecycleHook)
3673 3679
 		if err := convert_v1_LifecycleHook_To_api_LifecycleHook(in.Pre, out.Pre, s); err != nil {
... ...
@@ -1756,6 +1756,12 @@ func deepCopy_v1_LifecycleHook(in deployapiv1.LifecycleHook, out *deployapiv1.Li
1756 1756
 }
1757 1757
 
1758 1758
 func deepCopy_v1_RecreateDeploymentStrategyParams(in deployapiv1.RecreateDeploymentStrategyParams, out *deployapiv1.RecreateDeploymentStrategyParams, c *conversion.Cloner) error {
1759
+	if in.TimeoutSeconds != nil {
1760
+		out.TimeoutSeconds = new(int64)
1761
+		*out.TimeoutSeconds = *in.TimeoutSeconds
1762
+	} else {
1763
+		out.TimeoutSeconds = nil
1764
+	}
1759 1765
 	if in.Pre != nil {
1760 1766
 		out.Pre = new(deployapiv1.LifecycleHook)
1761 1767
 		if err := deepCopy_v1_LifecycleHook(*in.Pre, out.Pre, c); err != nil {
... ...
@@ -3141,6 +3141,12 @@ func autoconvert_api_RecreateDeploymentStrategyParams_To_v1beta3_RecreateDeploym
3141 3141
 	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
3142 3142
 		defaulting.(func(*deployapi.RecreateDeploymentStrategyParams))(in)
3143 3143
 	}
3144
+	if in.TimeoutSeconds != nil {
3145
+		out.TimeoutSeconds = new(int64)
3146
+		*out.TimeoutSeconds = *in.TimeoutSeconds
3147
+	} else {
3148
+		out.TimeoutSeconds = nil
3149
+	}
3144 3150
 	if in.Pre != nil {
3145 3151
 		out.Pre = new(deployapiv1beta3.LifecycleHook)
3146 3152
 		if err := convert_api_LifecycleHook_To_v1beta3_LifecycleHook(in.Pre, out.Pre, s); err != nil {
... ...
@@ -3677,6 +3683,12 @@ func autoconvert_v1beta3_RecreateDeploymentStrategyParams_To_api_RecreateDeploym
3677 3677
 	if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
3678 3678
 		defaulting.(func(*deployapiv1beta3.RecreateDeploymentStrategyParams))(in)
3679 3679
 	}
3680
+	if in.TimeoutSeconds != nil {
3681
+		out.TimeoutSeconds = new(int64)
3682
+		*out.TimeoutSeconds = *in.TimeoutSeconds
3683
+	} else {
3684
+		out.TimeoutSeconds = nil
3685
+	}
3680 3686
 	if in.Pre != nil {
3681 3687
 		out.Pre = new(deployapi.LifecycleHook)
3682 3688
 		if err := convert_v1beta3_LifecycleHook_To_api_LifecycleHook(in.Pre, out.Pre, s); err != nil {
... ...
@@ -1764,6 +1764,12 @@ func deepCopy_v1beta3_LifecycleHook(in deployapiv1beta3.LifecycleHook, out *depl
1764 1764
 }
1765 1765
 
1766 1766
 func deepCopy_v1beta3_RecreateDeploymentStrategyParams(in deployapiv1beta3.RecreateDeploymentStrategyParams, out *deployapiv1beta3.RecreateDeploymentStrategyParams, c *conversion.Cloner) error {
1767
+	if in.TimeoutSeconds != nil {
1768
+		out.TimeoutSeconds = new(int64)
1769
+		*out.TimeoutSeconds = *in.TimeoutSeconds
1770
+	} else {
1771
+		out.TimeoutSeconds = nil
1772
+	}
1767 1773
 	if in.Pre != nil {
1768 1774
 		out.Pre = new(deployapiv1beta3.LifecycleHook)
1769 1775
 		if err := deepCopy_v1beta3_LifecycleHook(*in.Pre, out.Pre, c); err != nil {
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 func TestNewClient(t *testing.T) {
13 13
 	o := testclient.NewObjects(kapi.Scheme, kapi.Scheme)
14
-	if err := testclient.AddObjectsFromPath("../../../test/integration/fixtures/test-deployment-config.json", o, kapi.Scheme); err != nil {
14
+	if err := testclient.AddObjectsFromPath("../../../test/integration/fixtures/test-deployment-config.yaml", o, kapi.Scheme); err != nil {
15 15
 		t.Fatal(err)
16 16
 	}
17 17
 	oc, _ := NewFixtureClients(o)
... ...
@@ -35,6 +35,9 @@ func OkStrategy() deployapi.DeploymentStrategy {
35 35
 				kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
36 36
 			},
37 37
 		},
38
+		RecreateParams: &deployapi.RecreateDeploymentStrategyParams{
39
+			TimeoutSeconds: mkintp(20),
40
+		},
38 41
 	}
39 42
 }
40 43
 
... ...
@@ -64,11 +67,12 @@ func OkCustomParams() *deployapi.CustomDeploymentStrategyParams {
64 64
 	}
65 65
 }
66 66
 
67
+func mkintp(i int) *int64 {
68
+	v := int64(i)
69
+	return &v
70
+}
71
+
67 72
 func OkRollingStrategy() deployapi.DeploymentStrategy {
68
-	mkintp := func(i int) *int64 {
69
-		v := int64(i)
70
-		return &v
71
-	}
72 73
 	return deployapi.DeploymentStrategy{
73 74
 		Type: deployapi.DeploymentStrategyTypeRolling,
74 75
 		RollingParams: &deployapi.RollingDeploymentStrategyParams{
... ...
@@ -67,6 +67,9 @@ type CustomDeploymentStrategyParams struct {
67 67
 // RecreateDeploymentStrategyParams are the input to the Recreate deployment
68 68
 // strategy.
69 69
 type RecreateDeploymentStrategyParams struct {
70
+	// TimeoutSeconds is the time to wait for updates before giving up. If the
71
+	// value is nil, a default will be used.
72
+	TimeoutSeconds *int64
70 73
 	// Pre is a lifecycle hook which is executed before the strategy manipulates
71 74
 	// the deployment. All LifecycleHookFailurePolicy values are supported.
72 75
 	Pre *LifecycleHook
... ...
@@ -35,6 +35,14 @@ func init() {
35 35
 					TimeoutSeconds:      mkintp(deployapi.DefaultRollingTimeoutSeconds),
36 36
 				}
37 37
 			}
38
+			if obj.Type == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
39
+				obj.RecreateParams = &RecreateDeploymentStrategyParams{}
40
+			}
41
+		},
42
+		func(obj *RecreateDeploymentStrategyParams) {
43
+			if obj.TimeoutSeconds == nil {
44
+				obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds)
45
+			}
38 46
 		},
39 47
 		func(obj *RollingDeploymentStrategyParams) {
40 48
 			if obj.IntervalSeconds == nil {
... ...
@@ -48,6 +48,9 @@ func TestDefaults(t *testing.T) {
48 48
 				Spec: deployv1.DeploymentConfigSpec{
49 49
 					Strategy: deployv1.DeploymentStrategy{
50 50
 						Type: deployv1.DeploymentStrategyTypeRecreate,
51
+						RecreateParams: &deployv1.RecreateDeploymentStrategyParams{
52
+							TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds),
53
+						},
51 54
 						RollingParams: &deployv1.RollingDeploymentStrategyParams{
52 55
 							UpdatePeriodSeconds: newInt64(5),
53 56
 							IntervalSeconds:     newInt64(6),
... ...
@@ -67,6 +70,9 @@ func TestDefaults(t *testing.T) {
67 67
 				Spec: deployv1.DeploymentConfigSpec{
68 68
 					Strategy: deployv1.DeploymentStrategy{
69 69
 						Type: deployv1.DeploymentStrategyTypeRecreate,
70
+						RecreateParams: &deployv1.RecreateDeploymentStrategyParams{
71
+							TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds),
72
+						},
70 73
 						RollingParams: &deployv1.RollingDeploymentStrategyParams{
71 74
 							UpdatePeriodSeconds: newInt64(5),
72 75
 							IntervalSeconds:     newInt64(6),
... ...
@@ -67,6 +67,9 @@ type CustomDeploymentStrategyParams struct {
67 67
 // RecreateDeploymentStrategyParams are the input to the Recreate deployment
68 68
 // strategy.
69 69
 type RecreateDeploymentStrategyParams struct {
70
+	// TimeoutSeconds is the time to wait for updates before giving up. If the
71
+	// value is nil, a default will be used.
72
+	TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty" description:"the time to wait for updates before giving up"`
70 73
 	// Pre is a lifecycle hook which is executed before the strategy manipulates
71 74
 	// the deployment. All LifecycleHookFailurePolicy values are supported.
72 75
 	Pre *LifecycleHook `json:"pre,omitempty" description:"a hook executed before the strategy starts the deployment"`
... ...
@@ -35,6 +35,14 @@ func init() {
35 35
 					TimeoutSeconds:      mkintp(deployapi.DefaultRollingTimeoutSeconds),
36 36
 				}
37 37
 			}
38
+			if obj.Type == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil {
39
+				obj.RecreateParams = &RecreateDeploymentStrategyParams{}
40
+			}
41
+		},
42
+		func(obj *RecreateDeploymentStrategyParams) {
43
+			if obj.TimeoutSeconds == nil {
44
+				obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds)
45
+			}
38 46
 		},
39 47
 		func(obj *RollingDeploymentStrategyParams) {
40 48
 			if obj.IntervalSeconds == nil {
... ...
@@ -67,6 +67,9 @@ func TestDefaults(t *testing.T) {
67 67
 				Spec: deployv1.DeploymentConfigSpec{
68 68
 					Strategy: deployv1.DeploymentStrategy{
69 69
 						Type: deployv1.DeploymentStrategyTypeRecreate,
70
+						RecreateParams: &deployv1.RecreateDeploymentStrategyParams{
71
+							TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds),
72
+						},
70 73
 						RollingParams: &deployv1.RollingDeploymentStrategyParams{
71 74
 							UpdatePeriodSeconds: newInt64(5),
72 75
 							IntervalSeconds:     newInt64(6),
... ...
@@ -67,6 +67,9 @@ type CustomDeploymentStrategyParams struct {
67 67
 // RecreateDeploymentStrategyParams are the input to the Recreate deployment
68 68
 // strategy.
69 69
 type RecreateDeploymentStrategyParams struct {
70
+	// TimeoutSeconds is the time to wait for updates before giving up. If the
71
+	// value is nil, a default will be used.
72
+	TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty" description:"the time to wait for updates before giving up"`
70 73
 	// Pre is a lifecycle hook which is executed before the strategy manipulates
71 74
 	// the deployment. All LifecycleHookFailurePolicy values are supported.
72 75
 	Pre *LifecycleHook `json:"pre,omitempty" description:"a hook executed before the strategy starts the deployment"`
... ...
@@ -28,6 +28,9 @@ import (
28 28
 type RecreateDeploymentStrategy struct {
29 29
 	// getReplicationController knows how to get a replication controller.
30 30
 	getReplicationController func(namespace, name string) (*kapi.ReplicationController, error)
31
+	// getUpdateAcceptor returns an UpdateAcceptor to verify the first replica
32
+	// of the deployment.
33
+	getUpdateAcceptor func(timeout time.Duration) strat.UpdateAcceptor
31 34
 	// scaler is used to scale replication controllers.
32 35
 	scaler kubectl.Scaler
33 36
 	// codec is used to decode DeploymentConfigs contained in deployments.
... ...
@@ -41,6 +44,10 @@ type RecreateDeploymentStrategy struct {
41 41
 	retryPeriod time.Duration
42 42
 }
43 43
 
44
+// AcceptorInterval is how often the UpdateAcceptor should check for
45
+// readiness.
46
+const AcceptorInterval = 1 * time.Second
47
+
44 48
 // NewRecreateDeploymentStrategy makes a RecreateDeploymentStrategy backed by
45 49
 // a real HookExecutor and client.
46 50
 func NewRecreateDeploymentStrategy(client kclient.Interface, codec runtime.Codec) *RecreateDeploymentStrategy {
... ...
@@ -49,6 +56,9 @@ func NewRecreateDeploymentStrategy(client kclient.Interface, codec runtime.Codec
49 49
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
50 50
 			return client.ReplicationControllers(namespace).Get(name)
51 51
 		},
52
+		getUpdateAcceptor: func(timeout time.Duration) strat.UpdateAcceptor {
53
+			return stratsupport.NewAcceptNewlyObservedReadyPods(client, timeout, AcceptorInterval)
54
+		},
52 55
 		scaler:       scaler,
53 56
 		codec:        codec,
54 57
 		hookExecutor: stratsupport.NewHookExecutor(client, os.Stdout, codec),
... ...
@@ -79,6 +89,10 @@ func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationCo
79 79
 	retryParams := kubectl.NewRetryParams(s.retryPeriod, s.retryTimeout)
80 80
 	waitParams := kubectl.NewRetryParams(s.retryPeriod, s.retryTimeout)
81 81
 
82
+	if updateAcceptor == nil {
83
+		updateAcceptor = s.getUpdateAcceptor(time.Duration(*params.TimeoutSeconds) * time.Second)
84
+	}
85
+
82 86
 	// Execute any pre-hook.
83 87
 	if params != nil && params.Pre != nil {
84 88
 		if err := s.hookExecutor.Execute(params.Pre, to, "prehook"); err != nil {
... ...
@@ -105,20 +119,19 @@ func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationCo
105 105
 
106 106
 	// Scale up the to deployment.
107 107
 	if desiredReplicas > 0 {
108
-		// If an UpdateAcceptor is provided, scale up to 1 and validate the replica,
108
+		// Scale up to 1 and validate the replica,
109 109
 		// aborting if the replica isn't acceptable.
110
-		if updateAcceptor != nil {
111
-			glog.Infof("Scaling %s to 1 before performing acceptance check", deployutil.LabelForDeployment(to))
112
-			updatedTo, err := s.scaleAndWait(to, 1, retryParams, waitParams)
113
-			if err != nil {
114
-				return fmt.Errorf("couldn't scale %s to 1: %v", deployutil.LabelForDeployment(to), err)
115
-			}
116
-			glog.Infof("Performing acceptance check of %s", deployutil.LabelForDeployment(to))
117
-			if err := updateAcceptor.Accept(updatedTo); err != nil {
118
-				return fmt.Errorf("update acceptor rejected %s: %v", deployutil.LabelForDeployment(to), err)
119
-			}
120
-			to = updatedTo
110
+		glog.Infof("Scaling %s to 1 before performing acceptance check", deployutil.LabelForDeployment(to))
111
+		updatedTo, err := s.scaleAndWait(to, 1, retryParams, waitParams)
112
+		if err != nil {
113
+			return fmt.Errorf("couldn't scale %s to 1: %v", deployutil.LabelForDeployment(to), err)
121 114
 		}
115
+		glog.Infof("Performing acceptance check of %s", deployutil.LabelForDeployment(to))
116
+		if err := updateAcceptor.Accept(updatedTo); err != nil {
117
+			return fmt.Errorf("update acceptor rejected %s: %v", deployutil.LabelForDeployment(to), err)
118
+		}
119
+		to = updatedTo
120
+
122 121
 		// Complete the scale up.
123 122
 		if to.Spec.Replicas != desiredReplicas {
124 123
 			glog.Infof("Scaling %s to %d", deployutil.LabelForDeployment(to), desiredReplicas)
... ...
@@ -11,6 +11,7 @@ import (
11 11
 	deployapi "github.com/openshift/origin/pkg/deploy/api"
12 12
 	deploytest "github.com/openshift/origin/pkg/deploy/api/test"
13 13
 	scalertest "github.com/openshift/origin/pkg/deploy/scaler/test"
14
+	"github.com/openshift/origin/pkg/deploy/strategy"
14 15
 	deployutil "github.com/openshift/origin/pkg/deploy/util"
15 16
 )
16 17
 
... ...
@@ -25,26 +26,32 @@ func TestRecreate_initialDeployment(t *testing.T) {
25 25
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
26 26
 			return deployment, nil
27 27
 		},
28
-		scaler: scaler,
28
+		getUpdateAcceptor: getUpdateAcceptor,
29
+		scaler:            scaler,
29 30
 	}
30 31
 
31
-	deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec)
32
-	err := strategy.Deploy(nil, deployment, 2)
32
+	config := deploytest.OkDeploymentConfig(1)
33
+	config.Spec.Strategy = recreateParams(30, "", "", "")
34
+	deployment, _ = deployutil.MakeDeployment(config, kapi.Codec)
35
+	err := strategy.Deploy(nil, deployment, 3)
33 36
 	if err != nil {
34 37
 		t.Fatalf("unexpected deploy error: %#v", err)
35 38
 	}
36 39
 
37
-	if e, a := 1, len(scaler.Events); e != a {
40
+	if e, a := 2, len(scaler.Events); e != a {
38 41
 		t.Fatalf("expected %d scale calls, got %d", e, a)
39 42
 	}
40
-	if e, a := uint(2), scaler.Events[0].Size; e != a {
43
+	if e, a := uint(1), scaler.Events[0].Size; e != a {
44
+		t.Errorf("expected scale up to %d, got %d", e, a)
45
+	}
46
+	if e, a := uint(3), scaler.Events[1].Size; e != a {
41 47
 		t.Errorf("expected scale up to %d, got %d", e, a)
42 48
 	}
43 49
 }
44 50
 
45 51
 func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
46 52
 	config := deploytest.OkDeploymentConfig(1)
47
-	config.Spec.Strategy.RecreateParams = recreateParams(deployapi.LifecycleHookFailurePolicyAbort, "", "")
53
+	config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "")
48 54
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
49 55
 	scaler := &scalertest.FakeScaler{}
50 56
 
... ...
@@ -56,6 +63,7 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
56 56
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
57 57
 			return deployment, nil
58 58
 		},
59
+		getUpdateAcceptor: getUpdateAcceptor,
59 60
 		hookExecutor: &hookExecutorImpl{
60 61
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
61 62
 				hookExecuted = true
... ...
@@ -76,7 +84,7 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
76 76
 
77 77
 func TestRecreate_deploymentPreHookFail(t *testing.T) {
78 78
 	config := deploytest.OkDeploymentConfig(1)
79
-	config.Spec.Strategy.RecreateParams = recreateParams(deployapi.LifecycleHookFailurePolicyAbort, "", "")
79
+	config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "")
80 80
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
81 81
 	scaler := &scalertest.FakeScaler{}
82 82
 
... ...
@@ -87,6 +95,7 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) {
87 87
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
88 88
 			return deployment, nil
89 89
 		},
90
+		getUpdateAcceptor: getUpdateAcceptor,
90 91
 		hookExecutor: &hookExecutorImpl{
91 92
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
92 93
 				return fmt.Errorf("hook execution failure")
... ...
@@ -106,7 +115,7 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) {
106 106
 
107 107
 func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
108 108
 	config := deploytest.OkDeploymentConfig(1)
109
-	config.Spec.Strategy.RecreateParams = recreateParams("", deployapi.LifecycleHookFailurePolicyAbort, "")
109
+	config.Spec.Strategy = recreateParams(30, "", deployapi.LifecycleHookFailurePolicyAbort, "")
110 110
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
111 111
 	scaler := &scalertest.FakeScaler{}
112 112
 
... ...
@@ -118,6 +127,7 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
118 118
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
119 119
 			return deployment, nil
120 120
 		},
121
+		getUpdateAcceptor: getUpdateAcceptor,
121 122
 		hookExecutor: &hookExecutorImpl{
122 123
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
123 124
 				hookExecuted = true
... ...
@@ -138,7 +148,7 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
138 138
 
139 139
 func TestRecreate_deploymentMidHookFail(t *testing.T) {
140 140
 	config := deploytest.OkDeploymentConfig(1)
141
-	config.Spec.Strategy.RecreateParams = recreateParams("", deployapi.LifecycleHookFailurePolicyAbort, "")
141
+	config.Spec.Strategy = recreateParams(30, "", deployapi.LifecycleHookFailurePolicyAbort, "")
142 142
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
143 143
 	scaler := &scalertest.FakeScaler{}
144 144
 
... ...
@@ -149,6 +159,7 @@ func TestRecreate_deploymentMidHookFail(t *testing.T) {
149 149
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
150 150
 			return deployment, nil
151 151
 		},
152
+		getUpdateAcceptor: getUpdateAcceptor,
152 153
 		hookExecutor: &hookExecutorImpl{
153 154
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
154 155
 				return fmt.Errorf("hook execution failure")
... ...
@@ -167,7 +178,7 @@ func TestRecreate_deploymentMidHookFail(t *testing.T) {
167 167
 }
168 168
 func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
169 169
 	config := deploytest.OkDeploymentConfig(1)
170
-	config.Spec.Strategy.RecreateParams = recreateParams("", "", deployapi.LifecycleHookFailurePolicyAbort)
170
+	config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort)
171 171
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
172 172
 	scaler := &scalertest.FakeScaler{}
173 173
 
... ...
@@ -179,6 +190,7 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
179 179
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
180 180
 			return deployment, nil
181 181
 		},
182
+		getUpdateAcceptor: getUpdateAcceptor,
182 183
 		hookExecutor: &hookExecutorImpl{
183 184
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
184 185
 				hookExecuted = true
... ...
@@ -199,7 +211,7 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
199 199
 
200 200
 func TestRecreate_deploymentPostHookFail(t *testing.T) {
201 201
 	config := deploytest.OkDeploymentConfig(1)
202
-	config.Spec.Strategy.RecreateParams = recreateParams("", "", deployapi.LifecycleHookFailurePolicyAbort)
202
+	config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort)
203 203
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
204 204
 	scaler := &scalertest.FakeScaler{}
205 205
 
... ...
@@ -211,6 +223,7 @@ func TestRecreate_deploymentPostHookFail(t *testing.T) {
211 211
 		getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
212 212
 			return deployment, nil
213 213
 		},
214
+		getUpdateAcceptor: getUpdateAcceptor,
214 215
 		hookExecutor: &hookExecutorImpl{
215 216
 			executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
216 217
 				hookExecuted = true
... ...
@@ -307,9 +320,8 @@ func TestRecreate_acceptorFail(t *testing.T) {
307 307
 	}
308 308
 }
309 309
 
310
-func recreateParams(preFailurePolicy, midFailurePolicy, postFailurePolicy deployapi.LifecycleHookFailurePolicy) *deployapi.RecreateDeploymentStrategyParams {
310
+func recreateParams(timeout int64, preFailurePolicy, midFailurePolicy, postFailurePolicy deployapi.LifecycleHookFailurePolicy) deployapi.DeploymentStrategy {
311 311
 	var pre, mid, post *deployapi.LifecycleHook
312
-
313 312
 	if len(preFailurePolicy) > 0 {
314 313
 		pre = &deployapi.LifecycleHook{
315 314
 			FailurePolicy: preFailurePolicy,
... ...
@@ -328,10 +340,15 @@ func recreateParams(preFailurePolicy, midFailurePolicy, postFailurePolicy deploy
328 328
 			ExecNewPod:    &deployapi.ExecNewPodHook{},
329 329
 		}
330 330
 	}
331
-	return &deployapi.RecreateDeploymentStrategyParams{
332
-		Pre:  pre,
333
-		Mid:  mid,
334
-		Post: post,
331
+	return deployapi.DeploymentStrategy{
332
+		Type: deployapi.DeploymentStrategyTypeRecreate,
333
+		RecreateParams: &deployapi.RecreateDeploymentStrategyParams{
334
+			TimeoutSeconds: &timeout,
335
+
336
+			Pre:  pre,
337
+			Mid:  mid,
338
+			Post: post,
339
+		},
335 340
 	}
336 341
 }
337 342
 
... ...
@@ -348,6 +365,14 @@ func (t *testControllerClient) updateReplicationController(namespace string, ctr
348 348
 	return t.updateReplicationControllerFunc(namespace, ctrl)
349 349
 }
350 350
 
351
+func getUpdateAcceptor(timeout time.Duration) strategy.UpdateAcceptor {
352
+	return &testAcceptor{
353
+		acceptFn: func(deployment *kapi.ReplicationController) error {
354
+			return nil
355
+		},
356
+	}
357
+}
358
+
351 359
 type testAcceptor struct {
352 360
 	acceptFn func(*kapi.ReplicationController) error
353 361
 }
... ...
@@ -13,7 +13,7 @@ os::log::install_errexit
13 13
 
14 14
 os::cmd::expect_success 'oc get deploymentConfigs'
15 15
 os::cmd::expect_success 'oc get dc'
16
-os::cmd::expect_success 'oc create -f test/integration/fixtures/test-deployment-config.json'
16
+os::cmd::expect_success 'oc create -f test/integration/fixtures/test-deployment-config.yaml'
17 17
 os::cmd::expect_success 'oc describe deploymentConfigs test-deployment-config'
18 18
 os::cmd::expect_success_and_text 'oc get dc -o name' 'deploymentconfig/test-deployment-config'
19 19
 os::cmd::expect_success_and_text 'oc describe dc test-deployment-config' 'deploymentconfig=test-deployment-config'
... ...
@@ -38,7 +38,7 @@ os::cmd::expect_success_and_text 'oc env dc/test-deployment-config OTHER=foo -o
38 38
 os::cmd::expect_success_and_text 'echo OTHER=foo | oc env dc/test-deployment-config -e - --list' 'OTHER=foo'
39 39
 os::cmd::expect_success_and_not_text 'echo #OTHER=foo | oc env dc/test-deployment-config -e - --list' 'OTHER=foo'
40 40
 os::cmd::expect_success 'oc env dc/test-deployment-config TEST=bar OTHER=baz BAR-'
41
-os::cmd::expect_success_and_not_text 'oc env -f test/integration/fixtures/test-deployment-config.json TEST=VERSION -o yaml' 'v1beta3'
41
+os::cmd::expect_success_and_not_text 'oc env -f test/integration/fixtures/test-deployment-config.yaml TEST=VERSION -o yaml' 'v1beta3'
42 42
 os::cmd::expect_success 'oc env dc/test-deployment-config A=a B=b C=c D=d E=e F=f G=g'
43 43
 os::cmd::expect_success_and_text 'oc env dc/test-deployment-config --list' 'A=a'
44 44
 os::cmd::expect_success_and_text 'oc env dc/test-deployment-config --list' 'B=b'
... ...
@@ -11,7 +11,7 @@ os::log::install_errexit
11 11
 
12 12
 # This test validates the 'volume' command
13 13
 
14
-os::cmd::expect_success 'oc create -f test/integration/fixtures/test-deployment-config.json'
14
+os::cmd::expect_success 'oc create -f test/integration/fixtures/test-deployment-config.yaml'
15 15
 
16 16
 os::cmd::expect_success_and_text 'oc volume dc/test-deployment-config --list' 'vol1'
17 17
 os::cmd::expect_success 'oc volume dc/test-deployment-config --add --name=vol0 -m /opt5'
... ...
@@ -189,13 +189,13 @@ oc logs --previous dc/failing-dc | grep 'test pre hook executed'
189 189
 oc delete dc/failing-dc
190 190
 # test the mid hook on a recreate deployment and the health check
191 191
 oc create -f test/fixtures/failing-dc-mid.yaml
192
-tryuntil oc get rc/failing-dc-1
193
-oc logs -f dc/failing-dc
194
-wait_for_command "oc get rc/failing-dc-1 --template={{.metadata.annotations}} | grep openshift.io/deployment.phase:Failed" $((60*TIME_SEC))
195
-oc logs dc/failing-dc | grep 'test mid hook executed'
196
-oc deploy failing-dc --latest
197
-oc logs --version=1 dc/failing-dc | grep 'test mid hook executed'
198
-oc logs --previous dc/failing-dc | grep 'test mid hook executed'
192
+tryuntil oc get rc/failing-dc-mid-1
193
+oc logs -f dc/failing-dc-mid
194
+wait_for_command "oc get rc/failing-dc-mid-1 --template={{.metadata.annotations}} | grep openshift.io/deployment.phase:Failed" $((60*TIME_SEC))
195
+oc logs dc/failing-dc-mid | grep 'test mid hook executed'
196
+oc deploy failing-dc-mid --latest
197
+oc logs --version=1 dc/failing-dc-mid | grep 'test mid hook executed'
198
+oc logs --previous dc/failing-dc-mid | grep 'test mid hook executed'
199 199
 
200 200
 echo "[INFO] Run pod diagnostics"
201 201
 # Requires a node to run the pod; uses origin-deployer pod, expects registry deployed
... ...
@@ -226,7 +226,7 @@ oc logs buildconfig/ruby-sample-build --loglevel=6
226 226
 echo "logs: ok"
227 227
 
228 228
 echo "[INFO] Starting a deployment to test scaling..."
229
-oc create -f test/integration/fixtures/test-deployment-config.json
229
+oc create -f test/integration/fixtures/test-deployment-config.yaml
230 230
 # scaling which might conflict with the deployment should work
231 231
 oc scale dc/test-deployment-config --replicas=2
232 232
 tryuntil '[ "$(oc get rc/test-deployment-config-1 -o yaml | grep Complete)" ]'
... ...
@@ -1,14 +1,15 @@
1 1
 apiVersion: v1
2 2
 kind: DeploymentConfig
3 3
 metadata:
4
-  name: failing-dc
4
+  name: failing-dc-mid
5 5
 spec:
6 6
   replicas: 2
7 7
   selector:
8
-    name: failing-dc
8
+    name: failing-dc-mid
9 9
   strategy:
10 10
     type: Recreate
11 11
     recreateParams:
12
+      timeoutSeconds: 5
12 13
       mid:
13 14
         failurePolicy: Abort
14 15
         execNewPod:
... ...
@@ -19,7 +20,7 @@ spec:
19 19
   template:
20 20
     metadata:
21 21
       labels:
22
-        name: failing-dc
22
+        name: failing-dc-mid
23 23
     spec:
24 24
       containers:
25 25
       - image: "docker.io/centos:centos7"
26 26
deleted file mode 100644
... ...
@@ -1,62 +0,0 @@
1
-{
2
-  "kind": "DeploymentConfig",
3
-  "apiVersion": "v1beta3",
4
-  "metadata": {
5
-    "name": "test-deployment-config",
6
-    "creationTimestamp": null
7
-  },
8
-  "spec": {
9
-    "strategy": {
10
-      "type": "Recreate",
11
-      "resources": {}
12
-    },
13
-    "replicas": 1,
14
-    "selector": {
15
-      "name": "test-deployment"
16
-    },
17
-    "template": {
18
-      "metadata": {
19
-        "creationTimestamp": null,
20
-        "labels": {
21
-          "name": "test-deployment"
22
-        }
23
-      },
24
-      "spec": {
25
-	"volumes": [
26
-	  {
27
-	    "name": "vol1",
28
-	    "emptyDir": {}
29
-	  }
30
-	],
31
-        "containers": [
32
-          {
33
-            "name": "ruby-helloworld",
34
-            "image": "127.0.0.1:5001/openshift/origin-ruby-sample",
35
-            "ports": [
36
-              {
37
-                "containerPort": 8080,
38
-                "protocol": "TCP"
39
-              }
40
-            ],
41
-            "resources": {
42
-              "limits": {
43
-                "cpu": "100m",
44
-                "memory": "3Gi"
45
-              }
46
-            },
47
-            "terminationMessagePath": "/dev/termination-log",
48
-            "imagePullPolicy": "IfNotPresent",
49
-            "capabilities": {},
50
-            "securityContext": {
51
-              "capabilities": {},
52
-              "privileged": false
53
-            }
54
-          }
55
-        ],
56
-        "restartPolicy": "Always",
57
-        "dnsPolicy": "ClusterFirst"
58
-      }
59
-    }
60
-  },
61
-  "status": {}
62
-}
63 1
new file mode 100644
... ...
@@ -0,0 +1,34 @@
0
+apiVersion: v1
1
+kind: DeploymentConfig
2
+metadata:
3
+  name: test-deployment-config
4
+spec:
5
+  replicas: 1
6
+  selector:
7
+    name: test-deployment
8
+  strategy:
9
+    type: Recreate
10
+    recreateParams:
11
+      timeoutSeconds: 10
12
+  template:
13
+    metadata:
14
+      labels:
15
+        name: test-deployment
16
+    spec:
17
+      containers:
18
+      - image: openshift/origin-pod
19
+        imagePullPolicy: IfNotPresent
20
+        name: ruby-helloworld
21
+        ports:
22
+        - containerPort: 8080
23
+          protocol: TCP
24
+        resources:
25
+          limits:
26
+            cpu: 100m
27
+            memory: 3Gi
28
+      volumes:
29
+      - emptyDir: {}
30
+        name: vol1
31
+  triggers:
32
+  - type: ConfigChange
33
+status: {}
0 34
\ No newline at end of file