From 7f089fab8629b2fe8a447feb22e06b8386d44a01 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Wed, 22 Jan 2025 12:31:27 +1300 Subject: [PATCH] fix(apps): use replicas from application spec [r8s-142] (#335) --- app/kubernetes/converters/configuration.js | 11 +++++++++-- app/react/kubernetes/applications/utils.ts | 5 ++--- .../kubernetes/volumes/ListView/VolumesDatatable.tsx | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/kubernetes/converters/configuration.js b/app/kubernetes/converters/configuration.js index 076b3437d..281fb07c4 100644 --- a/app/kubernetes/converters/configuration.js +++ b/app/kubernetes/converters/configuration.js @@ -19,8 +19,15 @@ class KubernetesConfigurationConverter { res.IsRegistrySecret = secret.IsRegistrySecret; res.SecretType = secret.SecretType; if (secret.Annotations) { - const serviceAccountAnnotation = secret.Annotations.find((a) => a.key === 'kubernetes.io/service-account.name'); - res.ServiceAccountName = serviceAccountAnnotation ? serviceAccountAnnotation.value : undefined; + const serviceAccountKey = 'kubernetes.io/service-account.name'; + if (typeof secret.Annotations === 'object') { + res.ServiceAccountName = secret.Annotations[serviceAccountKey]; + } else if (Array.isArray(secret.Annotations)) { + const serviceAccountAnnotation = secret.Annotations.find((a) => a.key === 'kubernetes.io/service-account.name'); + res.ServiceAccountName = serviceAccountAnnotation ? serviceAccountAnnotation.value : undefined; + } else { + res.ServiceAccountName = undefined; + } } res.Labels = secret.Labels; return res; diff --git a/app/react/kubernetes/applications/utils.ts b/app/react/kubernetes/applications/utils.ts index aa6a32ef5..d705e75c1 100644 --- a/app/react/kubernetes/applications/utils.ts +++ b/app/react/kubernetes/applications/utils.ts @@ -69,11 +69,10 @@ export function getTotalPods( ): number { switch (application.kind) { case 'Deployment': - return application.status?.replicas ?? 0; + case 'StatefulSet': + return application.spec?.replicas ?? 0; case 'DaemonSet': return application.status?.desiredNumberScheduled ?? 0; - case 'StatefulSet': - return application.status?.replicas ?? 0; default: throw new Error('Unknown application type'); } diff --git a/app/react/kubernetes/volumes/ListView/VolumesDatatable.tsx b/app/react/kubernetes/volumes/ListView/VolumesDatatable.tsx index f6c5c2956..b81f60e9a 100644 --- a/app/react/kubernetes/volumes/ListView/VolumesDatatable.tsx +++ b/app/react/kubernetes/volumes/ListView/VolumesDatatable.tsx @@ -64,7 +64,9 @@ export function VolumesDatatable() { settingsManager={tableState} title="Volumes" titleIcon={Database} - getRowId={(row) => row.PersistentVolumeClaim.Name} + getRowId={(row) => + `${row.PersistentVolumeClaim.Name}-${row.ResourcePool.Namespace.Name}` + } disableSelect={!hasWriteAuth} isRowSelectable={({ original: volume }) => !isSystemNamespace(volume.ResourcePool.Namespace.Name, namespaces) &&