Skip to content

Commit

Permalink
move errors to the bottom
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sharma <[email protected]>
  • Loading branch information
epk committed Dec 6, 2023
1 parent b87c0c0 commit bde44b6
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions lib/krane/kubernetes_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,6 @@ def sync_debug_info(kubectl)

def debug_message(cause = nil, info_hash = {})
helpful_info = []
if cause == :gave_up
debug_heading = ColorizedString.new("#{id}: GLOBAL WATCH TIMEOUT (#{info_hash[:timeout]} seconds)").yellow
helpful_info << "If you expected it to take longer than #{info_hash[:timeout]} seconds for your deploy"\
" to roll out, increase --global-timeout."
elsif deploy_failed?
debug_heading = ColorizedString.new("#{id}: FAILED").red
helpful_info << failure_message if failure_message.present?
elsif deploy_timed_out?
debug_heading = ColorizedString.new("#{id}: TIMED OUT (#{pretty_timeout_type})").yellow
helpful_info << timeout_message if timeout_message.present?
else
# Arriving in debug_message when we neither failed nor timed out is very unexpected. Dump all available info.
debug_heading = ColorizedString.new("#{id}: MONITORING ERROR").red
helpful_info << failure_message if failure_message.present?
helpful_info << timeout_message if timeout_message.present? && timeout_message != STANDARD_TIMEOUT_MESSAGE
end

final_status = " - Final status: #{status}"
final_status = "\n#{final_status}" if helpful_info.present? && !helpful_info.last.end_with?("\n")
Expand Down Expand Up @@ -312,6 +296,23 @@ def debug_message(cause = nil, info_hash = {})
end
end

if cause == :gave_up
debug_heading = ColorizedString.new("#{id}: GLOBAL WATCH TIMEOUT (#{info_hash[:timeout]} seconds)").yellow
helpful_info << "If you expected it to take longer than #{info_hash[:timeout]} seconds for your deploy"\
" to roll out, increase --global-timeout."
elsif deploy_failed?
debug_heading = ColorizedString.new("#{id}: FAILED").red
helpful_info << failure_message if failure_message.present?
elsif deploy_timed_out?
debug_heading = ColorizedString.new("#{id}: TIMED OUT (#{pretty_timeout_type})").yellow
helpful_info << timeout_message if timeout_message.present?
else
# Arriving in debug_message when we neither failed nor timed out is very unexpected. Dump all available info.
debug_heading = ColorizedString.new("#{id}: MONITORING ERROR").red
helpful_info << failure_message if failure_message.present?
helpful_info << timeout_message if timeout_message.present? && timeout_message != STANDARD_TIMEOUT_MESSAGE
end

helpful_info.join("\n")
end

Expand Down Expand Up @@ -553,6 +554,7 @@ def validate_spec_with_kubectl(kubectl)
if err.empty? || err.match(SERVER_DRY_RUN_DISABLED_ERROR)
_, err, st = validate_with_local_dry_run(kubectl)
end

return true if st.success?
@validation_errors << if sensitive_template_content?
"Validation for #{id} failed. Detailed information is unavailable as the raw error may contain sensitive data."
Expand All @@ -575,6 +577,7 @@ def validate_with_server_side_dry_run(kubectl)
def validate_with_local_dry_run(kubectl)
verb = deploy_method == :apply ? "apply" : "create"
command = [verb, "-f", file_path, "--dry-run=client", "--output=name"]

kubectl.run(*command, log_failure: false, output_is_sensitive: sensitive_template_content?,
retry_whitelist: [:client_timeout, :empty, :context_deadline], attempts: 3, use_namespace: !global?)
end
Expand Down

0 comments on commit bde44b6

Please sign in to comment.