in src/agentmgr.js [431:483]
async _restoreAction(isStartup) {
const copy = getActionCopyName(this.actionName);
try {
// unfortunately, openwhisk does not support a server-side "move action" API,
// otherwise the next 3 steps (read, update, delete) could be a single
// and presumably fast move operation
let original;
if (this.actionWithCode) {
// normal case during shutdown: we have the original action in memory
original = this.actionWithCode;
} else {
// the original was fetched before or was backed up in the copy
original = await this.wsk.actions.get(copy)
log.debug("restore: fetched action original from backup copy");
}
// copy the backup (copy) to the regular action
await this.wsk.actions.update({
name: this.actionName,
action: original
});
log.debug("restore: restored original action");
if (this.argv.cleanup) {
if (!isStartup) {
log.log("Removing helper actions due to --cleanup...");
}
// remove the backup
await this.wsk.actions.delete(copy);
log.debug("restore: deleted backup copy");
// remove any helpers if they exist
await deleteActionIfExists(this.wsk, `${this.actionName}_wskdebug_invoked`);
await deleteActionIfExists(this.wsk, `${this.actionName}_wskdebug_completed`);
} else if (!isStartup) {
log.log(`Following helper actions are not removed to keep shutdown fast. Remove using --cleanup if desired.`);
log.log(`- ${log.highlightColor(copy)}`);
if (!this.concurrency && !this.ngrokAgent) {
log.log("- " + log.highlightColor(`${this.actionName}_wskdebug_invoked`));
log.log("- " + log.highlightColor(`${this.actionName}_wskdebug_completed`));
}
log.log();
}
return original;
} catch (e) {
log.error("Error while restoring original action:", e);
}
}