Skip to content

Commit dae762b

Browse files
committed
reload backend
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent cc89d04 commit dae762b

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

app/controlplane/pkg/biz/casbackend.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,26 @@ func (uc *CASBackendUseCase) PerformValidation(ctx context.Context, id string) e
616616
}
617617

618618
defer func() {
619+
// reload the backend in case some other instance updated it while we were validating
620+
backend, err := uc.repo.FindByID(ctx, backendUUID)
621+
if err != nil {
622+
uc.logger.Errorw("msg", "finding backend after validation", "ID", id, "error", err)
623+
return
624+
} else if backend == nil {
625+
uc.logger.Errorw("msg", "backend not found after validation", "ID", id)
626+
return
627+
}
628+
629+
// Store previous status for audit logging
630+
previousStatus := backend.ValidationStatus
631+
619632
// Update the validation status and error
620633
uc.logger.Infow("msg", "updating validation status", "ID", id, "status", validationStatus, "error", validationError)
621634
if err := uc.repo.UpdateValidationStatus(ctx, backendUUID, validationStatus, validationError); err != nil {
622635
uc.logger.Errorw("msg", "updating validation status", "ID", id, "error", err)
623636
return
624637
}
625638

626-
// Store previous status for audit logging
627-
previousStatus := backend.ValidationStatus
628-
629639
// Log status change as an audit event if status has changed and auditor is available
630640
if uc.auditorUC != nil && previousStatus != validationStatus {
631641
uc.logger.Infow("msg", "status changed, dispatching audit event",

0 commit comments

Comments
 (0)