Skip to content

Commit

Permalink
retry omnibus code signing (#29552)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkb7 committed Sep 25, 2024
1 parent 2acf4d5 commit 87c9fa0
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions omnibus/lib/project_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,48 @@ def package_me

def ddwcssign(file)
log.info(self.class.name) { "Signing #{file}" }
cmd = Array.new.tap do |arr|

# Signing is inherently flaky as the timestamp server may not be available
# retry a few times
max_retries = 3
attempts = 0
delay = 2

begin
attempts += 1
cmd = Array.new.tap do |arr|
arr << "dd-wcs"
arr << "sign"
arr << "\"#{file}\""
end.join(" ")
status = shellout(cmd)
if status.exitstatus != 0
log.warn(self.class.name) do
<<-EOH.strip
Failed to sign with dd-wcs
STDOUT
------
#{status.stdout}
STDERR
------
#{status.stderr}
EOH
end.join(" ")

status = shellout(cmd)
if status.exitstatus != 0
log.warn(self.class.name) do
<<-EOH.strip
Failed to sign with dd-wcs (Attempt #{attempts} of #{max_retries})
STDOUT
------
#{status.stdout}
STDERR
------
#{status.stderr}
EOH
end
raise "Failed to sign with dd-wcs"
else
log.info(self.class.name) { "Successfully signed #{file} after #{attempts} attempt(s)" }
end
rescue => e
# Retry logic: raise error after 3 attempts
if attempts < max_retries
log.info(self.class.name) { "Retrying signing #{file} (Attempt #{attempts + 1})" }
sleep(delay)
retry
end
raise "Failed to sign with dd-wcs: #{e.message}"
end
end

Expand All @@ -78,4 +100,4 @@ class Project
expose :inspect_binary
expose :sign_file
end
end
end

0 comments on commit 87c9fa0

Please sign in to comment.