Skip to content

Commit

Permalink
Don't check currentRevision or currentReplicas
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesOwenHall committed Apr 2, 2024
1 parent 2db9122 commit d4218a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/krane/kubernetes_resource/stateful_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def deploy_succeeded?
@success_assumption_warning_shown = true
end
else
success &= status_data['currentRevision'] == status_data['updateRevision']
success &= desired_replicas == status_data['readyReplicas'].to_i
success &= desired_replicas == status_data['updatedReplicas'].to_i
end
Expand Down
24 changes: 6 additions & 18 deletions test/unit/krane/kubernetes_resource/stateful_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,26 @@ def test_deploy_succeeded_true_with_rolling_update_strategy

def test_deploy_succeeded_true_with_on_delete_strategy_and_no_rollout_annotation
# OnDelete strategy without rollout annotation should always succeed.
# Change the updateRevision to ensure it's not being used to determine success.
ss_template = build_ss_template(status: { "updateRevision": 3 }, updateStrategy: "OnDelete", rollout: nil)
# Change updatedReplicas to ensure it's not being used to determine success.
ss_template = build_ss_template(status: { "updatedReplicas": 0 }, updateStrategy: "OnDelete", rollout: nil)
ss = build_synced_ss(ss_template: ss_template)
assert_predicate(ss, :deploy_succeeded?)
end

def test_deploy_succeeded_true_with_on_delete_strategy_and_full_rollout_annotation
ss_template = build_ss_template(status: { "updateRevision": 3 }, updateStrategy: "OnDelete", rollout: nil)
ss = build_synced_ss(ss_template: ss_template)
assert_predicate(ss, :deploy_succeeded?)
end

def test_deploy_does_not_succeed_when_revision_does_not_match_without_annotation
ss_template = build_ss_template(status: { "updateRevision": 1 }, rollout: nil)
ss = build_synced_ss(ss_template: ss_template)
refute_predicate(ss, :deploy_succeeded?)
end

def test_deploy_succeeded_when_replica_counts_match_for_ondelete_strategy_with_full_annotation
ss_template = build_ss_template(updateStrategy: "OnDelete", rollout: "full")
ss = build_synced_ss(ss_template: ss_template)
assert_predicate(ss, :deploy_succeeded?)
end

def test_deploy_does_not_succeed_when_replica_counts_do_not_match_for_ondelete_strategy_with_full_annotation
ss_template = build_ss_template(status: { "readyReplicas": 1 }, updateStrategy: "OnDelete", rollout: "full")
def test_deploy_succeeded_false_when_updated_replicas_dont_match_desired
ss_template = build_ss_template(status: { "updatedReplicas": 1 })
ss = build_synced_ss(ss_template: ss_template)
refute_predicate(ss, :deploy_succeeded?)
end

def test_deploy_does_not_succeed_when_replica_counts_do_not_match_for_rollingupdate_strategy
ss_template = build_ss_template(status: { "updatedReplicas": 1 }, updateStrategy: "RollingUpdate", rollout: nil)
def test_deploy_does_not_succeed_when_replica_counts_do_not_match_for_ondelete_strategy_with_full_annotation
ss_template = build_ss_template(status: { "updatedReplicas": 1 }, updateStrategy: "OnDelete", rollout: "full")
ss = build_synced_ss(ss_template: ss_template)
refute_predicate(ss, :deploy_succeeded?)
end
Expand Down

0 comments on commit d4218a9

Please sign in to comment.