From 9300603777ff3da4cd15d35a1d73cfb2471ab2bb Mon Sep 17 00:00:00 2001 From: Anthony Lapenna Date: Mon, 31 Aug 2020 17:21:25 +1200 Subject: [PATCH] fix(k8s/applications): fix an issue with daemonset in 0/0 state (#4288) --- .../containersDatatable.html | 4 ++-- app/kubernetes/helpers/application/index.js | 20 +++++++++---------- .../edit/applicationController.js | 4 ++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/kubernetes/components/datatables/application/containers-datatable/containersDatatable.html b/app/kubernetes/components/datatables/application/containers-datatable/containersDatatable.html index 6b5b1b361..8c291971d 100644 --- a/app/kubernetes/components/datatables/application/containers-datatable/containersDatatable.html +++ b/app/kubernetes/components/datatables/application/containers-datatable/containersDatatable.html @@ -130,10 +130,10 @@ - Loading... + Loading... - No pod available. + No pod available. diff --git a/app/kubernetes/helpers/application/index.js b/app/kubernetes/helpers/application/index.js index 8a1e75336..9bc898fca 100644 --- a/app/kubernetes/helpers/application/index.js +++ b/app/kubernetes/helpers/application/index.js @@ -3,14 +3,14 @@ import { KubernetesPortMapping, KubernetesPortMappingPort } from 'Kubernetes/mod import { KubernetesServiceTypes } from 'Kubernetes/models/service/models'; import { KubernetesConfigurationTypes } from 'Kubernetes/models/configuration/models'; import { - KubernetesApplicationConfigurationFormValueOverridenKeyTypes, - KubernetesApplicationEnvironmentVariableFormValue, + KubernetesApplicationAutoScalerFormValue, KubernetesApplicationConfigurationFormValue, KubernetesApplicationConfigurationFormValueOverridenKey, + KubernetesApplicationConfigurationFormValueOverridenKeyTypes, + KubernetesApplicationEnvironmentVariableFormValue, KubernetesApplicationPersistedFolderFormValue, - KubernetesApplicationPublishedPortFormValue, - KubernetesApplicationAutoScalerFormValue, KubernetesApplicationPlacementFormValue, + KubernetesApplicationPublishedPortFormValue, } from 'Kubernetes/models/application/formValues'; import { KubernetesApplicationEnvConfigMapPayload, @@ -23,13 +23,13 @@ import { KubernetesApplicationVolumeSecretPayload, } from 'Kubernetes/models/application/payloads'; import KubernetesVolumeHelper from 'Kubernetes/helpers/volumeHelper'; -import { KubernetesApplicationPlacementTypes, KubernetesApplicationDeploymentTypes } from 'Kubernetes/models/application/models'; -import { KubernetesPodNodeAffinityNodeSelectorRequirementOperators, KubernetesPodAffinity } from 'Kubernetes/pod/models'; +import { KubernetesApplicationDeploymentTypes, KubernetesApplicationPlacementTypes } from 'Kubernetes/models/application/models'; +import { KubernetesPodAffinity, KubernetesPodNodeAffinityNodeSelectorRequirementOperators } from 'Kubernetes/pod/models'; import { - KubernetesNodeSelectorTermPayload, - KubernetesPreferredSchedulingTermPayload, - KubernetesPodNodeAffinityPayload, KubernetesNodeSelectorRequirementPayload, + KubernetesNodeSelectorTermPayload, + KubernetesPodNodeAffinityPayload, + KubernetesPreferredSchedulingTermPayload, } from 'Kubernetes/pod/payloads/affinities'; class KubernetesApplicationHelper { @@ -65,7 +65,7 @@ class KubernetesApplicationHelper { } static associateContainersAndApplication(app) { - if (!app.Pods) { + if (!app.Pods || app.Pods.length === 0) { return []; } const containers = app.Pods[0].Containers; diff --git a/app/kubernetes/views/applications/edit/applicationController.js b/app/kubernetes/views/applications/edit/applicationController.js index c784540ca..b3304df8c 100644 --- a/app/kubernetes/views/applications/edit/applicationController.js +++ b/app/kubernetes/views/applications/edit/applicationController.js @@ -40,6 +40,10 @@ function computeTolerations(nodes, application) { // Some operators require empty "values" field, some only one element in "values" field, etc function computeAffinities(nodes, application) { + if (!application.Pods || application.Pods.length === 0) { + return nodes; + } + const pod = application.Pods[0]; _.forEach(nodes, (n) => { if (pod.NodeSelector) {