Skip to content

Commit

Permalink
change updateAttestedNodes tx type
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Harding <aharding@vmware.com>
  • Loading branch information
azdagron committed Mar 12, 2021
1 parent 8893166 commit f06d325
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/server/plugin/datastore/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (ds *Plugin) ListAttestedNodes(ctx context.Context,
// UpdateAttestedNode updates the given node's cert serial and expiration.
func (ds *Plugin) UpdateAttestedNode(ctx context.Context,
req *datastore.UpdateAttestedNodeRequest) (resp *datastore.UpdateAttestedNodeResponse, err error) {
if err = ds.withWriteTx(ctx, func(tx *gorm.DB) (err error) {
if err = ds.withReadModifyWriteTx(ctx, func(tx *gorm.DB) (err error) {
resp, err = updateAttestedNode(tx, req)
return err
}); err != nil {
Expand Down Expand Up @@ -571,7 +571,7 @@ func (ds *Plugin) withReadModifyWriteTx(ctx context.Context, op func(tx *gorm.DB
if ds.db.databaseType == MySQL {
// MySQL REPEATABLE READ is weaker than that of PostgreSQL. Namely,
// PostgreSQL, beyond providing the minimum consistency guarantees
// mandataded for REPEATABLE READ in the standard, automatically fails
// mandated for REPEATABLE READ in the standard, automatically fails
// concurrent transactions that try to update the same target row.
//
// MySQL SERIALIZABLE is the same as REPEATABLE READ except that it
Expand Down Expand Up @@ -1538,6 +1538,7 @@ FROM attested_node_entries N

return builder.String(), args, nil
}

func updateAttestedNode(tx *gorm.DB, req *datastore.UpdateAttestedNodeRequest) (*datastore.UpdateAttestedNodeResponse, error) {
var model AttestedNode
if err := tx.Find(&model, "spiffe_id = ?", req.SpiffeId).Error; err != nil {
Expand Down

0 comments on commit f06d325

Please sign in to comment.