Skip to content

Commit e1c0760

Browse files
author
Slava Katiukha
committed
K8S-529 new add-ons creation during the upgrade
1 parent a1ec707 commit e1c0760

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
@@ -174,7 +174,7 @@ actions:
174174
script: |
175175
function deepCopy(obj) { return toNative(new org.json.JSONObject(String(obj))); }
176176
function applyIf(obj, config) { for (var prop in config) { if (typeof obj[prop] == "undefined" || obj[prop] == null) { obj[prop] = config[prop]; } } return obj; }
177-
function schedule(jps, batch, settings) { batch.methods.push({ m : { script: "Install", params: { envName: envName, nodeGroup: nodeGroup, jps: jps, settings: settings || {}, skipEmail: true, tracked: false } } }); }
177+
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 } } }); }
178178
function buildAddon(jps, parent, install) {
179179
var globals = deepCopy(jps.globals || {}); jps.globals = applyIf(globals, deepCopy(parent.globals));
180180
var actions = deepCopy(jps.actions || {}); jps.actions = applyIf(actions, deepCopy(parent.actions));
@@ -186,7 +186,7 @@ actions:
186186
resp = resp.response || resp;
187187
if (resp.result != 0) return resp;
188188

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

191191
try {
192192
newJps = toNative(new org.yaml.snakeyaml.Yaml().load(new com.hivext.api.core.utils.Transport().get(manifestUrl)));
@@ -207,35 +207,33 @@ actions:
207207
for (var i = 0, n = apps.length; i < n; i++) {
208208
var app = apps[i], jps;
209209

210-
if (!app.isInstalled) continue;
210+
if (!app.isInstalled) continue;
211211
app.settings.data = app.settings.data || {};
212212
app.settings.data.version = version;
213213

214214
if (app.app_id == "kubernetes" || app.app_id == "kubernetes-release") {
215215
mainApp[app.app_id] = { jps: newJps, data: app.settings.data };
216216
} else {
217217
jps = newAddons[app.app_id];
218-
nodeGroup = "k8sm";
219218

220219
if (jps) {
221220
jps = buildAddon(jps, newJps);
222221
delete newAddons[app.app_id];
222+
223+
schedule(jps, batch, app.settings.data, mainGroup);
223224
} else {
224225
resp = api.marketplace.jps.Uninstall({ appUniqueName: app.uniqueName, force: true });
225226
if (resp.result != 0) return resp;
226227
}
227228
}
228-
229-
if (jps) schedule(jps, batch, app.settings.data);
230229
}
231230

232231
if (mainApp) {
233232
mainApp = mainApp["kubernetes-release"] || mainApp.kubernetes;
234-
nodeGroup = "";
235233
schedule(mainApp.jps, batch, mainApp.data);
236234
} else return { result: com.hivext.api.Response.OBJECT_FORMAT_ERROR, error: "Kubernetes manifest is not found!", data: ex};
237235

238-
for (var appId in newAddons) schedule(buildAddon(newAddons[appId], newJps, true), batch);
236+
for (var appId in newAddons) schedule(buildAddon(newAddons[appId], newJps, true), batch, null, mainGroup);
239237

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

0 commit comments

Comments
 (0)