Repository navigation
fix: apply PULL_POLICY to the controller and webhook server #1751
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // | ||
| // Copyright (c) 2019-2026 Red Hat, Inc. | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
|
|
||
| package config | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| corev1 "k8s.io/api/core/v1" | ||
| ) | ||
|
|
||
| func TestGetWebhooksServerImagePullPolicy(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| value string | ||
| expected corev1.PullPolicy | ||
| wantErr bool | ||
| }{ | ||
| {name: "defaults to Always when unset", value: "", expected: corev1.PullAlways}, | ||
| {name: "accepts Always", value: "Always", expected: corev1.PullAlways}, | ||
| {name: "accepts IfNotPresent", value: "IfNotPresent", expected: corev1.PullIfNotPresent}, | ||
| {name: "accepts Never", value: "Never", expected: corev1.PullNever}, | ||
| {name: "rejects unknown value", value: "Sometimes", wantErr: true}, | ||
| {name: "rejects wrong case", value: "never", wantErr: true}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Setenv(WebhooksImagePullPolicyEnvVar, tt.value) | ||
|
|
||
| actual, err := GetWebhooksServerImagePullPolicy() | ||
|
|
||
| if tt.wantErr { | ||
| assert.Error(t, err) | ||
| assert.Contains(t, err.Error(), WebhooksImagePullPolicyEnvVar) | ||
| return | ||
| } | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, tt.expected, actual) | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the webhook pull policy to locally started controllers.
make runandmake debugbuild the controller environment frommanager.yaml. That component does not defineWEBHOOKS_SERVER_IMAGE_PULL_POLICY. The local controller therefore reads an empty value, andGetWebhooksServerImagePullPolicyreturnsAlways. A run withPULL_POLICY=Nevercan reset the webhook Deployment toAlways. This affects only local development runs.Set the variable in
_gen_configuration_envfromPULL_POLICY, and keep an explicit shell override. Use the same$${NAME:-value}form as the manager env entries:Suggested fix
echo "export RELATED_IMAGE_devworkspace_webhook_server=$(DWO_IMG)" >> $(CONTROLLER_ENV_FILE) echo "export WEBHOOK_SECRET_NAME=devworkspace-operator-webhook-cert" >> $(CONTROLLER_ENV_FILE) + echo "export WEBHOOKS_SERVER_IMAGE_PULL_POLICY=\"$${WEBHOOKS_SERVER_IMAGE_PULL_POLICY:-$(PULL_POLICY)}\"" >> $(CONTROLLER_ENV_FILE) cat $(CONTROLLER_ENV_FILE)Checkov (3.4.3)
[medium] 2-22: Containers should not run with allowPrivilegeEscalation
(CKV_K8S_20)
[medium] 2-22: Minimize the admission of root containers
(CKV_K8S_23)