Skip to content
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

Consideration of imagePullPolicy on lifecycle hook execution #12080

Merged
merged 1 commit into from
Dec 2, 2016
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
15 changes: 8 additions & 7 deletions pkg/deploy/strategy/support/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,14 @@ func makeHookPod(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationCont
Spec: kapi.PodSpec{
Containers: []kapi.Container{
{
Name: HookContainerName,
Image: baseContainer.Image,
Command: exec.Command,
WorkingDir: baseContainer.WorkingDir,
Env: mergedEnv,
Resources: resources,
VolumeMounts: volumeMounts,
Name: HookContainerName,
Image: baseContainer.Image,
ImagePullPolicy: baseContainer.ImagePullPolicy,
Command: exec.Command,
WorkingDir: baseContainer.WorkingDir,
Env: mergedEnv,
Resources: resources,
VolumeMounts: volumeMounts,
Copy link

Choose a reason for hiding this comment

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

@Kargakis should we be passing along other fields as well like SecurityContext settings?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Kargakis , @pweil- , Do you want that i amend my PR with the other fields ? Can you list me all fields that you want to add ?

Copy link

Choose a reason for hiding this comment

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

@VanRoy created #12103 to make sure we follow up on it. No need to add it here.

},
},
Volumes: volumes,
Expand Down
53 changes: 52 additions & 1 deletion pkg/deploy/strategy/support/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
Value: deploymentNamespace,
},
},
ImagePullPolicy: kapi.PullIfNotPresent,
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceCPU: resource.MustParse("10"),
Expand Down Expand Up @@ -370,6 +371,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
Value: deploymentNamespace,
},
},
ImagePullPolicy: kapi.PullIfNotPresent,
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceCPU: resource.MustParse("10"),
Expand Down Expand Up @@ -429,6 +431,7 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
Value: deploymentNamespace,
},
},
ImagePullPolicy: kapi.PullIfNotPresent,
Resources: kapi.ResourceRequirements{
Limits: kapi.ResourceList{
kapi.ResourceCPU: resource.MustParse("10"),
Expand All @@ -451,6 +454,54 @@ func TestHookExecutor_makeHookPod(t *testing.T) {
},
strategyAnnotations: map[string]string{"annotation2": "value2"},
},
{
name: "allways pull image",
hook: &deployapi.LifecycleHook{
FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort,
ExecNewPod: &deployapi.ExecNewPodHook{
ContainerName: "container2",
},
},
expected: &kapi.Pod{
ObjectMeta: kapi.ObjectMeta{
Name: namer.GetPodName(deploymentName, "hook"),
Labels: map[string]string{
deployapi.DeploymentPodTypeLabel: "hook",
deployapi.DeployerPodForDeploymentLabel: deploymentName,
},
Annotations: map[string]string{
deployapi.DeploymentAnnotation: deploymentName,
},
},
Spec: kapi.PodSpec{
RestartPolicy: kapi.RestartPolicyNever,
ActiveDeadlineSeconds: &maxDeploymentDurationSeconds,
Containers: []kapi.Container{
{
Name: "lifecycle",
Image: "registry:8080/repo1:ref2",
Env: []kapi.EnvVar{
{
Name: "OPENSHIFT_DEPLOYMENT_NAME",
Value: deploymentName,
},
{
Name: "OPENSHIFT_DEPLOYMENT_NAMESPACE",
Value: deploymentNamespace,
},
},
ImagePullPolicy: kapi.PullAlways,
},
},
TerminationGracePeriodSeconds: &gracePeriod,
ImagePullSecrets: []kapi.LocalObjectReference{
{
Name: "secret-1",
},
},
},
},
},
}

for _, test := range tests {
Expand Down Expand Up @@ -670,7 +721,7 @@ func deployment(name, namespace string, strategyLabels, strategyAnnotations map[
{
Name: "container2",
Image: "registry:8080/repo1:ref2",
ImagePullPolicy: kapi.PullIfNotPresent,
ImagePullPolicy: kapi.PullAlways,
},
},
Volumes: []kapi.Volume{
Expand Down