Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Add pre-stop hooks for containers that expose ports #2298

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

thedadams
Copy link
Contributor

This pre-stop hook will simply wait for 5 seconds. In order to achieve this in the most general way, a configmap is mounted as a volume that has a very simply binary that sleeps for 5 seconds. It is done this way because this should work for any container images, including scratch.

@thedadams thedadams force-pushed the pre-stop-hook branch 2 times, most recently from 26414ff to eb79e20 Compare October 26, 2023 17:54
@thedadams
Copy link
Contributor Author

Putting this up for review. I tested it with a scratch image and it worked. I'm still in shock.

@thedadams thedadams marked this pull request as ready for review October 26, 2023 19:06
@thedadams
Copy link
Contributor Author

thedadams commented Oct 26, 2023

https://github.com/acorn-io/manager/pull/1517 should be merged first so we can use the mirrored image. I am also open to doing something else with this image, but this seemed to be the easiest.

Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

I have done similar witchcraft before, it's always fun to see it pop up again. left a few questions.

This pre-stop hook will simply wait for 5 seconds. In order to achieve
this in the most general way, a configmap is mounted as a volume that
has a very simply binary that sleeps for 5 seconds. It is done this way
because this should work for any container images, including scratch.

Wait is not applied for stateful containers, jobs, or containers with
one replica.

Signed-off-by: Donnie Adams <donnie@acorn.io>
@thedadams
Copy link
Contributor Author

In addition to the above mentioned changes, I:

  1. Made it so that the ConfigMap is only stored in memory once for apps with multiple containers that needed it. That is, the ConfigMap was only created once, but it was stored in memory for the apply multiple times.
  2. Changed the location of the binary from /usr/local/bin to /.acorn/sleep
  3. The repo I created for the sleep binary gets the size of the binary down to 5K for amd64 and 7k for arm64.

Re-requesting reviews for these reasons.

@thedadams thedadams merged commit c0ac7e1 into acorn-io:main Oct 27, 2023
@thedadams thedadams deleted the pre-stop-hook branch October 27, 2023 18:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants