Skip to content

Commit

Permalink
attestation: retry on InvalidAttestationError instead
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab committed Oct 4, 2024
1 parent d0e4aea commit 6b63660
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def self.check_attestation(bottle, signing_repo, signing_workflow = nil, subject
attestation
end

ATTESTATION_MAX_RETRIES = 5

# Verifies the given bottle against a cryptographic attestation of build provenance
# from homebrew-core's CI, falling back on a "backfill" attestation for older bottles.
#
Expand Down Expand Up @@ -246,12 +248,15 @@ def self.check_core_attestation(bottle)
end

backfill_attestation
rescue InvalidAttestationError => e
raise if ENV["HOMEBREW_GITHUB_ACTIONS"].blank?

opoo "Attestation verification failed (please verify that this is not a network error before rebottling): #{e}"

{}
rescue InvalidAttestationError
@attestation_retry_count ||= T.let(Hash.new(0), T.nilable(T::Hash[Bottle, Integer]))
raise if @attestation_retry_count[bottle] >= ATTESTATION_MAX_RETRIES

sleep_time = 3 ** @attestation_retry_count[bottle]
opoo "Failed to verify attestation. Retrying in #{sleep_time}..."
sleep sleep_time
@attestation_retry_count[bottle] += 1
retry
end
end
end

0 comments on commit 6b63660

Please sign in to comment.