kubeless icon indicating copy to clipboard operation
kubeless copied to clipboard

Prepare Container Args New Lines

Open kody-abe opened this issue 4 years ago • 4 comments

Is this a BUG REPORT or FEATURE REQUEST?: bug

What happened:

When the prepare container for a function that uses a url is started the kuberenetes initContainer (prepare) args incorrectly has new lines

initContainers:
  - args:
    - curl {{REDACTED_URL}}
      -L --silent --output /tmp/func.fromurl && unzip -o /tmp/func.fromurl -d /kubeless
      && cp /src/requirements.txt /kubeless
    command:
    - sh
    - -c
    image: kubeless/unzip@sha256:f162c062973cca05459834de6ed14c039d45df8cdb76097f50b028a1621b3697

Notice the new lines after the URL and after /kubeless. This issue results in the container crashing with sh: -L: not found

What you expected to happen:

The initContainer section to be similar to:

initContainers:
  - args:
    - curl {{REDACTED_URL}} -L --silent --output /tmp/func.fromurl && unzip -o /tmp/func.fromurl -d /kubeless && cp /src/requirements.txt /kubeless
    command:
    - sh
    - -c
    image: kubeless/unzip@sha256:f162c062973cca05459834de6ed14c039d45df8cdb76097f50b028a1621b3697

How to reproduce it (as minimally and precisely as possible): Create a function with a url+zip function configuration

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): 1.12.0
  • Kubeless version (use kubeless version): 1.0.4-dirty
  • Cloud provider or physical cluster: AWS (EKS)

kody-abe avatar Aug 14 '19 03:08 kody-abe

Hi @kody-abe,

I am not able to reproduce the issue with the example we have in this repository. When I create a function with an URL it resolves to:

  initContainers:
  - args:
    - curl https://github.com/kubeless/kubeless/blob/master/examples/nodejs/helloFunctions.zip?raw=true
      -L --silent --output /tmp/func.fromurl && echo 'd1f84e9f0a8ce27e7d9ce6f457126a8f92e957e5109312e7996373f658015547  /tmp/func.fromurl'
      > /tmp/func.sha256 && sha256sum -c /tmp/func.sha256 && unzip -o /tmp/func.fromurl
      -d /kubeless && cp /src/package.json /kubeless
    command:
    - sh
    - -c
    image: kubeless/unzip@sha256:4863100364496255de9bf8722a220dad7143ab277ac72435876eb8c93936e9d7

And the logs are okay:

▶ kubectl logs get-node-url-zip-7bb898755d-ttgw8 -c prepare
/tmp/func.fromurl: OK
Archive:  /tmp/func.fromurl
  inflating: /kubeless/helloget.js   
  inflating: /kubeless/hellowithdata.js  
  inflating: /kubeless/hellowithdeps.js  
  inflating: /kubeless/index.js    

Maybe the issue is that we are not quoting the URL, does your URL contain any troublesome characters like &?

andresmgot avatar Aug 14 '19 06:08 andresmgot

@andresmgot Yes it does contain a few &

kody-abe avatar Aug 14 '19 14:08 kody-abe

@andresmgot So, I have confirmed the issue is with the & - I have wrapped my url in quotes and it seems to have worked.

kody-abe avatar Aug 14 '19 18:08 kody-abe

@kody-abe you mean that you quoted the URL editing the deployment or doing something else?

andresmgot avatar Aug 19 '19 08:08 andresmgot