diff --git a/pkg/infra/serverlock/errors.go b/pkg/infra/serverlock/errors.go new file mode 100644 index 00000000000..f5fe91c68db --- /dev/null +++ b/pkg/infra/serverlock/errors.go @@ -0,0 +1,9 @@ +package serverlock + +type ServerLockExistsError struct { + actionName string +} + +func (e *ServerLockExistsError) Error() string { + return "there is already a lock for this actionName: " + e.actionName +} diff --git a/pkg/infra/serverlock/serverlock.go b/pkg/infra/serverlock/serverlock.go index 1e2d7cfd024..f3406dd7f70 100644 --- a/pkg/infra/serverlock/serverlock.go +++ b/pkg/infra/serverlock/serverlock.go @@ -2,7 +2,6 @@ package serverlock import ( "context" - "errors" "time" "github.com/grafana/grafana/pkg/infra/log" @@ -184,7 +183,7 @@ func (sl *ServerLockService) acquireForRelease(ctx context.Context, actionName s if len(lockRows) > 0 { result := lockRows[0] if sl.isLockWithinInterval(result, maxInterval) { - return errors.New("there is already a lock for this actionName: " + actionName) + return &ServerLockExistsError{actionName: actionName} } else { // lock has timeouted, so we update the timestamp result.LastExecution = time.Now().Unix()