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: use SleepAction for prestop hooks instead of ExecAction #4126

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ To make Samson leave your resource name alone, set `metadata.annotations.samson/
When not using kubernetes services to route requests, requests can be lost during a deployment,
since old pods shut down before everyone all clients are refreshed.

To prevent this, samson can automatically add `container[].lifecycle.preStop` `/bin/sleep <INT>`
To prevent this, samson can automatically add `container[].lifecycle.preStop.sleep.seconds: <INT>`
and increase the `spec.terminationGracePeriodSeconds` if necessary.

(will only add if `preStop` hook is not set and pod `metadata.annotations.container-nameofcontainer-samson/preStop` is not set to `disabled` and container has ports)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def set_pre_stop
# add prestop sleep
sleep_time = Integer(ENV['KUBERNETES_PRESTOP_SLEEP_DURATION'] || '3')
containers.each do |container|
(container[:lifecycle] ||= {})[:preStop] = {exec: {command: ["/bin/sleep", sleep_time.to_s]}}
(container[:lifecycle] ||= {})[:preStop] = {sleep: {seconds: sleep_time}}
end

# shut down after prestop sleeping is done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def lifecycle_defined?

it "adds preStop to avoid 502 errors when server addresses are cached for a few seconds" do
template.to_hash.dig_fetch(:spec, :template, :spec, :containers, 0, :lifecycle).must_equal(
preStop: {exec: {command: ["/bin/sleep", "3"]}}
preStop: {sleep: {seconds: 3}}
)
end

Expand Down
Loading