This is an automated email from the ASF dual-hosted git repository. alexkli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit fca0acd93df2bdaaaeba43c58d153c078c239b7c Author: Alexander Klimetschek <[email protected]> AuthorDate: Tue Apr 14 11:57:44 2020 -0700 activation db agent tweaks - add hidden --disable-concurrency option to force it - shorten activation db timeout to 30 sec by default - better poll logging --- src/agentmgr.js | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/agentmgr.js b/src/agentmgr.js index 7c5ebf0..4405b8d 100644 --- a/src/agentmgr.js +++ b/src/agentmgr.js @@ -192,15 +192,21 @@ class AgentMgr { debugTask("started local ngrok proxy"); } else { - this.concurrency = await this.openwhiskSupports("concurrency"); + if (this.argv.disableConcurrency) { + this.concurrency = false; + } else { + this.concurrency = await this.openwhiskSupports("concurrency"); + if (!this.concurrency) { + console.warn("This OpenWhisk does not support action concurrency. Debugging will be a bit slower. Consider using '--ngrok' which might be a faster option."); + } + } + if (this.concurrency) { // normal fast agent using concurrent node.js actions agentName = "concurrency"; agentCode = await this.getConcurrencyAgent(); } else { - console.warn("This OpenWhisk does not support action concurrency. Debugging will be a bit slower. Consider using '--ngrok' which might be a faster option."); - agentName = "polling activation db"; agentCode = await this.getPollingActivationDbAgent(); } @@ -282,9 +288,6 @@ class AgentMgr { // the $waitForActivation agent activation will block, but only until // it times out, hence we need to retry when it fails while (this.polling) { - if (this.argv.verbose) { - process.stdout.write("."); - } try { let activation; if (this.concurrency) { @@ -297,6 +300,9 @@ class AgentMgr { blocking: true }); + if (this.argv.verbose) { + process.stdout.write("."); + } } else { // poll for the newest activation const since = Date.now(); @@ -311,10 +317,6 @@ class AgentMgr { } while (true) { - if (this.argv.verbose) { - process.stdout.write("."); - } - const activations = await this.wsk.activations.list({ name: `${name}_wskdebug_invoked`, since: since, @@ -335,11 +337,19 @@ class AgentMgr { } } + if (this.argv.verbose) { + process.stdout.write("."); + } + // need to limit load on openwhisk (activation list) await sleep(1000); } } + if (this.argv.verbose) { + process.stdout.write("."); + } + // check for successful response with a new activation if (activation && activation.response) { const params = activation.response.result; @@ -358,7 +368,7 @@ class AgentMgr { } else if (activation && activation.activationId) { // ignore this and retry. - // usually means the action did not respond within one second, + // usually means the action did not respond within one minute, // which in turn is unlikely for the agent who should exit itself // after 50 seconds, so can only happen if there was some delay // outside the action itself @@ -371,17 +381,27 @@ class AgentMgr { } catch (e) { // look for special error codes from agent const errorCode = getActivationError(e).code; - // 42 => retry if (errorCode === 42) { - // do nothing + // 42 => retry, do nothing here (except logging progress) + if (this.argv.verbose) { + process.stdout.write("."); + } + } else if (errorCode === 43) { // 43 => graceful shutdown (for unit tests) console.log("Graceful shutdown requested by agent (only for unit tests)"); return null; + } else if (e.statusCode === 503 && !this.concurrency) { + // 503 => openwhisk activation DB likely overloaded with requests, warn, wait a bit and retry + + if (this.argv.verbose) { + console.log("x"); + } console.warn("Server responded with 503 while looking for new activation records. Consider using --ngrok option.") - // can be server is overloaded with activation list requests, wait a bit extra and retry - sleep(1000); + + await sleep(5000); + } else { // otherwise log error and abort console.error(); @@ -544,7 +564,7 @@ class AgentMgr { code: fs.readFileSync(file, {encoding: 'utf8'}) }, limits: { - timeout: (this.argv.agentTimeout || 300) * 1000 + timeout: (this.argv.agentTimeout || 30) * 1000 }, annotations: [ { key: "description", value: `wskdebug agent helper. temporarily installed.` }
