Skip to content

Commit 733e2e7

Browse files
committed
K8S-659 check quotas for storage adding
1 parent 76b2a7e commit 733e2e7

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
@@ -583,6 +583,20 @@ addons:
583583
type: info
584584
message: Cluster Storage is already present!
585585
- script: |
586+
const perEnv = "environment.maxnodescount", perNodeGroup = "environment.maxsamenodescount";
587+
var quotas = jelastic.billing.account.GetQuotas(perEnv + ";" + perNodeGroup).array;
588+
var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1;
589+
590+
for (var i = 0; i < quotas.length; i++){
591+
var q = quotas[i], n = toNative(q.quota.name);
592+
if (n == perEnv && ${env.nodes.length} + storageCount > q.value) {
593+
return {result:"warning", message:"Environment nodes quota is exhausted!"};
594+
}
595+
if (n == perNodeGroup && storageCount > q.value) {
596+
return {result:"warning", message:"NodeGroup nodes quota is exhausted!"};
597+
}
598+
}
599+
586600
var resp = jelastic.env.control.GetEnvInfo('${env.appid}', session),
587601
nodeGroups = [],
588602
nodeGroupsKubernetes = [],
@@ -601,8 +615,6 @@ addons:
601615
sslstate : resp.env.sslstate
602616
};
603617

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

0 commit comments

Comments
 (0)