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 issues in BuildImage() #2626

Merged
merged 5 commits into from
Jul 5, 2024
Merged

Conversation

ash2k
Copy link
Contributor

@ash2k ash2k commented Jul 5, 2024

What does this PR do?

Please see individual commits. The most important fixes are to not reuse the Context and to close it to release resources.

BuildOptions() calls GetContext() which calls archive.TarWithOptions() which starts a goroutine. This goroutine will be stuck until the reader is closed. So, current code leaks goroutines and open files when BuildImage() fails.

Why is it important?

Improves reliability of image building.

Related issues

ash2k added 4 commits July 5, 2024 13:49
The code already logs them so no need to return them all to the caller - the calling code will likely log them too. This will result in the same errors being logged twice. This is confusing for the user.
buildOptions.Context cannot be reused because it might have been partially consumed by the failed ImageBuild(). So, the next invocation will send a partial context, which will not work correctly.
@ash2k ash2k requested a review from a team as a code owner July 5, 2024 04:24
Copy link

netlify bot commented Jul 5, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 13d0b22
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66877705b6ec190008f6d381
😎 Deploy Preview https://deploy-preview-2626--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.

This ensures all resources are released properly.
@mdelapenya mdelapenya self-assigned this Jul 5, 2024
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Jul 5, 2024
Copy link
Collaborator

@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 306f185 into testcontainers:main Jul 5, 2024
108 checks passed
@ash2k ash2k deleted the fix-build-image branch July 5, 2024 11:21
mdelapenya added a commit that referenced this pull request Jul 15, 2024
* main:
  fix: log output after context timeout (#2643)
  chore(deps): use "github.com/containerd/platforms" instead (#2638)
  chore(deps): bump google.golang.org/grpc to 1.64.1 (#2635)
  chore(deps): bump certifi from 2024.2.2 to 2024.7.4 (#2631)
  chore: prepare for next minor development cycle (0.33.0)
  chore: use new version (v0.32.0) in modules and examples
  feat: honour go toolchain's verbose flag to print out logs (#2624)
  Fix issues in BuildImage() (#2626)
  docs: indicate version for the Run function (#2627)
  chore: remove duplicated tests for config (#2628)
  Log retried errors (#2613)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants