Skip to content

Commit 46ab23f

Browse files
committed
K8S-659 check quotas for storage adding
1 parent 2386a9a commit 46ab23f

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
@@ -575,6 +575,20 @@ addons:
575575
type: info
576576
message: Cluster Storage is already present!
577577
- script: |
578+
const perEnv = "environment.maxnodescount", perNodeGroup = "environment.maxsamenodescount";
579+
var quotas = jelastic.billing.account.GetQuotas(perEnv + ";" + perNodeGroup).array;
580+
var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1;
581+
582+
for (var i = 0; i < quotas.length; i++){
583+
var q = quotas[i], n = toNative(q.quota.name);
584+
if (n == perEnv && ${env.nodes.length} + storageCount > q.value) {
585+
return {result:"warning", message:"Environment nodes quota is exhausted!"};
586+
}
587+
if (n == perNodeGroup && storageCount > q.value) {
588+
return {result:"warning", message:"NodeGroup nodes quota is exhausted!"};
589+
}
590+
}
591+
578592
var resp = jelastic.env.control.GetEnvInfo('${env.appid}', session),
579593
nodeGroups = [],
580594
nodeGroupsKubernetes = [],
@@ -593,8 +607,6 @@ addons:
593607
sslstate : resp.env.sslstate
594608
};
595609

596-
var storageCount = ${nodes.k8sm.length} > 1 ? 3 : 1;
597-
598610
for (var i = 0, k = resp.nodes; i < k.length; i++) {
599611
nodeGroup = String(k[i].nodeGroup);
600612
if (nodeGroups.indexOf(nodeGroup) == -1) {

0 commit comments

Comments
 (0)