godaddy / godaddy/kubernetes-client

stdout is null when running from AWS Lambda

Open
#490 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
963
Forks
189
PR merge metrics
No merged PRs in 30d

Description

I am running into issues when running the client from within an AWS Lambda function. I get a

> Failed to run cmd.

exception, which happens on line 44 of ```kubernetes-client/lib/auth-providers/cmd.js```

I have monkey patched the code and printed the exception accordingly. It turned out that line 42 was failing, because ```stdout``` is null when trying to JSON.parse it.
The offending line is:
```result = JSON.parse(output.stdout.toString('utf8'));```

Somehow Lambda is not populating (or is intentionally blocking) ```stdout```.

My code is like this:

```
const client = new Client({
config: config.fromKubeconfig('/tmp/config.dev'),
version: '1.12',
});
```

It runs just fine both locally and in Cloud9. It only fails in Lambda.

I am not sure this is something that can be fixed since, apparently, Lambda is the one blocking things but I wanted to bring it up anyways since it may affect others trying to achieve the same thing as me in the future.

So, long story short, does anyone know why ```stdout``` is gone when running inside Lambda? If yes, is there anything we can do to work around it?

If somebody tells me how to fix it I can create a PR myself, but as of right now I have no clue where to start.

For reference only, here's how the object (partially) looks like in Cloud9:

![image](https://user-images.githubusercontent.com/3764756/58888729-243ca680-86e8-11e9-96c1-81f2fb2da52a.png)

And this is the same object (partially) in Lambda:

![image](https://user-images.githubusercontent.com/3764756/58888981-7bdb1200-86e8-11e9-93dc-9906f34e3d1c.png)

Contributor guide

Open the contributing guide

Research direction

Start in kubernetes-client/lib/auth-providers/cmd.js, especially lines 42-44, and inspect how the command result differs between Cloud9 and AWS Lambda. Reproduce the null stdout case in Lambda and determine the expected behavior before changing the handling. Done means the client no longer fails unexpectedly when Lambda returns this result, with coverage for the affected path if the repository has a suitable test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, kubernetes, nodejs
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.