Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci-operator/step-registry/gather/aws-console: UTF-8 for output #19827

Merged

Conversation

wking
Copy link
Member

@wking wking commented Jun 29, 2021

In recent CI, we have failed console gathers like:

Gathering console logs for i-026ba0637214cd027
'ascii' codec can't encode character '\u2026' in position 14093: ordinal not in range(128)
Failed to gather console logs

This is descended from d060927 (#17735). But we want to gather these logs, not silently fail to gather the logs. This commit restores our old "fail the step when we fail to gather" behavior, and sets PYTHONIOENCODING to ask for UTF-8 instead of ASCII output.

In recent CI, we have failed console gathers like [1]:

  Gathering console logs for i-026ba0637214cd027
  'ascii' codec can't encode character '\u2026' in position 14093: ordinal not in range(128)
  Failed to gather console logs

This is descended from d060927 (gather/aws-console: Make log
gathering non-fatal, 2021-04-14, openshift#17735).  But we want to gather these
logs, not silently fail to gather the logs.  This commit restores our
old "fail the step when we fail to gather" behavior, and sets
PYTHONIOENCODING [2] to ask for UTF-8 instead of ASCII output.

[1]: https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/origin-ci-test/logs/periodic-ci-openshift-[…]e2e-aws-serial/gather-aws-console/build-log.txt
[2]: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2021
@openshift-ci openshift-ci bot requested review from enxebre and vrutkovs June 29, 2021 17:53
@wking
Copy link
Member Author

wking commented Jun 29, 2021

Example of the fix working:

$ AWS_PROFILE=ci PYTHONIOENCODING=ascii:strict aws --region us-east-1 ec2 get-console-output --instance-id i-024c99a8f35bdc94d --output text

'ascii' codec can't encode character '\u2026' in position 19168: ordinal not in range(128)
$ AWS_PROFILE=ci PYTHONIOENCODING=UTF-8:backslashreplace aws --region us-east-1 ec2 get-console-output --instance-id i-024c99a8f35bdc94d --output text | head -n3
i-024c99a8f35bdc94d     ated 151 pages with 5 groups
[    0.001000] rcu: Hierarchical RCU implementation.
[    0.001000] rcu:     RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=4.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the UTF-8 prominence in your commit mesage is a slight misdirection here - the real fix is backslashreplace because the ANSI color codes aren't valid UTF-8 either. But fine as is!

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 29, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wking
Copy link
Member Author

wking commented Jun 29, 2021

In the random instance I picked out of CI for testing UTF-8:strict was sufficient:

$ AWS_PROFILE=ci PYTHONIOENCODING=ascii:strict aws --region us-east-1 ec2 get-console-output --instance-id i-024c99a8f35bdc94d --output text

'ascii' codec can't encode character '\u2026' in position 19168: ordinal not in range(128)
$ AWS_PROFILE=ci PYTHONIOENCODING=UTF-8:strict aws --region us-east-1 ec2 get-console-output --instance-id i-024c99a8f35bdc94d --output text | head -n3
i-024c99a8f35bdc94d     ated 151 pages with 5 groups
[    0.001000] rcu: Hierarchical RCU implementation.
[    0.001000] rcu:     RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=4.

The only issues with that instance were U+2026 HORIZONTAL ELLIPSIS:

$ AWS_PROFILE=ci PYTHONIOENCODING=ascii:backslashreplace aws --region us-east-1 ec2 get-console-output --instance-id i-024c99a8f35bdc94d --output text | grep -o '\\u[0-9]*' | sort | uniq -c
     13 \u2026

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 29, 2021

@wking: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/rehearse/periodic-ci-openshift-release-master-nightly-4.9-e2e-aws-proxy 24b834c link /test pj-rehearse
ci/rehearse/openshift/installer/release-4.9/e2e-aws-upgrade 24b834c link /test pj-rehearse
ci/rehearse/periodic-ci-openshift-release-master-ci-4.9-upgrade-from-stable-4.8-e2e-aws-ovn-upgrade 24b834c link /test pj-rehearse
ci/rehearse/openshift/origin/release-4.1/e2e-aws-image-ecosystem 24b834c link /test pj-rehearse

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 1aefdea into openshift:master Jun 29, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 29, 2021

@wking: Updated the step-registry configmap in namespace ci at cluster app.ci using the following files:

  • key gather-aws-console-commands.sh using file ci-operator/step-registry/gather/aws-console/gather-aws-console-commands.sh

In response to this:

In recent CI, we have failed console gathers like:

Gathering console logs for i-026ba0637214cd027
'ascii' codec can't encode character '\u2026' in position 14093: ordinal not in range(128)
Failed to gather console logs

This is descended from d060927 (#17735). But we want to gather these logs, not silently fail to gather the logs. This commit restores our old "fail the step when we fail to gather" behavior, and sets PYTHONIOENCODING to ask for UTF-8 instead of ASCII output.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@wking wking deleted the gather-aws-console-encoding branch June 29, 2021 19:22
wking added a commit to wking/openshift-release that referenced this pull request Jun 30, 2021
…YTHONIOENCODING

24b834c (ci-operator/step-registry/gather/aws-console: UTF-8 for
output, 2021-06-29, openshift#19827) is not doing well in the wild.  For
example, [1]:

  INFO[2021-06-29T20:14:28Z] Gathering console logs for i-008f73fde1ef3f0dc

  'ascii' codec can't encode character '\u2026' in position 13999: ordinal not in range(128)
  {"component":"entrypoint","error":"wrapped process failed: exit status 1","file":"prow/entrypoint/run.go:80","func":"k8s.io/test-infra/prow/entrypoint.Options.Run","level":"error","msg":"Error executing test process","severity":"error","time":"2021-06-29T20:14:27Z"}
  error: failed to execute wrapped command: exit status 1

Apparently the AWS CLI is not using Python's default stream encoding
here.  But from [2,3,4] there is the suggestion that
LC_ALL=en_US.UTF-8 will help.

[1]: https://prow.ci.openshift.org/view/gs/origin-ci-test/logs/periodic-ci-openshift-release-master-ci-4.9-e2e-aws/1409949910362492928
[2]: https://awscli.amazonaws.com/v2/documentation/api/latest/topic/config-vars.html#locale
[3]: https://github.com/aws/aws-cli/blob/2.2.5/awscli/compat.py#L121-L146
[4]: https://docs.python.org/3/library/locale.html#locale.getpreferredencoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
3 participants