Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retry omnibus code signing #29552

Merged
merged 6 commits into from
Sep 25, 2024
Merged
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
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
Loading