Skip to content

Commit c4c683f

Browse files
authored
Update promote-master.js
1 parent 296166f commit c4c683f

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

addons/promote-new-primary-wo-proxy/scripts/promote-master.js

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ function promoteNewPrimary() {
4444
resp = this.setContainerVar();
4545
if (resp.result != 0) return resp;
4646

47-
resp = this.setNewMasterNode();
48-
if (resp.result != 0) return resp;
49-
5047
resp = this.addNode();
5148
if (resp.result != 0) return resp;
5249

@@ -117,13 +114,6 @@ function promoteNewPrimary() {
117114
return this.cmdByGroup("touch " + TMP_FILE, SQLDB, 3);
118115
};
119116

120-
this.setNewMasterNode = function() {
121-
return jelastic.dev.scripting.Eval("ext", session, "api.env.control.SetMasterNode", {
122-
envName: envName,
123-
nodeId: this.getNewPrimaryNode().id
124-
});
125-
};
126-
127117
this.setContainerVar = function() {
128118
let resp = this.setDomains();
129119
if (resp.result != 0) return resp;
@@ -365,24 +355,21 @@ function promoteNewPrimary() {
365355
if (resp.result != 0) return resp;
366356

367357
let nodes = this.getParsedNodes();
368-
369-
this.log("getParsedNodes resp->" + nodes);
370358

371359
if (nodes) {
372360
for (let i = 0, n = nodes.length; i < n; i++) {
373361
if (nodes[i]) {
374-
if (nodes[i].type == "secondary" && !alreadySetNewPrimary) {
362+
if (nodes[i].type == SECONDARY && !alreadySetNewPrimary) {
375363
this.setNewPrimaryNode(nodes[i]);
376364
alreadySetNewPrimary = true;
377-
}
378-
if (nodes[i].type == "primary" ) {
365+
} else {
379366
resp = api.env.control.SetNodeDisplayName(envName, session, nodes[i].id, PRIMARY + " - " + FAILED);
380367
if (resp.result != 0) return resp;
381368

382369
resp = this.getSQLNodeById(nodes[i].id);
383370
if (resp.result != 0) return resp;
384371

385-
if (resp.node) {
372+
if (resp.node && !resp.node.ismaster) {
386373
this.setFailedPrimary(resp.node);
387374
}
388375
}
@@ -401,24 +388,15 @@ function promoteNewPrimary() {
401388
let resp = this.cmdById(newPrimary.id, command, 20);
402389
if (resp.result != 0) return resp;
403390

404-
405-
406391
return api.env.control.SetNodeDisplayName(envName, session, newPrimary.id, PRIMARY);
407392
};
408393

409394
this.restoreNodes = function() {
410395
let nodes = this.getParsedNodes();
411-
412-
this.log("restoreNodes: getParsedNodes resp->" + nodes);
413396

414397
let newPrimary = this.getNewPrimaryNode();
415-
416-
this.log("restoreNodes: getNewPrimaryNode resp->" + newPrimary);
417398

418-
let command = "bash /tmp/db_recovery.sh --scenario restore_secondary_from_primary --donor-ip " + newPrimary.address;
419-
420-
this.log("restoreNodes: command resp->" + command);
421-
399+
let command = "/bash /tmp/db_recovery.sh --scenario restore_secondary_from_primary --donor-ip " + newPrimary.address;
422400
for (let i = 0, n = nodes.length; i < n; i++) {
423401
if (nodes[i].id != newPrimary.id && nodes[i].type == SECONDARY) {
424402
let resp = this.cmdById(nodes[i].id, command);
@@ -516,7 +494,6 @@ function promoteNewPrimary() {
516494

517495
this.removeFailedPrimary = function() {
518496
let failedPrimary = this.getFailedPrimary();
519-
this.log("diagnosticNodes Primary ->" + failedPrimary);
520497
if (failedPrimary && !failedPrimary.ismaster) {
521498
return api.env.control.RemoveNode(envName, session, failedPrimary.id);
522499
}

0 commit comments

Comments
 (0)