Skip to content

Commit cbc76cb

Browse files
committed
Add support to set image pull policy for agent images
1 parent 93f95d9 commit cbc76cb

File tree

9 files changed

+8
-53
lines changed

9 files changed

+8
-53
lines changed

apis/v1alpha1/instrumentation_types.go

-42
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ type Java struct {
189189
// All extensions are copied to a single directory; if a JAR with the same name exists, it will be overwritten.
190190
// +optional
191191
Extensions []Extensions `json:"extensions,omitempty"`
192-
193-
// ImagePullPolicy
194-
// One of Always, Never, IfNotPresent.
195-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
196-
// +optional
197-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
198192
}
199193

200194
type Extensions struct {
@@ -228,12 +222,6 @@ type NodeJS struct {
228222
// Resources describes the compute resource requirements.
229223
// +optional
230224
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
231-
232-
// ImagePullPolicy
233-
// One of Always, Never, IfNotPresent.
234-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
235-
// +optional
236-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
237225
}
238226

239227
// Python defines Python SDK and instrumentation configuration.
@@ -259,12 +247,6 @@ type Python struct {
259247
// Resources describes the compute resource requirements.
260248
// +optional
261249
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
262-
263-
// ImagePullPolicy
264-
// One of Always, Never, IfNotPresent.
265-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
266-
// +optional
267-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
268250
}
269251

270252
// DotNet defines DotNet SDK and instrumentation configuration.
@@ -289,12 +271,6 @@ type DotNet struct {
289271
// Resources describes the compute resource requirements.
290272
// +optional
291273
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
292-
293-
// ImagePullPolicy
294-
// One of Always, Never, IfNotPresent.
295-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
296-
// +optional
297-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
298274
}
299275

300276
type Go struct {
@@ -319,12 +295,6 @@ type Go struct {
319295
// Resources describes the compute resource requirements.
320296
// +optional
321297
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
322-
323-
// ImagePullPolicy
324-
// One of Always, Never, IfNotPresent.
325-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
326-
// +optional
327-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
328298
}
329299

330300
// ApacheHttpd defines Apache SDK and instrumentation configuration.
@@ -365,12 +335,6 @@ type ApacheHttpd struct {
365335
// Resources describes the compute resource requirements.
366336
// +optional
367337
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
368-
369-
// ImagePullPolicy
370-
// One of Always, Never, IfNotPresent.
371-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
372-
// +optional
373-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
374338
}
375339

376340
// Nginx defines Nginx SDK and instrumentation configuration.
@@ -407,12 +371,6 @@ type Nginx struct {
407371
// Resources describes the compute resource requirements.
408372
// +optional
409373
Resources corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
410-
411-
// ImagePullPolicy
412-
// One of Always, Never, IfNotPresent.
413-
// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
414-
// +optional
415-
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
416374
}
417375

418376
// InstrumentationStatus defines status of the instrumentation.

pkg/instrumentation/apachehttpd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func injectApacheHttpdagent(_ logr.Logger, apacheSpec v1alpha1.ApacheHttpd, pod
180180
MountPath: apacheAgentConfDirFull,
181181
},
182182
},
183-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, apacheSpec.ImagePullPolicy),
183+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
184184
})
185185
}
186186

pkg/instrumentation/dotnet.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func injectDotNetSDK(dotNetSpec v1alpha1.DotNet, pod corev1.Pod, index int, runt
128128
Name: volume.Name,
129129
MountPath: dotnetInstrMountPath,
130130
}},
131-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, dotNetSpec.ImagePullPolicy),
131+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
132132
})
133133
}
134134
return pod, nil

pkg/instrumentation/golang.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func injectGoSDK(goSpec v1alpha1.Go, pod corev1.Pod, cfg config.Config, instSpec
6868
Name: kernelDebugVolumeName,
6969
},
7070
},
71-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, goSpec.ImagePullPolicy),
71+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
7272
}
7373

7474
// Annotation takes precedence for OTEL_GO_AUTO_TARGET_EXE

pkg/instrumentation/helper.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,12 @@ func setContainersFromAnnotation(inst *instrumentationWithContainers, annotation
183183
return nil
184184
}
185185

186-
func setImagePullPolicy(instSpec corev1.PullPolicy, langSpec corev1.PullPolicy) corev1.PullPolicy {
186+
func setImagePullPolicy(instSpec corev1.PullPolicy) corev1.PullPolicy {
187187
var imagePullPolicy = corev1.PullAlways
188188

189189
if instSpec != imagePullPolicy {
190190
imagePullPolicy = instSpec
191191
}
192192

193-
if langSpec != instSpec {
194-
imagePullPolicy = langSpec
195-
}
196193
return imagePullPolicy
197194
}

pkg/instrumentation/javaagent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int, instSpec
8181
Name: volume.Name,
8282
MountPath: javaInstrMountPath,
8383
}},
84-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, javaSpec.ImagePullPolicy),
84+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
8585
})
8686

8787
for i, extension := range javaSpec.Extensions {

pkg/instrumentation/nginx.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ mv ${NGINX_AGENT_CONF_DIR_FULL}/opentelemetry_agent.conf ${NGINX_AGENT_CONF_DIR
244244
},
245245
},
246246
SecurityContext: pod.Spec.Containers[index].SecurityContext,
247-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, nginxSpec.ImagePullPolicy),
247+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
248248
})
249249

250250
found := false

pkg/instrumentation/nodejs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func injectNodeJSSDK(nodeJSSpec v1alpha1.NodeJS, pod corev1.Pod, index int, inst
7474
Name: volume.Name,
7575
MountPath: nodejsInstrMountPath,
7676
}},
77-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, nodeJSSpec.ImagePullPolicy),
77+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
7878
})
7979
}
8080
return pod, nil

pkg/instrumentation/python.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func injectPythonSDK(pythonSpec v1alpha1.Python, pod corev1.Pod, index int, plat
131131
Name: volume.Name,
132132
MountPath: pythonInstrMountPath,
133133
}},
134-
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy, pythonSpec.ImagePullPolicy),
134+
ImagePullPolicy: setImagePullPolicy(instSpec.ImagePullPolicy),
135135
})
136136
}
137137
return pod, nil

0 commit comments

Comments
 (0)