Skip to content

Commit

Permalink
do not do deletions when using RollingUpdate strategy on 1.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Sep 13, 2018
1 parent eb0ac84 commit ae7463c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/kubernetes/app/models/kubernetes/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def wait_for_termination_of_all_pods

class StatefulSet < Base
def patch_replace?
[nil, "OnDelete"].include?(@template.dig(:spec, :updateStrategy)) && running?
deprecated = @template.dig(:spec, :updateStrategy) # supporting pre 1.9 clusters
strategy = (deprecated.is_a?(String) ? deprecated : @template.dig(:spec, :updateStrategy, :type))
[nil, "OnDelete"].include?(strategy) && running?
end

# StatefulSet cannot be updated normally when OnDelete is used or kubernetes <1.7
Expand Down
9 changes: 9 additions & 0 deletions plugins/kubernetes/test/models/kubernetes/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,15 @@ def deployment_stub(replica_count)
end
end

it "updates when running and using RollingUpdate" do
template[:spec][:updateStrategy] = {type: "RollingUpdate"}
assert_request(:get, url, to_return: {body: "{}"}) do
assert_request(:put, url, to_return: {body: "{}"}) do
resource.deploy
end
end
end

it "patches and deletes pods when using OnDelete (default)" do
set = {
spec: {
Expand Down

0 comments on commit ae7463c

Please sign in to comment.