Skip to content

Commit 1511d42

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

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-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+
os::cmd::expect_success "oc create -f ${OS_ROOT}/test/fixtures/complete-dc-hooks.yaml"
189+
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-pre -o jsonpath={.items[*].status.phase}' 'Succeeded'
190+
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-mid -o jsonpath={.items[*].status.phase}' 'Succeeded'
191+
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-post -o jsonpath={.items[*].status.phase}' 'Succeeded'
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/complete-dc-hooks.yaml

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

0 commit comments

Comments
 (0)