@@ -616,19 +616,29 @@ 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 {
631- uc .logger .Debugw ("msg" , "status changed, dispatching audit event" ,
641+ uc .logger .Infow ("msg" , "status changed, dispatching audit event" ,
632642 "backend" , backend .ID ,
633643 "previousStatus" , previousStatus ,
634644 "newStatus" , validationStatus )
0 commit comments