Skip to content

Commit 66d1ed3

Browse files
authored
fix(eks): kubectl get handler output includes stderr (#22658)
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*
1 parent 7efad2e commit 66d1ed3

File tree

353 files changed

+1696
-9471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+1696
-9471
lines changed

packages/@aws-cdk/aws-eks/lib/kubectl-handler/get/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def kubectl(args):
7575
while retry > 0:
7676
try:
7777
cmd = [ 'kubectl', '--kubeconfig', kubeconfig ] + args
78-
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
78+
output = subprocess.check_output(cmd, stderr=subprocess.PIPE)
7979
except subprocess.CalledProcessError as exc:
80-
output = exc.output
80+
output = exc.output + exc.stderr
8181
if b'i/o timeout' in output and retry > 0:
8282
logger.info("kubectl timed out, retries left: %s" % retry)
8383
retry = retry - 1

packages/@aws-cdk/aws-eks/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"aws-sdk": "^2.1211.0",
9696
"cdk8s": "^2.5.28",
9797
"cdk8s-plus-21": "^2.0.0-beta.12",
98+
"cdk8s-plus-22": "^2.0.0-rc.158",
9899
"jest": "^27.5.1",
99100
"sinon": "^9.2.4"
100101
},
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def kubectl(args):
7575
while retry > 0:
7676
try:
7777
cmd = [ 'kubectl', '--kubeconfig', kubeconfig ] + args
78-
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
78+
output = subprocess.check_output(cmd, stderr=subprocess.PIPE)
7979
except subprocess.CalledProcessError as exc:
80-
output = exc.output
80+
output = exc.output + exc.stderr
8181
if b'i/o timeout' in output and retry > 0:
8282
logger.info("kubectl timed out, retries left: %s" % retry)
8383
retry = retry - 1

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2c98a634e36e3f2a1c1a78958953ed173e2c6cf8446c15dabbef67d4e30b33d6/index.js

-58
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/__entrypoint__.js

-118
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/consts.d.ts

-13
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/consts.js

-3
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/consts.ts

-14
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/index.d.ts

-8
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/index.js

-32
This file was deleted.

packages/@aws-cdk/aws-eks/test/alb-controller.integ.snapshot/asset.2e7c728134413d1ae7e15a07f641cbe8df88e0260e1a11a26305b89cb2fd5eb2/index.ts

-33
This file was deleted.

0 commit comments

Comments
 (0)