Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/models/concerns/orchestration/ssh_provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Minor nitpick: If build_errors is nil, this interpolation results in a leading newline character. It might be cleaner to use an array join:"

Suggested change
self.build_errors = "#{build_errors}\n#{error_message}"
self.build_errors = [build_errors, error_message].compact.join("\n")

refresh_build_status
failure error_message, e
end

def delSSHWaitForResponse
Expand Down
16 changes: 8 additions & 8 deletions app/models/host_status/build_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use elsif waiting_for_build? to avoid a level of nesting?

if token_expired?
TOKEN_EXPIRED
else
PENDING
end
else
BUILT
end
Expand Down
Loading