You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/04/14 07:53:32 UTC
[openwhisk-wskdebug] 02/09: performance: avoid reading namespace
list if not in wskprops, use from initial action GET
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 e2fd50dcf084ab52e0c4133cb359375a27213789
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Mon Apr 13 17:44:15 2020 -0700
performance: avoid reading namespace list if not in wskprops, use from initial action GET
---
src/debugger.js | 45 +++++++++++----------------------------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/src/debugger.js b/src/debugger.js
index 7343fb6..db33974 100644
--- a/src/debugger.js
+++ b/src/debugger.js
@@ -35,6 +35,7 @@ class Debugger {
constructor(argv) {
this.startTime = Date.now();
debug("starting debugger");
+
this.argv = argv;
this.actionName = argv.action;
@@ -46,11 +47,16 @@ class Debugger {
if (argv.ignoreCerts) {
this.wskProps.ignore_certs = true;
}
+
+ try {
+ this.wsk = openwhisk(this.wskProps);
+ } catch (err) {
+ console.error(`Error: Could not setup openwhisk client: ${err.message}`);
+ process.exit(1);
+ }
}
async start() {
- await this.setupWsk();
-
this.agentMgr = new AgentMgr(this.argv, this.wsk, this.actionName);
this.watcher = new Watcher(this.argv, this.wsk);
@@ -58,13 +64,13 @@ class Debugger {
await OpenWhiskInvoker.checkIfAvailable();
debug("verified that docker is available and running");
- console.info(`Starting debugger for /${this.wskProps.namespace}/${this.actionName}`);
-
// get the action metadata
const actionMetadata = await this.agentMgr.peekAction();
-
debug("fetched action metadata from openwhisk");
+ this.wskProps.namespace = actionMetadata.namespace;
+ console.info(`Starting debugger for /${this.wskProps.namespace}/${this.actionName}`);
+
// local debug container
this.invoker = new OpenWhiskInvoker(this.actionName, actionMetadata, this.argv, this.wskProps, this.wsk);
@@ -236,35 +242,6 @@ class Debugger {
this.ready = false;
}
- // ------------------------------------------------< openwhisk utils >------------------
-
- async setupWsk() {
- if (!this.wsk) {
- try {
- this.wsk = openwhisk(this.wskProps);
- } catch (err) {
- console.error(`Error: Could not setup openwhisk client: ${err.message}`);
- process.exit(1);
- }
- if (this.wskProps.namespace === undefined) {
- // there is a strict 1-1 bijection between auth and namespace, hence auth is enough.
- // while the openwhisk() client does not care about the namespace being set,
- // some code here in wskdebug relies on it to be set correctly.
- const namespaces = await this.wsk.namespaces.list();
- if (!namespaces || namespaces.length < 1) {
- console.error("Error: Unknown namespace. Please specify as NAMESPACE in .wskprops.");
- process.exit(2);
- }
- if (namespaces.length > 1) {
- console.error("Error: OpenWhisk reports access to more than one namespace. Please specify the namespace to use as NAMESPACE in .wskprops.", namespaces);
- process.exit(2);
- }
- this.wskProps.namespace = namespaces[0];
- debug(`fetched namespace name: ${this.wskProps.namespace} (was not in wskprops file)`);
- }
- }
- }
-
// ------------------------------------------------< utils >-----------------
async tryCatch(task, message="Error during shutdown:") {