Skip to content

Commit 8e1fb49

Browse files
🌱 Retries for signing the results with rekor
- Included retries for signing the results with rekor. Signed-off-by: naveensrinivasan <[email protected]>
1 parent cd50e39 commit 8e1fb49

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

signing/signing.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"errors"
2424
"fmt"
2525
"io"
26+
"log"
2627
"net/http"
2728
"net/url"
2829
"os"
@@ -74,6 +75,7 @@ func New(token string) (*Signing, error) {
7475
// SignScorecardResult signs the results file and uploads the attestation to the Rekor transparency log.
7576
func (s *Signing) SignScorecardResult(scorecardResultsFile string) error {
7677
// Prepare settings for SignBlobCmd.
78+
numberOfRetries := 3
7779
rootOpts := &sigOpts.RootOptions{Timeout: sigOpts.DefaultTimeout} // Just the timeout.
7880
keyOpts := sigOpts.KeyOpts{
7981
FulcioURL: sigOpts.DefaultFulcioURL, // Signing certificate provider.
@@ -86,8 +88,16 @@ func (s *Signing) SignScorecardResult(scorecardResultsFile string) error {
8688
// This command will use the provided OIDCIssuer to authenticate into Fulcio, which will generate the
8789
// signing certificate on the scorecard result. This attestation is then uploaded to the Rekor transparency log.
8890
// The output bytes (signature) and certificate are discarded since verification can be done with just the payload.
89-
if _, err := sign.SignBlobCmd(rootOpts, keyOpts, regOpts, scorecardResultsFile, true, "", ""); err != nil {
90-
return fmt.Errorf("error signing payload: %w", err)
91+
for i := 0; i < numberOfRetries; i++ { // Retry in case of network errors.
92+
if _, err := sign.SignBlobCmd(rootOpts, keyOpts, regOpts, scorecardResultsFile, true, "", ""); err != nil {
93+
log.Printf("error signing scorecard results: %v\n", err)
94+
if i == numberOfRetries-1 {
95+
return fmt.Errorf("error signing scorecard results: %w", err)
96+
}
97+
} else {
98+
break
99+
}
100+
time.Sleep(5 * time.Second) // Wait 5 seconds before retrying.
91101
}
92102

93103
return nil

0 commit comments

Comments
 (0)