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

fix: possible race on artefact upload #2368

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 14 additions & 1 deletion buildengine/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"fmt"
"os"
"path/filepath"
goslices "slices"
"time"

"connectrpc.com/connect"
Expand Down Expand Up @@ -74,7 +75,19 @@
Content: content,
}))
if err != nil {
return err
// There is a possible race here, another deployment may have uploaded it
// double check it has not been added
newDiffs, diffErr := client.GetArtefactDiffs(ctx, connect.NewRequest(&ftlv1.GetArtefactDiffsRequest{ClientDigests: maps.Keys(filesByHash)}))
if diffErr != nil {
return fmt.Errorf("failed to get artefact diffs: %w after upload failure %w", diffErr, err)
}
if goslices.Contains(newDiffs.Msg.MissingDigests, missing) {
// It is still missing, return the error
return fmt.Errorf("failed to upload artifacts %w", err)
} else {

Check warning on line 87 in buildengine/deploy.go

View workflow job for this annotation

GitHub Actions / Lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
logger.Debugf("Upload %s of was cancelled as another deployment uploaded it", relToCWD(file.localPath))
continue
}
}
logger.Debugf("Uploaded %s as %s:%s", relToCWD(file.localPath), sha256.FromBytes(resp.Msg.Digest), file.Path)
}
Expand Down
Loading