From 570f8ee859795a096ac1495e86699ea1b9666f8a Mon Sep 17 00:00:00 2001 From: Denis Fateyev Date: Sun, 5 Dec 2021 01:48:00 +0600 Subject: [PATCH] K8S-659 check quotas for storage adding --- manifest.jps | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/manifest.jps b/manifest.jps index 185e7e4e..1132bb55 100644 --- a/manifest.jps +++ b/manifest.jps @@ -575,6 +575,20 @@ addons: type: info message: Cluster Storage is already present! - script: | + const perEnv = "environment.maxnodescount", perNodeGroup = "environment.maxsamenodescount"; + var quotas = jelastic.billing.account.GetQuotas(perEnv + ";" + perNodeGroup).array; + var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1; + + for (var i = 0; i < quotas.length; i++){ + var q = quotas[i], n = toNative(q.quota.name); + if (n == perEnv && ${env.nodes.length} + storageCount > q.value) { + return {result:"warning", message:"Environment nodes quota is exhausted!"}; + } + if (n == perNodeGroup && storageCount > q.value) { + return {result:"warning", message:"NodeGroup nodes quota is exhausted!"}; + } + } + var resp = jelastic.env.control.GetEnvInfo('${env.appid}', session), nodeGroups = [], nodeGroupsKubernetes = [], @@ -593,8 +607,6 @@ addons: sslstate : resp.env.sslstate }; - var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1; - for (var i = 0, k = resp.nodes; i < k.length; i++) { nodeGroup = String(k[i].nodeGroup); if (nodeGroups.indexOf(nodeGroup) == -1) {