Skip to content

Commit ae774cb

Browse files
committed
K8S-659 check quotas for storage adding
1 parent 99a21a2 commit ae774cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

manifest.jps

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,20 @@ addons:
584584
type: info
585585
message: Cluster Storage is already present!
586586
- script: |
587+
const perEnv = "environment.maxnodescount", perNodeGroup = "environment.maxsamenodescount";
588+
var quotas = jelastic.billing.account.GetQuotas(perEnv + ";" + perNodeGroup).array;
589+
var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1;
590+
591+
for (var i = 0; i < quotas.length; i++){
592+
var q = quotas[i], n = toNative(q.quota.name);
593+
if (n == perEnv && ${env.nodes.length} + storageCount > q.value) {
594+
return {result:"warning", message:"Environment nodes quota is exhausted!"};
595+
}
596+
if (n == perNodeGroup && storageCount > q.value) {
597+
return {result:"warning", message:"NodeGroup nodes quota is exhausted!"};
598+
}
599+
}
600+
587601
var resp = jelastic.env.control.GetEnvInfo('${env.appid}', session),
588602
nodeGroups = [],
589603
nodeGroupsKubernetes = [],
@@ -602,8 +616,6 @@ addons:
602616
sslstate : resp.env.sslstate
603617
};
604618

605-
var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1;
606-
607619
for (var i = 0, k = resp.nodes; i < k.length; i++) {
608620
nodeGroup = String(k[i].nodeGroup);
609621
if (nodeGroups.indexOf(nodeGroup) == -1) {

0 commit comments

Comments
 (0)