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

feat(termination)!: make container termination timeout configurable #2926

Merged
merged 13 commits into from
Jan 2, 2025

Conversation

moogacs
Copy link
Contributor

@moogacs moogacs commented Dec 19, 2024

What does this PR do?

  • extend Terminate() method with optional configuration for timeout configuration.
  • moved the terminationOptions under container to give the ability to make timeout, etc configurable via a functional option.
  • moved cleaning up under Terminate() function.

Why is it important?

  • Terminate() became broken with latest release version with latest release 0.34.0 Terminate() require handle for errors "is already in progress"
  • this is CleanupContainer method signature and to use it in down streams that will require many refactors because it expects testing.TB
func CleanupContainer(tb testing.TB, ctr Container, options ...TerminateOption) {

so with this change it will give the ability to configure the timeout and move the cleanup logic under termination

Related issues

a unit test added and shall be tested with all the existed pipelines

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 4ccbbb1
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/6776554a1ca1b00008abe737
😎 Deploy Preview https://deploy-preview-2926--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.

@moogacs moogacs marked this pull request as ready for review December 19, 2024 23:39
@moogacs moogacs requested a review from a team as a code owner December 19, 2024 23:39
@mdelapenya mdelapenya added feature New functionality or new behaviors on the existing one breaking change Causing compatibility issues. labels Dec 20, 2024
@moogacs moogacs changed the title feat(termination): make container termination timeout configurable feat(termination)!: make container termination timeout configurable Dec 20, 2024
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 PR, seems like a good idea, unfortunately this approach doesn't work with an interface design, see comments for details.

cleanup.go Outdated Show resolved Hide resolved
cleanup.go Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
@moogacs moogacs requested a review from stevenh December 21, 2024 16:02
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 fleshing out what this looks like, I've done a review on how it stands and will discuss with @mdelapenya in the new year the pros and cons of functional options vs require args.

modules/etcd/etcd.go Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker_test.go Outdated Show resolved Hide resolved
docker_test.go Show resolved Hide resolved
docker_test.go Show resolved Hide resolved
docker_test.go Show resolved Hide resolved
docker_test.go Outdated Show resolved Hide resolved
@moogacs
Copy link
Contributor Author

moogacs commented Dec 23, 2024

@stevenh thanks for feedback, i have address the comments. looking forward, Happy new year 😊

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 to be a pain, but looking at what you've done with this, we should actually make the fields private with methods to avoid any ambiguity as to their use by other types, see suggestion in cleanup.go.

docker.go Outdated Show resolved Hide resolved
docker_test.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
cleanup.go Outdated Show resolved Hide resolved
@moogacs moogacs requested a review from stevenh December 25, 2024 12:59
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 the updates, just a few bits I've clarified from previous suggestions, to allow us to get this over the line.

cleanup.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
docker.go Outdated Show resolved Hide resolved
@moogacs moogacs force-pushed the feat/cterminationTimeout branch from 12269a4 to 6f16fa0 Compare December 29, 2024 12:56
@moogacs moogacs requested a review from stevenh December 29, 2024 12:56
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 missed a bug in the last review

cleanup.go Outdated Show resolved Hide resolved
cleanup.go Outdated Show resolved Hide resolved
@moogacs moogacs requested a review from stevenh December 29, 2024 14:48
stevenh
stevenh previously approved these changes Dec 29, 2024
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 all your work on this, looks good to me.

@stevenh stevenh requested a review from mdelapenya December 29, 2024 19:04
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.

I'm still on PTO, being back Jan 2nd, but had time between sweets and meals to take a quick look.

Just a few comments to be addressed, other than that, will approve once resolved.

Thank you both for your time and effort here

cleanup.go Outdated Show resolved Hide resolved
cleanup.go Outdated Show resolved Hide resolved
docker_test.go Show resolved Hide resolved
cleanup.go Show resolved Hide resolved
stevenh
stevenh previously approved these changes Dec 31, 2024
mdelapenya
mdelapenya previously approved these changes Jan 2, 2025
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, approving it although I added two docs changes.

Will merge this PR right after they are addressed and the CI passes 🤞

Thank you for your work here 🙇

docs/features/garbage_collector.md Outdated Show resolved Hide resolved
docs/features/garbage_collector.md Show resolved Hide resolved
@mdelapenya mdelapenya merged commit 6f718ee into testcontainers:main Jan 2, 2025
21 of 22 checks passed
@mdelapenya
Copy link
Member

Merged, thank you @moogacs and @stevenh for your time reviewing this PR

mdelapenya added a commit that referenced this pull request Jan 2, 2025
* main:
  chore(deps): bump sonarsource/sonarcloud-github-action (#2933)
  feat(termination)!: make container termination timeout configurable (#2926)
  chore(deps): bump slackapi/slack-github-action from 1.26.0 to 2.0.0 (#2934)
  chore(deps): bump github/codeql-action from 3.25.15 to 3.28.0 (#2932)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Causing compatibility issues. feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: response from daemon: removal of container x is already in progress on calling Terminate()
3 participants