openwhisk-runtime-nodejs icon indicating copy to clipboard operation
openwhisk-runtime-nodejs copied to clipboard

Support tar.gz as package format, for increased compatibility with `npm pack`

Open trieloff opened this issue 7 years ago • 7 comments

As pointed out by @alexkli in this comment, it would be great to support tar.gz as an alternative package format. The main reason is that npm has a built-in pack command that creates a tar.gz file, embedding all required dependencies (but no devDependencies) and that this would eliminate the need for scripting workarounds.

trieloff avatar Dec 01 '17 08:12 trieloff

@trieloff can you open an issue in main repo https://github.com/apache/incubator-openwhisk for an enhancement request? The work needs to be done in the controller and invoker as phase1, they need to handle the payload in zip, or tgz and a way to detect it, then pass it down to the runtimes. You thinking that Adobe would be contributing this?

Then phase2 would be to modify all the runtimes that want to handle this, to also handle tgz in addition of zip, today they body has {binary: true}, but this would not describe if it's zip or tgz.

csantanapr avatar Dec 02 '17 14:12 csantanapr

Hmm - we can auto detect zip vs tgz in each of the runtimes (see https://en.wikipedia.org/wiki/List_of_file_signatures). The expected first bytes for a zip/jar file are 50 4b 03 04 and for a tgz are 1f 8b. So I'd prefer to just keep this out of the controller/schema.

rabbah avatar Dec 02 '17 14:12 rabbah

For reference, tgz support isn't particularly hard in the proxies: https://github.com/apache/incubator-openwhisk/pull/1166 originally had tgz.

rabbah avatar Dec 02 '17 14:12 rabbah

But controller and invoker already treats tgz as binary ?

Also we need to handle the UX either documenting which runtimes can handle the tgz and which ones not while we rolled it to all, including native docker.

But we can start small :-) with one runtime at a time and iterate.

Now what’s left contributors to come write tests and THEN implement feature in proxy :-)

csantanapr avatar Dec 02 '17 14:12 csantanapr

If controller/invoker treats binary transparently today leaving it to the runtime then I agree there is no need for changes in main/core

csantanapr avatar Dec 02 '17 14:12 csantanapr

Neither the controller or the invoker look into the binary blob beyond setting the binary bit which is detected based on the presence of base64 encoding. All the logic for interpreting the binary blob happens in the runtimes.

rabbah avatar Dec 02 '17 14:12 rabbah

used our "zip" example actions.md replacing zip with tar:

> tar zcv ex.tgz index.js node_modules package.json

> ~/projects/incubator-openwhisk-client-python/tools/cli/wsk action update ex ex.tgz --kind nodejs:6
ok: updated action ex

> wsk action invoke ex --param lines "[\"and now\", \"for something completely\", \"different\" ]" -r
{
    "padded": [
        ".......................and now",
        "......for something completely",
        ".....................different"
    ]
}

I cheated and used the python cli because rebuilding the go cli is slow for a one line change in the CLI. See #16 for proposed patch.

rabbah avatar Dec 02 '17 16:12 rabbah

done by @Luke-Roy-IBM in #235

dgrove-oss avatar May 03 '23 14:05 dgrove-oss