Skip to content

Commit

Permalink
Improve error for "instance lock is already locked" (#33788)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ authored Nov 30, 2022
1 parent f73b384 commit 451f75b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Add support for multiple regions in GCP {pull}32964[32964]
- Use `T.TempDir` to create temporary test directory {pull}33082[33082]
- Add an option to disable event normalization when creating a `beat.Client`. {pull}33657[33657]
- Add the file path of the instance lock on the error when it's is already locked {pull}33788[33788]

==== Deprecated

Expand Down
4 changes: 2 additions & 2 deletions libbeat/cmd/instance/locks/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
// ErrAlreadyLocked is returned when a lock on the data path is attempted but
// unsuccessful because another Beat instance already has the lock on the same
// data path.
ErrAlreadyLocked = fmt.Errorf("data path already locked by another beat. Please make sure that multiple beats are not sharing the same data path (path.data).")
ErrAlreadyLocked = fmt.Errorf("data path already locked by another beat. Please make sure that multiple beats are not sharing the same data path (path.data)")

// ErrLockfileEmpty is returned by readExistingPidfile() when an existing pidfile is found, but the file is empty.
ErrLockfileEmpty = fmt.Errorf("lockfile is empty")
Expand Down Expand Up @@ -112,7 +112,7 @@ func (lock *Locker) Lock() error {
// case: lock could not be obtained.
if !isLocked {
// if we're here, things are probably unrecoverable, as we've previously checked for a lockfile. Exit.
return ErrAlreadyLocked
return fmt.Errorf("%s: %w", lock.filePath, ErrAlreadyLocked)
}

return nil
Expand Down

0 comments on commit 451f75b

Please sign in to comment.