From e45cea0b0bc64161e3198ee982976ffb5578a3ce Mon Sep 17 00:00:00 2001
From: Vincent T
Date: Tue, 7 Nov 2023 10:40:48 -0500
Subject: [PATCH 1/2] frontend ContainersSection: Use correct status for init
containers
Signed-off-by: Vincent T
---
.../components/common/Resource/Resource.tsx | 9 +-
.../PodDetails.stories.storyshot | 85 +++++++++++++++++++
2 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/frontend/src/components/common/Resource/Resource.tsx b/frontend/src/components/common/Resource/Resource.tsx
index 563761d462..76095cdf46 100644
--- a/frontend/src/components/common/Resource/Resource.tsx
+++ b/frontend/src/components/common/Resource/Resource.tsx
@@ -850,7 +850,7 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
return resource?.spec?.initContainers || [];
}
- function getStatuses() {
+ function getStatuses(statusKind: 'containerStatuses' | 'initContainerStatuses') {
if (!resource || resource.kind !== 'Pod') {
return {};
}
@@ -859,7 +859,7 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
[key: string]: ContainerInfoProps['status'];
} = {};
- ((resource as KubePod).status.containerStatuses || []).forEach(containerStatus => {
+ ((resource as KubePod).status[statusKind] || []).forEach(containerStatus => {
const { name, ...status } = containerStatus;
statuses[name] = { ...status };
});
@@ -869,7 +869,8 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
const containers = getContainers();
const initContainers = getInitContainers();
- const statuses = getStatuses();
+ const statuses = getStatuses('containerStatuses');
+ const initStatuses = getStatuses('initContainerStatuses');
const numContainers = containers.length;
return (
@@ -896,7 +897,7 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
key={`init_container_${i}`}
resource={resource}
container={initContainer}
- status={statuses[initContainer.name]}
+ status={initStatuses[initContainer.name]}
/>
))}
diff --git a/frontend/src/components/pod/__snapshots__/PodDetails.stories.storyshot b/frontend/src/components/pod/__snapshots__/PodDetails.stories.storyshot
index 111860b1ad..8df522f0b5 100644
--- a/frontend/src/components/pod/__snapshots__/PodDetails.stories.storyshot
+++ b/frontend/src/components/pod/__snapshots__/PodDetails.stories.storyshot
@@ -1794,6 +1794,45 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
init-myservice
+
+ Status
+
+
+
+ Running
+
+
+
+ Restart Count
+
+
+ 0
+
+
+ Container ID
+
+
+
+ containerd://5fd564933040cc489ad0774b3f4d99866547cfef02a5277d7459a0fc800c9307
+
+
@@ -1821,6 +1860,18 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
busybox
+
+
+ ID:
+
+
+ docker.io/library/busybox@sha256:125113b35efe765c89a8ed49593e719532318d26828c58e26b26dd7c4c28a673
+
init-mydb
+
+ Status
+
+
+
+ Waiting (PodInitializing)
+
+
+
+ Restart Count
+
+
+ 0
+
+
+ Container ID
+
+
@@ -1876,6 +1960,7 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
busybox
+
Date: Tue, 7 Nov 2023 11:49:09 -0500
Subject: [PATCH 2/2] frontend ContainersSection: Add ephemeral containers
Signed-off-by: Vincent T
---
.../components/common/Resource/Resource.tsx | 23 ++++++++++++++++++-
frontend/src/i18n/locales/de/glossary.json | 2 +-
frontend/src/i18n/locales/en/glossary.json | 2 +-
frontend/src/i18n/locales/es/glossary.json | 2 +-
frontend/src/i18n/locales/fr/glossary.json | 2 +-
frontend/src/i18n/locales/pt/glossary.json | 2 +-
frontend/src/lib/k8s/pod.ts | 1 +
7 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/frontend/src/components/common/Resource/Resource.tsx b/frontend/src/components/common/Resource/Resource.tsx
index 76095cdf46..7df8ad6d77 100644
--- a/frontend/src/components/common/Resource/Resource.tsx
+++ b/frontend/src/components/common/Resource/Resource.tsx
@@ -850,7 +850,13 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
return resource?.spec?.initContainers || [];
}
- function getStatuses(statusKind: 'containerStatuses' | 'initContainerStatuses') {
+ function getEphemeralContainers() {
+ return resource?.spec?.ephemeralContainers || [];
+ }
+
+ function getStatuses(
+ statusKind: 'containerStatuses' | 'initContainerStatuses' | 'ephemeralContainerStatuses'
+ ) {
if (!resource || resource.kind !== 'Pod') {
return {};
}
@@ -869,8 +875,10 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
const containers = getContainers();
const initContainers = getInitContainers();
+ const ephemContainers = getEphemeralContainers();
const statuses = getStatuses('containerStatuses');
const initStatuses = getStatuses('initContainerStatuses');
+ const ephemStatuses = getStatuses('ephemeralContainerStatuses');
const numContainers = containers.length;
return (
@@ -890,6 +898,19 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
)}
+ {ephemContainers.length > 0 && (
+
+ {ephemContainers.map((ephemContainer: KubeContainer) => (
+
+ ))}
+
+ )}
+
{initContainers.length > 0 && (
{initContainers.map((initContainer: KubeContainer, i: number) => (
diff --git a/frontend/src/i18n/locales/de/glossary.json b/frontend/src/i18n/locales/de/glossary.json
index 07a6f6bd5c..314be72992 100644
--- a/frontend/src/i18n/locales/de/glossary.json
+++ b/frontend/src/i18n/locales/de/glossary.json
@@ -23,8 +23,8 @@
"Volume Mounts": "Speichereinhängpunkte",
"Containers": "Container",
"Container Spec": "Container-Spezifikation",
- "Container": "Container",
"Ephemeral Containers": "",
+ "Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
diff --git a/frontend/src/i18n/locales/en/glossary.json b/frontend/src/i18n/locales/en/glossary.json
index d9b74a9ed9..ccb04de83c 100644
--- a/frontend/src/i18n/locales/en/glossary.json
+++ b/frontend/src/i18n/locales/en/glossary.json
@@ -23,8 +23,8 @@
"Volume Mounts": "Volume Mounts",
"Containers": "Containers",
"Container Spec": "Container Spec",
- "Container": "Container",
"Ephemeral Containers": "Ephemeral Containers",
+ "Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
diff --git a/frontend/src/i18n/locales/es/glossary.json b/frontend/src/i18n/locales/es/glossary.json
index cdbf008cdd..b77bbecaf7 100644
--- a/frontend/src/i18n/locales/es/glossary.json
+++ b/frontend/src/i18n/locales/es/glossary.json
@@ -23,8 +23,8 @@
"Volume Mounts": "Montaje de Volumenes",
"Containers": "Contenedores",
"Container Spec": "Espec. de Contenedor",
- "Container": "Contenedor",
"Ephemeral Containers": "",
+ "Container": "Contenedor",
"Config Maps": "Config Maps",
"Definition": "Definición",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
diff --git a/frontend/src/i18n/locales/fr/glossary.json b/frontend/src/i18n/locales/fr/glossary.json
index 9793da2abe..e78997ecdd 100644
--- a/frontend/src/i18n/locales/fr/glossary.json
+++ b/frontend/src/i18n/locales/fr/glossary.json
@@ -23,8 +23,8 @@
"Volume Mounts": "Supports de volume",
"Containers": "Conteneurs",
"Container Spec": "Spécifications des conteneurs",
- "Container": "Conteneur",
"Ephemeral Containers": "",
+ "Container": "Conteneur",
"Config Maps": "Config Maps",
"Definition": "Définition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
diff --git a/frontend/src/i18n/locales/pt/glossary.json b/frontend/src/i18n/locales/pt/glossary.json
index d1291864ed..a893765eeb 100644
--- a/frontend/src/i18n/locales/pt/glossary.json
+++ b/frontend/src/i18n/locales/pt/glossary.json
@@ -23,8 +23,8 @@
"Volume Mounts": "Montagem de Volumes",
"Containers": "Containers",
"Container Spec": "Espec. de \"Container\"",
- "Container": "Container",
"Ephemeral Containers": "",
+ "Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definição",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
diff --git a/frontend/src/lib/k8s/pod.ts b/frontend/src/lib/k8s/pod.ts
index 977d4f2880..e8956b9a66 100644
--- a/frontend/src/lib/k8s/pod.ts
+++ b/frontend/src/lib/k8s/pod.ts
@@ -28,6 +28,7 @@ export interface KubePod extends KubeObjectInterface {
conditions: KubeCondition[];
containerStatuses: KubeContainerStatus[];
initContainerStatuses?: KubeContainerStatus[];
+ ephemeralContainerStatuses?: KubeContainerStatus[];
hostIP: string;
message?: string;
phase: string;