Skip to content

Add openshift.io/deployer-pod.type label #8632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/deploy/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ const (
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
// to implement the deployment behavior.
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
// DeployerPodForDeploymentLabel is a label which groups pods related to a
// deployment. The value is a deployment name. The deployer pod and hook pods
// created by the internal strategies will have this label. Custom
Expand Down
2 changes: 2 additions & 0 deletions pkg/deploy/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ const (
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
// to implement the deployment behavior.
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
// DeployerPodForDeploymentLabel is a label which groups pods related to a
// deployment. The value is a deployment name. The deployer pod and hook pods
// created by the internal strategies will have this label. Custom
Expand Down
2 changes: 2 additions & 0 deletions pkg/deploy/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ const (
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
// to implement the deployment behavior.
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
// DeployerPodForDeploymentLabel is a label which groups pods related to a
// deployment. The value is a deployment name. The deployer pod and hook pods
// created by the internal strategies will have this label. Custom
Expand Down
1 change: 1 addition & 0 deletions pkg/deploy/strategy/support/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationCont
deployapi.DeploymentAnnotation: deployment.Name,
},
Labels: map[string]string{
deployapi.DeploymentPodTypeLabel: label,
deployapi.DeployerPodForDeploymentLabel: deployment.Name,
},
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/strategy/support/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
ObjectMeta: kapi.ObjectMeta{
Name: namer.GetPodName(deploymentName, "hook"),
Labels: map[string]string{
deployapi.DeploymentPodTypeLabel: "hook",
deployapi.DeployerPodForDeploymentLabel: deploymentName,
},
Annotations: map[string]string{
Expand Down Expand Up @@ -274,6 +275,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
ObjectMeta: kapi.ObjectMeta{
Name: namer.GetPodName(deploymentName, "hook"),
Labels: map[string]string{
deployapi.DeploymentPodTypeLabel: "hook",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these labels?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see. Nevermind

deployapi.DeployerPodForDeploymentLabel: deploymentName,
},
Annotations: map[string]string{
Expand Down Expand Up @@ -329,6 +331,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
ObjectMeta: kapi.ObjectMeta{
Name: namer.GetPodName(deploymentName, "hook"),
Labels: map[string]string{
deployapi.DeploymentPodTypeLabel: "hook",
deployapi.DeployerPodForDeploymentLabel: deploymentName,
"label1": "value1",
},
Expand Down
6 changes: 6 additions & 0 deletions test/end-to-end/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ os::cmd::expect_success_and_text "cat '${LOG_DIR}/kubectl-with-token.log'" 'Usin
os::cmd::expect_success_and_text "cat '${LOG_DIR}/kubectl-with-token.log'" 'kubectl-with-token'

echo "[INFO] Testing deployment logs and failing pre and mid hooks ..."
# test hook selectors
os::cmd::expect_success "oc create -f ${OS_ROOT}/test/fixtures/complete-dc-hooks.yaml"
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-pre -o jsonpath={.items[*].status.phase}' '^Succeeded$'
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-mid -o jsonpath={.items[*].status.phase}' '^Succeeded$'
os::cmd::try_until_text 'oc get pods -l openshift.io/deployer-pod.type=hook-post -o jsonpath={.items[*].status.phase}' '^Succeeded$'
exit
# test the pre hook on a rolling deployment
oc create -f test/fixtures/failing-dc.yaml
tryuntil oc get rc/failing-dc-1
Expand Down
43 changes: 43 additions & 0 deletions test/fixtures/complete-dc-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: v1
kind: DeploymentConfig
metadata:
name: complete-dc-hooks
spec:
replicas: 2
selector:
name: complete-dc-hooks
strategy:
type: Recreate
recreateParams:
timeoutSeconds: 5
pre:
failurePolicy: Abort
execNewPod:
containerName: myapp
command:
- "/bin/true"
mid:
failurePolicy: Abort
execNewPod:
containerName: myapp
command:
- "/bin/true"
post:
failurePolicy: Abort
execNewPod:
containerName: myapp
command:
- "/bin/true"
template:
metadata:
labels:
name: complete-dc-hooks
spec:
containers:
- image: "docker.io/busybox"
name: myapp
command:
- "/bin/sleep"
- "60"
triggers:
- type: ConfigChange