@@ -441,6 +441,141 @@ status:
441441 },
442442 },
443443 },
444+ {
445+ name : "fetches pod logs from terminated containers" ,
446+ targetedObject : & corev1.Pod {
447+ ObjectMeta : metav1.ObjectMeta {
448+ Namespace : "test" ,
449+ Name : "my-pod" ,
450+ },
451+ Spec : corev1.PodSpec {
452+ InitContainers : []corev1.Container {
453+ {
454+ Name : "my-init-container" ,
455+ },
456+ },
457+ Containers : []corev1.Container {
458+ {
459+ Name : "my-container" ,
460+ },
461+ },
462+ EphemeralContainers : []corev1.EphemeralContainer {
463+ {
464+ EphemeralContainerCommon : corev1.EphemeralContainerCommon {
465+ Name : "my-ephemeral-container" ,
466+ },
467+ },
468+ },
469+ },
470+ Status : corev1.PodStatus {
471+ InitContainerStatuses : []corev1.ContainerStatus {
472+ {
473+ Name : "my-init-container" ,
474+ State : corev1.ContainerState {
475+ Terminated : & corev1.ContainerStateTerminated {},
476+ Running : nil ,
477+ },
478+ },
479+ },
480+ ContainerStatuses : []corev1.ContainerStatus {
481+ {
482+ Name : "my-container" ,
483+ State : corev1.ContainerState {
484+ Terminated : & corev1.ContainerStateTerminated {},
485+ Running : nil ,
486+ },
487+ },
488+ },
489+ EphemeralContainerStatuses : []corev1.ContainerStatus {
490+ {
491+ Name : "my-ephemeral-container" ,
492+ State : corev1.ContainerState {
493+ Terminated : & corev1.ContainerStateTerminated {},
494+ Running : nil ,
495+ },
496+ },
497+ },
498+ },
499+ },
500+ existingObjects : nil ,
501+ relatedResources : false ,
502+ keepGoing : false ,
503+ expectedError : nil ,
504+ expectedDump : & testhelpers.GatherDump {
505+ EmptyDirs : nil ,
506+ Files : []testhelpers.File {
507+ {
508+ Name : "namespaces/test/pods/my-pod.yaml" ,
509+ Content : strings .TrimPrefix (`
510+ apiVersion: v1
511+ kind: Pod
512+ metadata:
513+ name: my-pod
514+ namespace: test
515+ spec:
516+ containers:
517+ - name: my-container
518+ resources: {}
519+ ephemeralContainers:
520+ - name: my-ephemeral-container
521+ resources: {}
522+ initContainers:
523+ - name: my-init-container
524+ resources: {}
525+ status:
526+ containerStatuses:
527+ - image: ""
528+ imageID: ""
529+ lastState: {}
530+ name: my-container
531+ ready: false
532+ restartCount: 0
533+ state:
534+ terminated:
535+ exitCode: 0
536+ finishedAt: null
537+ startedAt: null
538+ ephemeralContainerStatuses:
539+ - image: ""
540+ imageID: ""
541+ lastState: {}
542+ name: my-ephemeral-container
543+ ready: false
544+ restartCount: 0
545+ state:
546+ terminated:
547+ exitCode: 0
548+ finishedAt: null
549+ startedAt: null
550+ initContainerStatuses:
551+ - image: ""
552+ imageID: ""
553+ lastState: {}
554+ name: my-init-container
555+ ready: false
556+ restartCount: 0
557+ state:
558+ terminated:
559+ exitCode: 0
560+ finishedAt: null
561+ startedAt: null
562+ ` , "\n " ),
563+ },
564+ {
565+ Name : "namespaces/test/pods/my-pod/my-container.terminated" ,
566+ Content : "fake logs" ,
567+ },
568+ {
569+ Name : "namespaces/test/pods/my-pod/my-ephemeral-container.terminated" ,
570+ Content : "fake logs" ,
571+ },
572+ {
573+ Name : "namespaces/test/pods/my-pod/my-init-container.terminated" ,
574+ Content : "fake logs" ,
575+ },
576+ },
577+ },
578+ },
444579 {
445580 name : "namespace doesn't collect any extra resources if related resources are disabled" ,
446581 targetedObject : & corev1.Namespace {
0 commit comments