Skip to content

Commit a4cf22d

Browse files
author
Slava Katiukha
committed
K8S-529 new add-ons creation during the upgrade
1 parent 40ce14a commit a4cf22d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

addons/upgrade.jps

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ actions:
226226
script: |
227227
function deepCopy(obj) { return toNative(new org.json.JSONObject(String(obj))); }
228228
function applyIf(obj, config) { for (var prop in config) { if (typeof obj[prop] == "undefined" || obj[prop] == null) { obj[prop] = config[prop]; } } return obj; }
229-
function schedule(jps, batch, settings) { batch.methods.push({ m : { script: "Install", params: { envName: envName, nodeGroup: nodeGroup, jps: jps, settings: settings || {}, skipEmail: true, tracked: false } } }); }
229+
function schedule(jps, batch, settings, nodeGroup) { batch.methods.push({ m : { script: "Install", params: { envName: envName, nodeGroup: nodeGroup || "", jps: jps, settings: settings || {}, skipEmail: true, tracked: false } } }); }
230230
function buildAddon(jps, parent, install) {
231231
var globals = deepCopy(jps.globals || {}); jps.globals = applyIf(globals, deepCopy(parent.globals));
232232
var actions = deepCopy(jps.actions || {}); jps.actions = applyIf(actions, deepCopy(parent.actions));
@@ -238,7 +238,7 @@ actions:
238238
resp = resp.response || resp;
239239
if (resp.result != 0) return resp;
240240

241-
var apps = resp.apps, newAddons = {}, mainApp = {}, newJps, nodeGroup;
241+
var apps = resp.apps, newAddons = {}, mainApp = {}, mainGroup = "k8sm", newJps;
242242

243243
try {
244244
newJps = toNative(new org.yaml.snakeyaml.Yaml().load(new com.hivext.api.core.utils.Transport().get(manifestUrl)));
@@ -259,35 +259,33 @@ actions:
259259
for (var i = 0, n = apps.length; i < n; i++) {
260260
var app = apps[i], jps;
261261

262-
if (!app.isInstalled) continue;
262+
if (!app.isInstalled) continue;
263263
app.settings.data = app.settings.data || {};
264264
app.settings.data.version = version;
265265

266266
if (app.app_id == "kubernetes" || app.app_id == "kubernetes-release") {
267267
mainApp[app.app_id] = { jps: newJps, data: app.settings.data };
268268
} else {
269269
jps = newAddons[app.app_id];
270-
nodeGroup = "k8sm";
271270

272271
if (jps) {
273272
jps = buildAddon(jps, newJps);
274273
delete newAddons[app.app_id];
274+
275+
schedule(jps, batch, app.settings.data, mainGroup);
275276
} else {
276277
resp = api.marketplace.jps.Uninstall({ appUniqueName: app.uniqueName, force: true });
277278
if (resp.result != 0) return resp;
278279
}
279280
}
280-
281-
if (jps) schedule(jps, batch, app.settings.data);
282281
}
283282

284283
if (mainApp) {
285284
mainApp = mainApp["kubernetes-release"] || mainApp.kubernetes;
286-
nodeGroup = "";
287285
schedule(mainApp.jps, batch, mainApp.data);
288286
} else return { result: com.hivext.api.Response.OBJECT_FORMAT_ERROR, error: "Kubernetes manifest is not found!", data: ex};
289287

290-
for (var appId in newAddons) schedule(buildAddon(newAddons[appId], newJps, true), batch);
288+
for (var appId in newAddons) schedule(buildAddon(newAddons[appId], newJps, true), batch, null, mainGroup);
291289

292290
if (batch.methods.length > 0) {
293291
var batchResp = api.utils.batch.Call(appid, toJSON(batch), false);

0 commit comments

Comments
 (0)