From e387cc78033ac1985479257f548e0a7fac17317a Mon Sep 17 00:00:00 2001 From: Shim Shtein Date: Thu, 13 Nov 2025 11:38:27 -0500 Subject: [PATCH] Fixes #38904 - Fix build status on SSH error The PR changes the way the build status is calculated, so the build will be considered failed if errors present regardless the waiting condition. The second part is that the host is adding a build error once the SSH times out. --- .../concerns/orchestration/ssh_provision.rb | 5 ++++- app/models/host_status/build_status.rb | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/models/concerns/orchestration/ssh_provision.rb b/app/models/concerns/orchestration/ssh_provision.rb index 6c4dbd13324..07182b87248 100644 --- a/app/models/concerns/orchestration/ssh_provision.rb +++ b/app/models/concerns/orchestration/ssh_provision.rb @@ -53,7 +53,10 @@ def setSSHWaitForResponse end self.client = Foreman::Provision::Ssh.new provision_host, image.try(:username), { :template => template_file.path, :uuid => uuid }.merge(credentials) rescue => e - failure _("Failed to login via SSH to %{name}: %{e}") % { :name => name, :e => e }, e + error_message = _("Failed to login via SSH to %{name}: %{e}") % { :name => name, :e => e } + self.build_errors = "#{build_errors}\n#{error_message}" + refresh_build_status + failure error_message, e end def delSSHWaitForResponse diff --git a/app/models/host_status/build_status.rb b/app/models/host_status/build_status.rb index c2d5fd8012b..c7573a898c7 100644 --- a/app/models/host_status/build_status.rb +++ b/app/models/host_status/build_status.rb @@ -41,15 +41,15 @@ def to_global(options = {}) end def to_status(options = {}) - if waiting_for_build? - if token_expired? - TOKEN_EXPIRED - else - PENDING - end + if build_errors? + BUILD_FAILED else - if build_errors? - BUILD_FAILED + if waiting_for_build? + if token_expired? + TOKEN_EXPIRED + else + PENDING + end else BUILT end