Skip to content

Commit 65b01a6

Browse files
committed
Add openshift.io/deployer-pod.type label
1 parent 0e2af56 commit 65b01a6

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

pkg/deploy/api/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ const (
199199
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
200200
// to implement the deployment behavior.
201201
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
202+
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
203+
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
202204
// DeployerPodForDeploymentLabel is a label which groups pods related to a
203205
// deployment. The value is a deployment name. The deployer pod and hook pods
204206
// created by the internal strategies will have this label. Custom

pkg/deploy/api/v1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ const (
197197
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
198198
// to implement the deployment behavior.
199199
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
200+
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
201+
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
200202
// DeployerPodForDeploymentLabel is a label which groups pods related to a
201203
// deployment. The value is a deployment name. The deployer pod and hook pods
202204
// created by the internal strategies will have this label. Custom

pkg/deploy/api/v1beta3/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ const (
197197
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
198198
// to implement the deployment behavior.
199199
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
200+
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
201+
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
200202
// DeployerPodForDeploymentLabel is a label which groups pods related to a
201203
// deployment. The value is a deployment name. The deployer pod and hook pods
202204
// created by the internal strategies will have this label. Custom

pkg/deploy/strategy/support/lifecycle.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationCont
303303
deployapi.DeploymentAnnotation: deployment.Name,
304304
},
305305
Labels: map[string]string{
306+
deployapi.DeploymentPodTypeLabel: label,
306307
deployapi.DeployerPodForDeploymentLabel: deployment.Name,
307308
},
308309
},

test/end-to-end/core.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ os::cmd::expect_success_and_text "cat '${LOG_DIR}/kubectl-with-token.log'" 'Usin
184184
os::cmd::expect_success_and_text "cat '${LOG_DIR}/kubectl-with-token.log'" 'kubectl-with-token'
185185

186186
echo "[INFO] Testing deployment logs and failing pre and mid hooks ..."
187+
# test hook selectors
188+
oc create -f test/fixtures/hooks-dc.yaml
189+
wait_for_command 'oc get pods -l openshift.io/deployer-pod.type=hook-pre | grep -q Completed' $((60*TIME_SEC))
190+
wait_for_command 'oc get pods -l openshift.io/deployer-pod.type=hook-mid | grep -q Completed' $((60*TIME_SEC))
191+
wait_for_command 'oc get pods -l openshift.io/deployer-pod.type=hook-post | grep -q Completed' $((60*TIME_SEC))
187192
# test the pre hook on a rolling deployment
188193
oc create -f test/fixtures/failing-dc.yaml
189194
tryuntil oc get rc/failing-dc-1

test/fixtures/hooks-dc.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: v1
2+
kind: DeploymentConfig
3+
metadata:
4+
name: failing-dc-hooks
5+
spec:
6+
replicas: 2
7+
selector:
8+
name: failing-dc-hooks
9+
strategy:
10+
type: Recreate
11+
recreateParams:
12+
timeoutSeconds: 5
13+
pre:
14+
failurePolicy: Abort
15+
execNewPod:
16+
containerName: myapp
17+
command: [ "/bin/sleep", "1" ]
18+
mid:
19+
failurePolicy: Abort
20+
execNewPod:
21+
containerName: myapp
22+
command: [ "/bin/sleep", "1" ]
23+
post:
24+
failurePolicy: Abort
25+
execNewPod:
26+
containerName: myapp
27+
command: [ "/bin/sleep", "1" ]
28+
template:
29+
metadata:
30+
labels:
31+
name: failing-dc-hooks
32+
spec:
33+
containers:
34+
- image: "docker.io/busybox"
35+
name: myapp
36+
command:
37+
- "/bin/sleep"
38+
- "60"
39+
triggers:
40+
- type: ConfigChange

0 commit comments

Comments
 (0)