Skip to content

Commit

Permalink
fix(eks): kubectl get handler output includes stderr (#22658)
Browse files Browse the repository at this point in the history
The custom resource that handles kubectl requests returns standard output and standard error in the same string. This is normally okay, because we likely get _either_ a successful result with standard output, or an unsuccessful one with standard error. However, there are certain circumstances where kubectl returns a successful result with standard output _as well as_ warnings in standard error. These warnings are harmless, but because of how the custom resource is set up, it corrupts the output that gets returned. This results in integ test failure. 

These changes separate out standard output and standard error that gets returned by kubectl, and only prints the error if we mean to throw an error.

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc committed Oct 27, 2022
1 parent 7efad2e commit 66d1ed3
Show file tree
Hide file tree
Showing 353 changed files with 1,696 additions and 9,471 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-eks/lib/kubectl-handler/get/__init__.py
Expand Up @@ -75,9 +75,9 @@ def kubectl(args):
while retry > 0:
try:
cmd = [ 'kubectl', '--kubeconfig', kubeconfig ] + args
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
output = subprocess.check_output(cmd, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as exc:
output = exc.output
output = exc.output + exc.stderr
if b'i/o timeout' in output and retry > 0:
logger.info("kubectl timed out, retries left: %s" % retry)
retry = retry - 1
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-eks/package.json
Expand Up @@ -95,6 +95,7 @@
"aws-sdk": "^2.1211.0",
"cdk8s": "^2.5.28",
"cdk8s-plus-21": "^2.0.0-beta.12",
"cdk8s-plus-22": "^2.0.0-rc.158",
"jest": "^27.5.1",
"sinon": "^9.2.4"
},
Expand Down
Expand Up @@ -75,9 +75,9 @@ def kubectl(args):
while retry > 0:
try:
cmd = [ 'kubectl', '--kubeconfig', kubeconfig ] + args
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
output = subprocess.check_output(cmd, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as exc:
output = exc.output
output = exc.output + exc.stderr
if b'i/o timeout' in output and retry > 0:
logger.info("kubectl timed out, retries left: %s" % retry)
retry = retry - 1
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 66d1ed3

Please sign in to comment.