Skip to content

Prune from JVM hook if Ryuk is disabled#4960

Merged
bsideup merged 3 commits intomasterfrom
prune_if_no_ryuk
Jan 31, 2022
Merged

Prune from JVM hook if Ryuk is disabled#4960
bsideup merged 3 commits intomasterfrom
prune_if_no_ryuk

Conversation

@bsideup
Copy link
Copy Markdown
Member

@bsideup bsideup commented Jan 28, 2022

a.k.a. Poor Man's Ryuk :D

a.k.a. Poor Man's Ryuk :D
@bsideup bsideup added this to the next milestone Jan 28, 2022
@bsideup bsideup requested review from kiview and rnorth as code owners January 28, 2022 21:02
.exec();

containers.parallelStream().forEach(container -> {
stopContainer(container.getId(), container.getImage());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if the stopContainer method name has become misleading and should be renamed. When I read this, my first thought was that this overall switch construct would stop containers but not explicitly remove them.

Copy link
Copy Markdown
Member

@kiview kiview Jan 31, 2022

Choose a reason for hiding this comment

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

stop behaves like this for a long time (since forever?) of course (and differentiates from the semantics of Docker's container stop). So while I was always in favor of aligning our domain language to the Docker one, by now this would a such a breaking change of semantics in our API, I am unsure how to easily deliver it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

stopContainer specifically is a private method, and IIRC is only called by this and a stopAndRemove (public) method.

So maybe more do-able?

(+100 for aliging to docker's domain language)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Happy to add it to the scope - do you have naming recommendations? reapContainer? :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rnorth Ok you are right, I was mixing it up with our public stop() method, which will call stopAndRemoveContainer (which I consider confusing but hard to change).

@bsideup WDTY about just removeContainer, since this would be aligned with the methods for other Docker resources?

  public synchronized void performCleanup() {
      registeredContainers.forEach(this::stopContainer);
      registeredNetworks.forEach(this::removeNetwork);
      registeredImages.forEach(this::removeImage);
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sounds good to me 👍

Comment thread core/src/main/java/org/testcontainers/DockerClientFactory.java Outdated
Copy link
Copy Markdown
Member

@rnorth rnorth left a comment

Choose a reason for hiding this comment

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

Only left some superficial comments - LGTM overall.

@bsideup bsideup requested review from kiview and rnorth January 31, 2022 13:04
@bsideup bsideup merged commit 205f21c into master Jan 31, 2022
@bsideup bsideup deleted the prune_if_no_ryuk branch January 31, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants