Skip to content

Commit a1331ae

Browse files
committed
OCPBUGS-28230: fallback to logs for termination message
Signed-off-by: Joe Lanford <[email protected]>
1 parent be20100 commit a1331ae

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

pkg/controller/bundle/bundle_unpacker.go

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string
157157
Drop: []corev1.Capability{"ALL"},
158158
},
159159
},
160+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
160161
},
161162
},
162163
InitContainers: []corev1.Container{
@@ -182,6 +183,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string
182183
Drop: []corev1.Capability{"ALL"},
183184
},
184185
},
186+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
185187
},
186188
{
187189
Name: "pull",
@@ -210,6 +212,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string
210212
Drop: []corev1.Capability{"ALL"},
211213
},
212214
},
215+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
213216
},
214217
},
215218
Volumes: []corev1.Volume{

pkg/controller/bundle/bundle_unpacker_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ func TestConfigMapUnpacker(t *testing.T) {
267267
Drop: []corev1.Capability{"ALL"},
268268
},
269269
},
270+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
270271
},
271272
},
272273
InitContainers: []corev1.Container{
@@ -292,6 +293,7 @@ func TestConfigMapUnpacker(t *testing.T) {
292293
Drop: []corev1.Capability{"ALL"},
293294
},
294295
},
296+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
295297
},
296298
{
297299
Name: "pull",
@@ -320,6 +322,7 @@ func TestConfigMapUnpacker(t *testing.T) {
320322
Drop: []corev1.Capability{"ALL"},
321323
},
322324
},
325+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
323326
},
324327
},
325328
Volumes: []corev1.Volume{
@@ -498,6 +501,7 @@ func TestConfigMapUnpacker(t *testing.T) {
498501
Drop: []corev1.Capability{"ALL"},
499502
},
500503
},
504+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
501505
},
502506
},
503507
InitContainers: []corev1.Container{
@@ -523,6 +527,7 @@ func TestConfigMapUnpacker(t *testing.T) {
523527
Drop: []corev1.Capability{"ALL"},
524528
},
525529
},
530+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
526531
},
527532
{
528533
Name: "pull",
@@ -551,6 +556,7 @@ func TestConfigMapUnpacker(t *testing.T) {
551556
Drop: []corev1.Capability{"ALL"},
552557
},
553558
},
559+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
554560
},
555561
},
556562
Volumes: []corev1.Volume{
@@ -769,6 +775,7 @@ func TestConfigMapUnpacker(t *testing.T) {
769775
Drop: []corev1.Capability{"ALL"},
770776
},
771777
},
778+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
772779
},
773780
},
774781
InitContainers: []corev1.Container{
@@ -794,6 +801,7 @@ func TestConfigMapUnpacker(t *testing.T) {
794801
Drop: []corev1.Capability{"ALL"},
795802
},
796803
},
804+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
797805
},
798806
{
799807
Name: "pull",
@@ -822,6 +830,7 @@ func TestConfigMapUnpacker(t *testing.T) {
822830
Drop: []corev1.Capability{"ALL"},
823831
},
824832
},
833+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
825834
},
826835
},
827836
Volumes: []corev1.Volume{
@@ -1035,6 +1044,7 @@ func TestConfigMapUnpacker(t *testing.T) {
10351044
Drop: []corev1.Capability{"ALL"},
10361045
},
10371046
},
1047+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
10381048
},
10391049
},
10401050
InitContainers: []corev1.Container{
@@ -1060,6 +1070,7 @@ func TestConfigMapUnpacker(t *testing.T) {
10601070
Drop: []corev1.Capability{"ALL"},
10611071
},
10621072
},
1073+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
10631074
},
10641075
{
10651076
Name: "pull",
@@ -1088,6 +1099,7 @@ func TestConfigMapUnpacker(t *testing.T) {
10881099
Drop: []corev1.Capability{"ALL"},
10891100
},
10901101
},
1102+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
10911103
},
10921104
},
10931105
Volumes: []corev1.Volume{
@@ -1270,6 +1282,7 @@ func TestConfigMapUnpacker(t *testing.T) {
12701282
Drop: []corev1.Capability{"ALL"},
12711283
},
12721284
},
1285+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
12731286
},
12741287
},
12751288
InitContainers: []corev1.Container{
@@ -1295,6 +1308,7 @@ func TestConfigMapUnpacker(t *testing.T) {
12951308
Drop: []corev1.Capability{"ALL"},
12961309
},
12971310
},
1311+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
12981312
},
12991313
{
13001314
Name: "pull",
@@ -1323,6 +1337,7 @@ func TestConfigMapUnpacker(t *testing.T) {
13231337
Drop: []corev1.Capability{"ALL"},
13241338
},
13251339
},
1340+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
13261341
},
13271342
},
13281343
Volumes: []corev1.Volume{
@@ -1516,6 +1531,7 @@ func TestConfigMapUnpacker(t *testing.T) {
15161531
Drop: []corev1.Capability{"ALL"},
15171532
},
15181533
},
1534+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
15191535
},
15201536
},
15211537
InitContainers: []corev1.Container{
@@ -1541,6 +1557,7 @@ func TestConfigMapUnpacker(t *testing.T) {
15411557
Drop: []corev1.Capability{"ALL"},
15421558
},
15431559
},
1560+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
15441561
},
15451562
{
15461563
Name: "pull",
@@ -1569,6 +1586,7 @@ func TestConfigMapUnpacker(t *testing.T) {
15691586
Drop: []corev1.Capability{"ALL"},
15701587
},
15711588
},
1589+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
15721590
},
15731591
},
15741592
Volumes: []corev1.Volume{

pkg/controller/registry/reconciler/reconciler.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,12 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s
279279
MountPath: catalogPath,
280280
}
281281
pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{
282-
Name: "extract-utilities",
283-
Image: utilImage,
284-
Command: []string{"cp"},
285-
Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)},
286-
VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount},
282+
Name: "extract-utilities",
283+
Image: utilImage,
284+
Command: []string{"cp"},
285+
Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)},
286+
VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount},
287+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
287288
}, corev1.Container{
288289
Name: "extract-content",
289290
Image: img,
@@ -295,7 +296,8 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s
295296
"--cache.from=" + grpcPodConfig.ExtractContent.CacheDir,
296297
"--cache.to=" + fmt.Sprintf("%s/cache", catalogPath),
297298
},
298-
VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount},
299+
VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount},
300+
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
299301
})
300302

301303
pod.Spec.Containers[0].Image = opmImg

pkg/controller/registry/reconciler/reconciler_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func TestPodExtractContent(t *testing.T) {
277277
ObjectMeta: metav1.ObjectMeta{
278278
GenerateName: "test-",
279279
Namespace: "testns",
280-
Labels: map[string]string{"olm.pod-spec-hash": "2AHzz8IDqQLwPsDyu4UjUmnROr4E59PMKm9OCm", "olm.managed": "true"},
280+
Labels: map[string]string{"olm.pod-spec-hash": "5MSUJs07MqD3fl9supmPaRNxD9N6tK8Bjo4OFl", "olm.managed": "true"},
281281
Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"},
282282
},
283283
Spec: corev1.PodSpec{
@@ -293,11 +293,12 @@ func TestPodExtractContent(t *testing.T) {
293293
},
294294
InitContainers: []corev1.Container{
295295
{
296-
Name: "extract-utilities",
297-
Image: "utilImage",
298-
Command: []string{"cp"},
299-
Args: []string{"/bin/copy-content", "/utilities/copy-content"},
300-
VolumeMounts: []corev1.VolumeMount{{Name: "utilities", MountPath: "/utilities"}},
296+
Name: "extract-utilities",
297+
Image: "utilImage",
298+
Command: []string{"cp"},
299+
Args: []string{"/bin/copy-content", "/utilities/copy-content"},
300+
VolumeMounts: []corev1.VolumeMount{{Name: "utilities", MountPath: "/utilities"}},
301+
TerminationMessagePolicy: "FallbackToLogsOnError",
301302
},
302303
{
303304
Name: "extract-content",
@@ -314,6 +315,7 @@ func TestPodExtractContent(t *testing.T) {
314315
{Name: "utilities", MountPath: "/utilities"},
315316
{Name: "catalog-content", MountPath: "/extracted-catalog"},
316317
},
318+
TerminationMessagePolicy: "FallbackToLogsOnError",
317319
},
318320
},
319321
Containers: []corev1.Container{

0 commit comments

Comments
 (0)