Skip to content

Commit

Permalink
Improve error for "instance lock is already locked" (#33788) (#33883)
Browse files Browse the repository at this point in the history
(cherry picked from commit 451f75b)

Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
  • Loading branch information
mergify[bot] and AndersonQ committed Dec 2, 2022
1 parent b4dfc2a commit 6d03209
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-developer.next.asciidoc
Expand Up @@ -146,6 +146,9 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Improve compatibility and reduce flakyness of Python tests {pull}31588[31588]
- Added `.python-version` file {pull}32323[32323]
- 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
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 6d03209

Please sign in to comment.