Skip to content

Commit

Permalink
K8S-659 check quotas for storage adding
Browse files Browse the repository at this point in the history
  • Loading branch information
dfateyev committed Dec 6, 2021
1 parent c091f9a commit 570f8ee
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions manifest.jps
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
Expand All @@ -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) {
Expand Down

0 comments on commit 570f8ee

Please sign in to comment.