Skip to content

Commit

Permalink
If we're going to batch dry run, then let's actually use the results
Browse files Browse the repository at this point in the history
  • Loading branch information
timothysmith0609 committed Jan 19, 2024
1 parent 41a63a8 commit 5857e44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions lib/krane/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,12 @@ def validate_configuration(prune:)

def validate_resources(resources)
validate_globals(resources)
batch_dry_run_success = validate_dry_run(resources)
resources.select! { |r| r.selected?(@selector) } if @selector_as_filter
applyables, individuals = resources.partition { |r| r.deploy_method == :apply }
batch_dry_run_success = validate_dry_run(applyables)
Krane::Concurrency.split_across_threads(resources) do |r|
# No need to pass in kubectl (and do per-resource dry run apply) if batch dry run succeeded
if batch_dry_run_success
r.validate_definition(kubectl: nil, selector: @selector, dry_run: false)
else
r.validate_definition(kubectl: kubectl, selector: @selector, dry_run: true)
end
r.validate_definition(kubectl: nil, selector: @selector, dry_run: false)
end
failed_resources = resources.select(&:validation_failed?)
if failed_resources.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/krane/resource_deployer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def apply_all(resources, prune, dry_run: false)
if st.success?
log_pruning(out) if prune
else
record_apply_failure(err, resources: resources) unless dry_run
record_apply_failure(err, resources: resources)
raise FatalDeploymentError, "Command failed: #{Shellwords.join(command)}"
end
end
Expand Down

0 comments on commit 5857e44

Please sign in to comment.