diff --git a/lib/krane/kubernetes_resource.rb b/lib/krane/kubernetes_resource.rb index 2636ae9b0..101c2eb9f 100644 --- a/lib/krane/kubernetes_resource.rb +++ b/lib/krane/kubernetes_resource.rb @@ -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") @@ -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 @@ -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." @@ -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