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

Improve handling of unsuitable LANG settings #236

Merged
merged 2 commits into from
Mar 4, 2022
Merged

Conversation

reidmv
Copy link
Contributor

@reidmv reidmv commented Feb 25, 2022

If Ruby starts without a LANG env var, it will assume locale "C". This
is a non-UTF-8 locale, and usually not the system default. If commands
print UTF-8 characters, Ruby will fail to correctly parse them if it
wasn't started with a valid locale.

The main scenario we want to account for is when a privilege escalation
command such as sudo or powerbroker has elevated a shell, but stripped
all environment variables out of it. If that happened, we want to try
and set the default system locale, which should be in
/etc/default/locale.

If Ruby starts without a LANG env var, it will assume locale "C". This
is a non-UTF-8 locale, and usually not the system default. If commands
print UTF-8 characters, Ruby will fail to correctly parse them if it
wasn't started with a valid locale.

The main scenario we want to account for is when a privilege escalation
command such as sudo or powerbroker has elevated a shell, but stripped
all environment variables out of it. If that happened, we want to try
and set the default system locale, which should be in
/etc/default/locale.
@reidmv reidmv requested a review from a team as a code owner February 25, 2022 00:55
Bolt tasks are very difficult to debug because they hide stderr output.
This commit adds a task helper which should reveal that output.
@reidmv
Copy link
Contributor Author

reidmv commented Feb 28, 2022

Aaaaaand no failures occurred now that failures would be revealed more fully when they happen. Classic. This would seem to indicate that the failures were transient though, whatever they were.

@reidmv
Copy link
Contributor Author

reidmv commented Mar 4, 2022

This is the test suite job that failed:
https://github.com/puppetlabs/puppetlabs-peadm/runs/5327453453?check_suite_focus=true

And this is the manual re-run of that job with the new commit that passed:
https://github.com/puppetlabs/puppetlabs-peadm/runs/5337184081?check_suite_focus=true

The point of the new bash task_helper.sh script was supposed to be to return stderr and in so doing reveal what actually went wrong, but since nothing went wrong on the second run it seems like the failure might have been a transient.

I'm going to trigger the full suite again and if it passes, will merge the PR. It's not bad to have the task_helper for the future.

@reidmv reidmv requested review from a team and removed request for a team March 4, 2022 16:36
@reidmv reidmv changed the title Try to ensure LANG is valid Improve handling of unsuitable LANG settings Mar 4, 2022
@reidmv reidmv added the feature label Mar 4, 2022
@reidmv reidmv merged commit a5276a9 into main Mar 4, 2022
@reidmv reidmv deleted the puppet_runonce-lang branch March 4, 2022 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant