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: handle 127 error code for podman compatibility #2778

Merged

Conversation

vchandela
Copy link
Contributor

@vchandela vchandela commented Sep 12, 2024

What does this PR do?

Why is it important?

  • Docker has a bug where it overrides exit code = 127 with exit code = 126. However, Podman handles these error codes separately.
  • While testing etcd module, my container was returning exit code = 127 on Podman. test-containers.go didn't know what to do with 127 error code as it follows the moby project so, it was stuck in an infinite loop.
  • Although, the container was up but the code was panicking.

Related issues

How to test this PR

  • Output for podman exec -ti <containerid> /bin/sh -c "echo test"; echo $?
podman exec -ti 3604e691a9efbaa916bdeaa365f7481a04aca79722c430d3cc285b671215cfec /bin/sh -c "echo test"; echo $?
Error: crun: executable file `/bin/sh` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
127

@vchandela vchandela requested a review from a team as a code owner September 12, 2024 14:34
Copy link

netlify bot commented Sep 12, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit d76ecc1
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66eaf10c0ef23a0008a9cf78
😎 Deploy Preview https://deploy-preview-2778--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

wait/host_port.go Outdated Show resolved Hide resolved
@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from fe93655 to 9a6847f Compare September 12, 2024 14:58
Copy link
Collaborator

@stevenh stevenh 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 these improvements, some more suggestions

wait/host_port.go Outdated Show resolved Hide resolved
wait/host_port.go Outdated Show resolved Hide resolved
wait/host_port.go Outdated Show resolved Hide resolved
wait/host_port.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

Looking good, we just need to handle the new error on return from the internalCheck function and we should be good

@vchandela
Copy link
Contributor Author

Looking good, we just need to handle the new error on return from the internalCheck function and we should be good

do we also need to write a test in host_port_test.go for exitCode = 127?

@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from d3f2a75 to dca8e0f Compare September 13, 2024 02:10
@mdelapenya
Copy link
Member

do we also need to write a test in host_port_test.go for exitCode = 127?

Yes please, once added, I think this PR is good to merge, thanks!

wait/host_port_test.go Outdated Show resolved Hide resolved
wait/host_port_test.go Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
@kiview
Copy link
Member

kiview commented Sep 13, 2024

Just to double check, if moby/moby#45795 would get fixed in the upstream, this PR would still be valid, correct?

@stevenh
Copy link
Collaborator

stevenh commented Sep 13, 2024

Just to double check, if moby/moby#45795 would get fixed in the upstream, this PR would still be valid, correct?

Technically it should only check 127, as 126 is an access issue which should not happen for /bin/sh so it could hide an issue if for some reason /bin has the wrong permissions preventing the internal check from being successful.

That said we would likely want this for compatibility with older versions of docker which have the issue as people won't upgrade instantly even if it is fixed.

@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from 70dc8d7 to 36a4e89 Compare September 14, 2024 06:26
Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

Sorry I think there was a miss understanding about my comment to use require, the intent was only for the new test, not to do it globally, which while desired could cause a lot of conflicts with other PRs that are currently in flight.

docker_files_test.go Outdated Show resolved Hide resolved
@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from a58712d to d967bfd Compare September 15, 2024 04:19
wait/host_port.go Outdated Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
wait/host_port_test.go Outdated Show resolved Hide resolved
@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch 2 times, most recently from 5ff9e57 to c3cccd4 Compare September 18, 2024 09:48
@mdelapenya
Copy link
Member

@vchandela can you run make lint so that all files are gofumpt-ed? 🙏

@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from c3cccd4 to d7c1fd7 Compare September 18, 2024 15:25
@vchandela
Copy link
Contributor Author

@vchandela can you run make lint so that all files are gofumpt-ed? 🙏

Done. Thanks for pointing out.

@vchandela vchandela force-pushed the vchandela-handle-127-error-code branch from d7c1fd7 to d76ecc1 Compare September 18, 2024 15:26
Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you for all your effort on the back and forward on this most appreciated.

@stevenh
Copy link
Collaborator

stevenh commented Sep 18, 2024

@vchandela can you check into the CI failures to make sure they aren't fall out from this.

@vchandela
Copy link
Contributor Author

@vchandela can you check into the CI failures to make sure they aren't fall out from this.

They seem unrelated to this PR. One is for K3s and another is for rabbitmq.

Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdelapenya mdelapenya merged commit 069f724 into testcontainers:main Sep 18, 2024
112 checks passed
mdelapenya added a commit that referenced this pull request Sep 20, 2024
* main:
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 23, 2024
* main:
  chore: use a much smaller image for testing (testcontainers#2795)
  fix: parallel containers clean race (testcontainers#2790)
  fix(registry): wait for (testcontainers#2793)
  fix: container timeout test (testcontainers#2792)
  docs: document redpanda options (testcontainers#2789)
  feat: support databend module (testcontainers#2779)
  chore: golangci-lint 1.61.0 (testcontainers#2787)
  fix(mssql): bump Docker image version (testcontainers#2786)
  fix: handle 127 error code for podman compatibility (testcontainers#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (testcontainers#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (testcontainers#2777)
  fix(postgres): Apply default snapshot name if no name specified (testcontainers#2783)
  fix: resource clean up for tests and examples (testcontainers#2738)
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 23, 2024
* main:
  chore: use a much smaller image for testing (testcontainers#2795)
  fix: parallel containers clean race (testcontainers#2790)
  fix(registry): wait for (testcontainers#2793)
  fix: container timeout test (testcontainers#2792)
  docs: document redpanda options (testcontainers#2789)
  feat: support databend module (testcontainers#2779)
  chore: golangci-lint 1.61.0 (testcontainers#2787)
  fix(mssql): bump Docker image version (testcontainers#2786)
  fix: handle 127 error code for podman compatibility (testcontainers#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (testcontainers#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (testcontainers#2777)
  fix(postgres): Apply default snapshot name if no name specified (testcontainers#2783)
  fix: resource clean up for tests and examples (testcontainers#2738)
mdelapenya added a commit that referenced this pull request Sep 26, 2024
* main: (29 commits)
  fix: template for code generation (#2800)
  fix: update module path (#2797)
  fix: container logging deadlocks (#2791)
  chore: use a much smaller image for testing (#2795)
  fix: parallel containers clean race (#2790)
  fix(registry): wait for (#2793)
  fix: container timeout test (#2792)
  docs: document redpanda options (#2789)
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
  fix: resource clean up for tests and examples (#2738)
  ci: add generate for mocks (#2774)
  fix: docker config error handling when config file does not exist (#2772)
  docs: refine heading badges in README (#2770)
  feat(wait): for file (#2731)
  ...
@mdelapenya mdelapenya self-assigned this Oct 1, 2024
@mdelapenya mdelapenya added the bug An issue with the library label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants