Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/controlplane/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func main() {
// Start around 24h mark to avoid overlap with default checker
go app.casBackendChecker.Start(ctx, &biz.CASBackendCheckerOpts{
CheckInterval: 24 * time.Hour,
InitialDelay: 24 * time.Hour,
InitialDelay: (24 * time.Hour) + jitter,
OnlyDefaults: toPtr(false),
})
}
Expand Down
18 changes: 14 additions & 4 deletions app/controlplane/pkg/biz/casbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,19 +616,29 @@ func (uc *CASBackendUseCase) PerformValidation(ctx context.Context, id string) e
}

defer func() {
// reload the backend in case some other instance updated it while we were validating
backend, err := uc.repo.FindByID(ctx, backendUUID)
if err != nil {
uc.logger.Errorw("msg", "finding backend after validation", "ID", id, "error", err)
return
} else if backend == nil {
uc.logger.Errorw("msg", "backend not found after validation", "ID", id)
return
}

// Store previous status for audit logging
previousStatus := backend.ValidationStatus

// Update the validation status and error
uc.logger.Infow("msg", "updating validation status", "ID", id, "status", validationStatus, "error", validationError)
if err := uc.repo.UpdateValidationStatus(ctx, backendUUID, validationStatus, validationError); err != nil {
uc.logger.Errorw("msg", "updating validation status", "ID", id, "error", err)
return
}

// Store previous status for audit logging
previousStatus := backend.ValidationStatus

// Log status change as an audit event if status has changed and auditor is available
if uc.auditorUC != nil && previousStatus != validationStatus {
uc.logger.Debugw("msg", "status changed, dispatching audit event",
uc.logger.Infow("msg", "status changed, dispatching audit event",
"backend", backend.ID,
"previousStatus", previousStatus,
"newStatus", validationStatus)
Expand Down
Loading