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

fix: Parse command output without using shell pipelines #369

Merged
merged 3 commits into from
Jun 1, 2022

Conversation

dlipovetsky
Copy link
Collaborator

@dlipovetsky dlipovetsky commented May 31, 2022

What problem does this PR solve?:
Errors are not being caught when the shell module executes a pipeline. For example, see #367 (comment)

It's possible to catch errors by using the pipefail shell option, but only if the shell supports it. In every case where we use a pipeline, we use it to parse command output. Instead of catching errors, we can just stop using pipelines.

Which issue(s) does this PR fix?:

Special notes for your reviewer:

The e2e tests fail, as expected. They will pass once #367 is merged. Merged.

Does this PR introduce a user-facing change?:


@github-actions
Copy link
Contributor

github-actions bot commented May 31, 2022

File Coverage
All files 16%
pkg/ansible/runner.go 0%
pkg/app/artifacts.go 0%
pkg/app/build.go 1%
pkg/app/build_azure.go 0%
pkg/app/build_gcp.go 0%
pkg/app/config.go 47%
pkg/app/errors.go 0%
pkg/app/provision.go 0%
pkg/app/root.go 0%
pkg/app/validate.go 0%
pkg/appansible/io.go 0%
pkg/appansible/playbook.go 0%
pkg/azure/azure.go 0%
pkg/logging/logger.go 0%
pkg/packer/manifest.go 0%
pkg/packer/packer.go 0%
pkg/stringutil/rand.go 0%
pkg/version/info.go 8%

Minimum allowed coverage is 75%

Generated by 🐒 cobertura-action against d7467a1

@github-actions github-actions bot added fix and removed fix labels May 31, 2022
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch from daffba7 to 010dc61 Compare May 31, 2022 19:09
@dlipovetsky
Copy link
Collaborator Author

dlipovetsky commented May 31, 2022

After #367 merged, I rebased on main and force-pushed. The e2e tests should now pass.

Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

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

Thanks for fixing all tasks

@dlipovetsky
Copy link
Collaborator Author

Ubuntu 18.04 and 20.04 tests are failing apparently because /bin/sh is not bash, and set -o pipefail is unrecognized. Will fix.

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch from 010dc61 to 7f6a328 Compare June 1, 2022 00:34
@dlipovetsky
Copy link
Collaborator Author

Ubuntu 18.04 and 20.04 tests are failing apparently because /bin/sh is not bash, and set -o pipefail is unrecognized. Will fix.

I tried to fix this by relying on /usr/bin/env bash, but that proved tricky to do. So instead I went all-in on the "native" parsing approach introduced recently by @faiq.

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch 3 times, most recently from d538a8f to cbdbd59 Compare June 1, 2022 06:47
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch from cbdbd59 to 330a4c7 Compare June 1, 2022 15:52
@dlipovetsky
Copy link
Collaborator Author

Sadly and unexpectedly, the cli_parse module didn't work for my needs, and its errors were inscrutable. So I went with regex parsing.

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch 3 times, most recently from b11c409 to 32c9952 Compare June 1, 2022 16:58
@dlipovetsky dlipovetsky changed the title fix: Catch errors when the shell module executes a pipeline fix: Parse command output without using shell pipelines Jun 1, 2022
@github-actions github-actions bot added fix and removed fix labels Jun 1, 2022
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch from 32c9952 to 0d23c47 Compare June 1, 2022 17:32
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/fix-shell-pipefail branch from 0d23c47 to d7467a1 Compare June 1, 2022 17:55
@faiq faiq merged commit f7b9d3e into main Jun 1, 2022
@faiq faiq deleted the dlipovetsky/fix-shell-pipefail branch June 1, 2022 19:42
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.

4 participants