Skip to content

Commit

Permalink
fix: consistency protection storing attestations
Browse files Browse the repository at this point in the history
COMMIT MESSAGE

Adds protection to the users while storing attestations

As Archivista relies on Object Storage/Filesystem to store the blob
attestation and the SQL server to register the attestations for
querying using GraphSQL, the flow needs to be consistent, as the
services can fail.

Ideally, the Store should happen transactional and not finish with
inconsistency: file available in the SQL but not in the metadata
Storage, for example. If it happens, the user will query the SQL
but will not be able to retrieve/download the attestation blob.

A minor fix is done in this PR, first adding the to the metadata
storage and after registering in the SQL server.
So, if the metadata storage fails, it will not continue and save
it in the SQL server.

Signed-off-by: Kairo Araujo <[email protected]>
  • Loading branch information
kairoaraujo authored and jkjell committed Jan 23, 2024
1 parent 488c3dd commit 18bce35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ func (s *Server) Store(ctx context.Context, r io.Reader) (api.StoreResponse, err
return api.StoreResponse{}, err
}

if err := s.metadataStore.Store(ctx, gid.String(), payload); err != nil {
logrus.Errorf("received error from metadata store: %+v", err)
return api.StoreResponse{}, err
}

if s.objectStore != nil {
if err := s.objectStore.Store(ctx, gid.String(), payload); err != nil {
logrus.Errorf("received error from object store: %+v", err)
return api.StoreResponse{}, err
}
}

if err := s.metadataStore.Store(ctx, gid.String(), payload); err != nil {
logrus.Errorf("received error from metadata store: %+v", err)
return api.StoreResponse{}, err
}

return api.StoreResponse{Gitoid: gid.String()}, nil
}

Expand Down

0 comments on commit 18bce35

Please sign in to comment.