From 17517d75217c5f69cb701069b3267c080877bd50 Mon Sep 17 00:00:00 2001 From: Ali <83188384+testA113@users.noreply.github.com> Date: Fri, 10 Mar 2023 10:24:20 +1300 Subject: [PATCH] fix(app): restrict ns fix create app [EE-5123] (#8633) Co-authored-by: testa113 --- .../create/createApplicationController.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 34f9413dc..cc069ef80 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -1213,17 +1213,23 @@ class KubernetesCreateApplicationController { this.allNamespaces = resourcePools.map(({ Namespace }) => Namespace.Name); this.resourcePools = _.sortBy(nonSystemNamespaces, ({ Namespace }) => (Namespace.Name === 'default' ? 0 : 1)); - const namespaceWithQuota = await this.KubernetesResourcePoolService.get(this.resourcePools[0].Namespace.Name); - this.formValues.ResourcePool = this.resourcePools[0]; - this.formValues.ResourcePool.Quota = namespaceWithQuota.Quota; - if (!this.formValues.ResourcePool) { - return; - } - + // this.state.nodes.memory and this.state.nodes.cpu are used to calculate the slider limits, so set them before calling updateSliders() _.forEach(nodes, (item) => { this.state.nodes.memory += filesizeParser(item.Memory); this.state.nodes.cpu += item.CPU; }); + + if (this.resourcePools.length) { + const namespaceWithQuota = await this.KubernetesResourcePoolService.get(this.resourcePools[0].Namespace.Name); + this.formValues.ResourcePool.Quota = namespaceWithQuota.Quota; + this.updateNamespaceLimits(namespaceWithQuota); + this.updateSliders(namespaceWithQuota); + } + this.formValues.ResourcePool = this.resourcePools[0]; + if (!this.formValues.ResourcePool) { + return; + } + this.nodesLabels = KubernetesNodeHelper.generateNodeLabelsFromNodes(nodes); this.nodeNumber = nodes.length; @@ -1281,9 +1287,6 @@ class KubernetesCreateApplicationController { this.formValues.IsPublishingService = this.formValues.PublishedPorts.length > 0; this.oldFormValues = angular.copy(this.formValues); - - this.updateNamespaceLimits(namespaceWithQuota); - this.updateSliders(namespaceWithQuota); } catch (err) { this.Notifications.error('Failure', err, 'Unable to load view data'); } finally {