Browse code

Merge pull request #5149 from pedro-r-marques/deploy-labels

Merged by openshift-bot

OpenShift Bot authored on 2015/11/17 12:40:04
Showing 16 changed files
... ...
@@ -15836,6 +15836,14 @@
15836 15836
      "resources": {
15837 15837
       "$ref": "v1.ResourceRequirements",
15838 15838
       "description": "resource requirements to execute the deployment"
15839
+     },
15840
+     "labels": {
15841
+      "type": "any",
15842
+      "description": "labels for deployer and hook pods"
15843
+     },
15844
+     "annotations": {
15845
+      "type": "any",
15846
+      "description": "annotations for deployer and hook pods"
15839 15847
      }
15840 15848
     }
15841 15849
    },
... ...
@@ -1510,6 +1510,22 @@ func deepCopy_api_DeploymentStrategy(in deployapi.DeploymentStrategy, out *deplo
1510 1510
 	} else {
1511 1511
 		out.Resources = newVal.(pkgapi.ResourceRequirements)
1512 1512
 	}
1513
+	if in.Labels != nil {
1514
+		out.Labels = make(map[string]string)
1515
+		for key, val := range in.Labels {
1516
+			out.Labels[key] = val
1517
+		}
1518
+	} else {
1519
+		out.Labels = nil
1520
+	}
1521
+	if in.Annotations != nil {
1522
+		out.Annotations = make(map[string]string)
1523
+		for key, val := range in.Annotations {
1524
+			out.Annotations[key] = val
1525
+		}
1526
+	} else {
1527
+		out.Annotations = nil
1528
+	}
1513 1529
 	return nil
1514 1530
 }
1515 1531
 
... ...
@@ -1569,6 +1569,22 @@ func deepCopy_v1_DeploymentStrategy(in deployapiv1.DeploymentStrategy, out *depl
1569 1569
 	} else {
1570 1570
 		out.Resources = newVal.(pkgapiv1.ResourceRequirements)
1571 1571
 	}
1572
+	if in.Labels != nil {
1573
+		out.Labels = make(map[string]string)
1574
+		for key, val := range in.Labels {
1575
+			out.Labels[key] = val
1576
+		}
1577
+	} else {
1578
+		out.Labels = nil
1579
+	}
1580
+	if in.Annotations != nil {
1581
+		out.Annotations = make(map[string]string)
1582
+		for key, val := range in.Annotations {
1583
+			out.Annotations[key] = val
1584
+		}
1585
+	} else {
1586
+		out.Annotations = nil
1587
+	}
1572 1588
 	return nil
1573 1589
 }
1574 1590
 
... ...
@@ -1577,6 +1577,22 @@ func deepCopy_v1beta3_DeploymentStrategy(in deployapiv1beta3.DeploymentStrategy,
1577 1577
 	} else {
1578 1578
 		out.Resources = newVal.(pkgapiv1beta3.ResourceRequirements)
1579 1579
 	}
1580
+	if in.Labels != nil {
1581
+		out.Labels = make(map[string]string)
1582
+		for key, val := range in.Labels {
1583
+			out.Labels[key] = val
1584
+		}
1585
+	} else {
1586
+		out.Labels = nil
1587
+	}
1588
+	if in.Annotations != nil {
1589
+		out.Annotations = make(map[string]string)
1590
+		for key, val := range in.Annotations {
1591
+			out.Annotations[key] = val
1592
+		}
1593
+	} else {
1594
+		out.Annotations = nil
1595
+	}
1580 1596
 	return nil
1581 1597
 }
1582 1598
 
... ...
@@ -36,6 +36,10 @@ type DeploymentStrategy struct {
36 36
 	RollingParams *RollingDeploymentStrategyParams
37 37
 	// Resources contains resource requirements to execute the deployment
38 38
 	Resources kapi.ResourceRequirements
39
+	// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
40
+	Labels map[string]string
41
+	// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
42
+	Annotations map[string]string
39 43
 }
40 44
 
41 45
 // DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
... ...
@@ -82,6 +82,12 @@ func convert_v1_DeploymentStrategy_To_api_DeploymentStrategy(in *DeploymentStrat
82 82
 	if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil {
83 83
 		return err
84 84
 	}
85
+	if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
86
+		return err
87
+	}
88
+	if err := s.Convert(&in.Annotations, &out.Annotations, 0); err != nil {
89
+		return err
90
+	}
85 91
 	return nil
86 92
 }
87 93
 
... ...
@@ -101,6 +107,12 @@ func convert_api_DeploymentStrategy_To_v1_DeploymentStrategy(in *newer.Deploymen
101 101
 	if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil {
102 102
 		return err
103 103
 	}
104
+	if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
105
+		return err
106
+	}
107
+	if err := s.Convert(&in.Annotations, &out.Annotations, 0); err != nil {
108
+		return err
109
+	}
104 110
 	return nil
105 111
 }
106 112
 
... ...
@@ -36,6 +36,10 @@ type DeploymentStrategy struct {
36 36
 	RollingParams *RollingDeploymentStrategyParams `json:"rollingParams,omitempty" description:"input to the Rolling deployment strategy"`
37 37
 	// Resources contains resource requirements to execute the deployment
38 38
 	Resources kapi.ResourceRequirements `json:"resources,omitempty" description:"resource requirements to execute the deployment"`
39
+	// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
40
+	Labels map[string]string `json:"labels,omitempty" description:"labels for deployer and hook pods"`
41
+	// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
42
+	Annotations map[string]string `json:"annotations,omitempty" description:"annotations for deployer and hook pods"`
39 43
 }
40 44
 
41 45
 // DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
... ...
@@ -81,6 +81,12 @@ func convert_v1beta3_DeploymentStrategy_To_api_DeploymentStrategy(in *Deployment
81 81
 	if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil {
82 82
 		return err
83 83
 	}
84
+	if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
85
+		return err
86
+	}
87
+	if err := s.Convert(&in.Annotations, &out.Annotations, 0); err != nil {
88
+		return err
89
+	}
84 90
 	return nil
85 91
 }
86 92
 
... ...
@@ -100,6 +106,12 @@ func convert_api_DeploymentStrategy_To_v1beta3_DeploymentStrategy(in *newer.Depl
100 100
 	if err := s.Convert(&in.Resources, &out.Resources, 0); err != nil {
101 101
 		return err
102 102
 	}
103
+	if err := s.Convert(&in.Labels, &out.Labels, 0); err != nil {
104
+		return err
105
+	}
106
+	if err := s.Convert(&in.Annotations, &out.Annotations, 0); err != nil {
107
+		return err
108
+	}
103 109
 	return nil
104 110
 }
105 111
 
... ...
@@ -36,6 +36,10 @@ type DeploymentStrategy struct {
36 36
 	RollingParams *RollingDeploymentStrategyParams `json:"rollingParams,omitempty" description:"input to the Rolling deployment strategy"`
37 37
 	// Compute resource requirements to execute the deployment
38 38
 	Resources kapi.ResourceRequirements `json:"resources,omitempty" description:"resource requirements to execute the deployment"`
39
+	// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
40
+	Labels map[string]string `json:"labels,omitempty" description:"labels for deployer and hook pods"`
41
+	// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
42
+	Annotations map[string]string `json:"annotations,omitempty" description:"annotations for deployer and hook pods"`
39 43
 }
40 44
 
41 45
 // DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
... ...
@@ -91,6 +91,13 @@ func validateDeploymentStrategy(strategy *deployapi.DeploymentStrategy) fielderr
91 91
 		}
92 92
 	}
93 93
 
94
+	if strategy.Labels != nil {
95
+		errs = append(errs, validation.ValidateLabels(strategy.Labels, "labels")...)
96
+	}
97
+	if strategy.Annotations != nil {
98
+		errs = append(errs, validation.ValidateAnnotations(strategy.Annotations, "annotations")...)
99
+	}
100
+
94 101
 	// TODO: validate resource requirements (prereq: https://github.com/kubernetes/kubernetes/pull/7059)
95 102
 
96 103
 	return errs
... ...
@@ -12,6 +12,7 @@ import (
12 12
 
13 13
 	deployapi "github.com/openshift/origin/pkg/deploy/api"
14 14
 	deployutil "github.com/openshift/origin/pkg/deploy/util"
15
+	"github.com/openshift/origin/pkg/util"
15 16
 )
16 17
 
17 18
 // DeploymentController starts a deployment by creating a deployer pod which
... ...
@@ -249,6 +250,10 @@ func (c *DeploymentController) makeDeployerPod(deployment *kapi.ReplicationContr
249 249
 		},
250 250
 	}
251 251
 
252
+	// MergeInfo will not overwrite values unless the flag OverwriteExistingDstKey is set.
253
+	util.MergeInto(pod.Labels, deploymentConfig.Template.Strategy.Labels, 0)
254
+	util.MergeInto(pod.Annotations, deploymentConfig.Template.Strategy.Annotations, 0)
255
+
252 256
 	pod.Spec.Containers[0].ImagePullPolicy = kapi.PullIfNotPresent
253 257
 
254 258
 	return pod, nil
... ...
@@ -651,6 +651,74 @@ func TestHandle_deployerPodDisappeared(t *testing.T) {
651 651
 	}
652 652
 }
653 653
 
654
+func expectMapContains(t *testing.T, exists, expected map[string]string, what string) {
655
+	if expected == nil {
656
+		return
657
+	}
658
+	for k, v := range expected {
659
+		value, ok := exists[k]
660
+		if ok && value != v {
661
+			t.Errorf("expected %s[%s]=%s, got %s", what, k, v, value)
662
+		} else if !ok {
663
+			t.Errorf("expected %s %s: not present", what, k)
664
+		}
665
+	}
666
+}
667
+
668
+func TestDeployerCustomLabelsAndAnnotations(t *testing.T) {
669
+	controller := &DeploymentController{
670
+		decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
671
+			return deployutil.DecodeDeploymentConfig(deployment, api.Codec)
672
+		},
673
+		podClient: &podClientImpl{
674
+			createPodFunc: func(namespace string, pod *kapi.Pod) (*kapi.Pod, error) {
675
+				return pod, nil
676
+			},
677
+		},
678
+		makeContainer: func(strategy *deployapi.DeploymentStrategy) (*kapi.Container, error) {
679
+			return okContainer(), nil
680
+		},
681
+	}
682
+
683
+	testCases := []struct {
684
+		name         string
685
+		strategy     deployapi.DeploymentStrategy
686
+		labels       map[string]string
687
+		annotations  map[string]string
688
+		verifyLabels bool
689
+	}{
690
+		{name: "labels and annotations", strategy: deploytest.OkStrategy(), labels: map[string]string{"label1": "value1"}, annotations: map[string]string{"annotation1": "value1"}, verifyLabels: true},
691
+		{name: "custom strategy, no annotations", strategy: deploytest.OkCustomStrategy(), labels: map[string]string{"label2": "value2", "label3": "value3"}, verifyLabels: true},
692
+		{name: "custom strategy, no labels", strategy: deploytest.OkCustomStrategy(), annotations: map[string]string{"annotation3": "value3"}, verifyLabels: true},
693
+		{name: "no overrride", strategy: deploytest.OkStrategy(), labels: map[string]string{deployapi.DeployerPodForDeploymentLabel: "ignored"}, verifyLabels: false},
694
+	}
695
+
696
+	for _, test := range testCases {
697
+		t.Logf("evaluating test case %s", test.name)
698
+		config := deploytest.OkDeploymentConfig(1)
699
+		config.Template.Strategy = test.strategy
700
+		config.Template.Strategy.Labels = test.labels
701
+		config.Template.Strategy.Annotations = test.annotations
702
+
703
+		deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
704
+		podTemplate, err := controller.makeDeployerPod(deployment)
705
+		if err != nil {
706
+			t.Fatal(err)
707
+		}
708
+
709
+		nameLabel, ok := podTemplate.Labels[deployapi.DeployerPodForDeploymentLabel]
710
+		if ok && nameLabel != deployment.Name {
711
+			t.Errorf("label %s expected %s, got %s", deployapi.DeployerPodForDeploymentLabel, deployment.Name, nameLabel)
712
+		} else if !ok {
713
+			t.Errorf("label %s not present", deployapi.DeployerPodForDeploymentLabel)
714
+		}
715
+		if test.verifyLabels {
716
+			expectMapContains(t, podTemplate.Labels, test.labels, "labels")
717
+		}
718
+		expectMapContains(t, podTemplate.Annotations, test.annotations, "annotations")
719
+	}
720
+}
721
+
654 722
 func okContainer() *kapi.Container {
655 723
 	return &kapi.Container{
656 724
 		Image:   "test/image",
... ...
@@ -51,7 +51,7 @@ func NewRecreateDeploymentStrategy(client kclient.Interface, codec runtime.Codec
51 51
 		},
52 52
 		scaler:       scaler,
53 53
 		codec:        codec,
54
-		hookExecutor: stratsupport.NewHookExecutor(client, os.Stdout),
54
+		hookExecutor: stratsupport.NewHookExecutor(client, os.Stdout, codec),
55 55
 		retryTimeout: 120 * time.Second,
56 56
 		retryPeriod:  1 * time.Second,
57 57
 	}
... ...
@@ -87,7 +87,7 @@ func NewRollingDeploymentStrategy(namespace string, client kclient.Interface, co
87 87
 			updater := kubectl.NewRollingUpdater(namespace, client)
88 88
 			return updater.Update(config)
89 89
 		},
90
-		hookExecutor: stratsupport.NewHookExecutor(client, os.Stdout),
90
+		hookExecutor: stratsupport.NewHookExecutor(client, os.Stdout, codec),
91 91
 		getUpdateAcceptor: func(timeout time.Duration) strat.UpdateAcceptor {
92 92
 			return stratsupport.NewAcceptNewlyObservedReadyPods(client, timeout, AcceptorInterval)
93 93
 		},
... ...
@@ -21,6 +21,7 @@ import (
21 21
 
22 22
 	deployapi "github.com/openshift/origin/pkg/deploy/api"
23 23
 	deployutil "github.com/openshift/origin/pkg/deploy/util"
24
+	"github.com/openshift/origin/pkg/util"
24 25
 	namer "github.com/openshift/origin/pkg/util/namer"
25 26
 )
26 27
 
... ...
@@ -34,10 +35,12 @@ type HookExecutor struct {
34 34
 	podLogDestination io.Writer
35 35
 	// podLogStream provides a reader for a pod's logs.
36 36
 	podLogStream func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error)
37
+	// Codec is used for encoding/decoding.
38
+	codec runtime.Codec
37 39
 }
38 40
 
39 41
 // NewHookExecutor makes a HookExecutor from a client.
40
-func NewHookExecutor(client kclient.Interface, podLogDestination io.Writer) *HookExecutor {
42
+func NewHookExecutor(client kclient.Interface, podLogDestination io.Writer, codec runtime.Codec) *HookExecutor {
41 43
 	return &HookExecutor{
42 44
 		podClient: &HookExecutorPodClientImpl{
43 45
 			CreatePodFunc: func(namespace string, pod *kapi.Pod) (*kapi.Pod, error) {
... ...
@@ -55,6 +58,7 @@ func NewHookExecutor(client kclient.Interface, podLogDestination io.Writer) *Hoo
55 55
 			return req.Stream()
56 56
 		},
57 57
 		podLogDestination: podLogDestination,
58
+		codec:             codec,
58 59
 	}
59 60
 }
60 61
 
... ...
@@ -93,8 +97,13 @@ func (e *HookExecutor) Execute(hook *deployapi.LifecycleHook, deployment *kapi.R
93 93
 //   * Working directory
94 94
 //   * Resources
95 95
 func (e *HookExecutor) executeExecNewPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) error {
96
+	config, err := deployutil.DecodeDeploymentConfig(deployment, e.codec)
97
+	if err != nil {
98
+		return err
99
+	}
100
+
96 101
 	// Build a pod spec from the hook config and deployment
97
-	podSpec, err := makeHookPod(hook, deployment, label)
102
+	podSpec, err := makeHookPod(hook, deployment, &config.Template.Strategy, label)
98 103
 	if err != nil {
99 104
 		return err
100 105
 	}
... ...
@@ -164,7 +173,7 @@ func (e *HookExecutor) readPodLogs(pod *kapi.Pod, wg *sync.WaitGroup) {
164 164
 }
165 165
 
166 166
 // makeHookPod makes a pod spec from a hook and deployment.
167
-func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, label string) (*kapi.Pod, error) {
167
+func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, strategy *deployapi.DeploymentStrategy, label string) (*kapi.Pod, error) {
168 168
 	exec := hook.ExecNewPod
169 169
 	var baseContainer *kapi.Container
170 170
 	for _, container := range deployment.Spec.Template.Spec.Containers {
... ...
@@ -269,6 +278,9 @@ func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationCont
269 269
 		},
270 270
 	}
271 271
 
272
+	util.MergeInto(pod.Labels, strategy.Labels, 0)
273
+	util.MergeInto(pod.Annotations, strategy.Annotations, 0)
274
+
272 275
 	return pod, nil
273 276
 }
274 277
 
... ...
@@ -42,6 +42,7 @@ func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) {
42 42
 				return func() *kapi.Pod { return nil }
43 43
 			},
44 44
 		},
45
+		codec: kapi.Codec,
45 46
 	}
46 47
 
47 48
 	err := executor.executeExecNewPod(hook, deployment, "hook")
... ...
@@ -81,6 +82,7 @@ func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) {
81 81
 		podLogStream: func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error) {
82 82
 			return ioutil.NopCloser(strings.NewReader("test")), nil
83 83
 		},
84
+		codec: kapi.Codec,
84 85
 	}
85 86
 
86 87
 	err := executor.executeExecNewPod(hook, deployment, "hook")
... ...
@@ -132,6 +134,7 @@ func TestHookExecutor_executeExecNewPodFailed(t *testing.T) {
132 132
 		podLogStream: func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error) {
133 133
 			return nil, fmt.Errorf("can't access logs")
134 134
 		},
135
+		codec: kapi.Codec,
135 136
 	}
136 137
 
137 138
 	err := executor.executeExecNewPod(hook, deployment, "hook")
... ...
@@ -150,9 +153,10 @@ func TestHookExecutor_makeHookPodInvalidContainerRef(t *testing.T) {
150 150
 		},
151 151
 	}
152 152
 
153
-	deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec)
153
+	config := deploytest.OkDeploymentConfig(1)
154
+	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
154 155
 
155
-	_, err := makeHookPod(hook, deployment, "hook")
156
+	_, err := makeHookPod(hook, deployment, &config.Template.Strategy, "hook")
156 157
 
157 158
 	if err == nil {
158 159
 		t.Fatalf("expected an error")
... ...
@@ -166,9 +170,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
166 166
 	maxDeploymentDurationSeconds := deployapi.MaxDeploymentDurationSeconds
167 167
 
168 168
 	tests := []struct {
169
-		name     string
170
-		hook     *deployapi.LifecycleHook
171
-		expected *kapi.Pod
169
+		name                string
170
+		hook                *deployapi.LifecycleHook
171
+		expected            *kapi.Pod
172
+		strategyLabels      map[string]string
173
+		strategyAnnotations map[string]string
172 174
 	}{
173 175
 		{
174 176
 			name: "overrides",
... ...
@@ -309,11 +315,74 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
309 309
 				},
310 310
 			},
311 311
 		},
312
+		{
313
+			name: "labels and annotations",
314
+			hook: &deployapi.LifecycleHook{
315
+				FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort,
316
+				ExecNewPod: &deployapi.ExecNewPodHook{
317
+					ContainerName: "container1",
318
+				},
319
+			},
320
+			expected: &kapi.Pod{
321
+				ObjectMeta: kapi.ObjectMeta{
322
+					Name: namer.GetPodName(deploymentName, "hook"),
323
+					Labels: map[string]string{
324
+						deployapi.DeployerPodForDeploymentLabel: deploymentName,
325
+						"label1": "value1",
326
+					},
327
+					Annotations: map[string]string{
328
+						deployapi.DeploymentAnnotation: deploymentName,
329
+						"annotation2":                  "value2",
330
+					},
331
+				},
332
+				Spec: kapi.PodSpec{
333
+					RestartPolicy:         kapi.RestartPolicyNever,
334
+					ActiveDeadlineSeconds: &maxDeploymentDurationSeconds,
335
+					Containers: []kapi.Container{
336
+						{
337
+							Name:  "lifecycle",
338
+							Image: "registry:8080/repo1:ref1",
339
+							Env: []kapi.EnvVar{
340
+								{
341
+									Name:  "ENV1",
342
+									Value: "VAL1",
343
+								},
344
+								{
345
+									Name:  "OPENSHIFT_DEPLOYMENT_NAME",
346
+									Value: deploymentName,
347
+								},
348
+								{
349
+									Name:  "OPENSHIFT_DEPLOYMENT_NAMESPACE",
350
+									Value: deploymentNamespace,
351
+								},
352
+							},
353
+							Resources: kapi.ResourceRequirements{
354
+								Limits: kapi.ResourceList{
355
+									kapi.ResourceCPU:    resource.MustParse("10"),
356
+									kapi.ResourceMemory: resource.MustParse("10M"),
357
+								},
358
+							},
359
+						},
360
+					},
361
+					ImagePullSecrets: []kapi.LocalObjectReference{
362
+						{
363
+							Name: "secret-1",
364
+						},
365
+					},
366
+				},
367
+			},
368
+			strategyLabels: map[string]string{
369
+				deployapi.DeployerPodForDeploymentLabel: "ignoredValue",
370
+				"label1": "value1",
371
+			},
372
+			strategyAnnotations: map[string]string{"annotation2": "value2"},
373
+		},
312 374
 	}
313 375
 
314 376
 	for _, test := range tests {
315 377
 		t.Logf("evaluating test: %s", test.name)
316
-		pod, err := makeHookPod(test.hook, deployment("deployment", "test"), "hook")
378
+		config, deployment := deployment("deployment", "test", test.strategyLabels, test.strategyAnnotations)
379
+		pod, err := makeHookPod(test.hook, deployment, &config.Template.Strategy, "hook")
317 380
 		if err != nil {
318 381
 			t.Fatalf("unexpected error: %s", err)
319 382
 		}
... ...
@@ -337,9 +406,10 @@ func TestHookExecutor_makeHookPodRestart(t *testing.T) {
337 337
 		},
338 338
 	}
339 339
 
340
-	deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec)
340
+	config := deploytest.OkDeploymentConfig(1)
341
+	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
341 342
 
342
-	pod, err := makeHookPod(hook, deployment, "hook")
343
+	pod, err := makeHookPod(hook, deployment, &config.Template.Strategy, "hook")
343 344
 	if err != nil {
344 345
 		t.Fatalf("unexpected error: %s", err)
345 346
 	}
... ...
@@ -456,7 +526,7 @@ func TestAcceptNewlyObservedReadyPods_scenarios(t *testing.T) {
456 456
 	}
457 457
 }
458 458
 
459
-func deployment(name, namespace string) *kapi.ReplicationController {
459
+func deployment(name, namespace string, strategyLabels, strategyAnnotations map[string]string) (*deployapi.DeploymentConfig, *kapi.ReplicationController) {
460 460
 	config := &deployapi.DeploymentConfig{
461 461
 		ObjectMeta: kapi.ObjectMeta{
462 462
 			Name:      name,
... ...
@@ -472,6 +542,8 @@ func deployment(name, namespace string) *kapi.ReplicationController {
472 472
 						kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"),
473 473
 					},
474 474
 				},
475
+				Labels:      strategyLabels,
476
+				Annotations: strategyAnnotations,
475 477
 			},
476 478
 			ControllerTemplate: kapi.ReplicationControllerSpec{
477 479
 				Replicas: 1,
... ...
@@ -534,7 +606,7 @@ func deployment(name, namespace string) *kapi.ReplicationController {
534 534
 	}
535 535
 	deployment, _ := deployutil.MakeDeployment(config, kapi.Codec)
536 536
 	deployment.Namespace = namespace
537
-	return deployment
537
+	return config, deployment
538 538
 }
539 539
 
540 540
 type envByNameAsc []kapi.EnvVar