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 2b92dfdadb5..c595f1e19b7 100644 --- a/pkg/infra/serverlock/serverlock.go +++ b/pkg/infra/serverlock/serverlock.go @@ -2,7 +2,6 @@ package serverlock import ( "context" - "errors" "time" "go.opentelemetry.io/otel/attribute" @@ -185,7 +184,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()