Skip to content

Commit 451f75b

Browse files
authored
Improve error for "instance lock is already locked" (#33788)
1 parent f73b384 commit 451f75b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG-developer.next.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
148148
- Add support for multiple regions in GCP {pull}32964[32964]
149149
- Use `T.TempDir` to create temporary test directory {pull}33082[33082]
150150
- Add an option to disable event normalization when creating a `beat.Client`. {pull}33657[33657]
151+
- Add the file path of the instance lock on the error when it's is already locked {pull}33788[33788]
151152

152153
==== Deprecated
153154

libbeat/cmd/instance/locks/lock.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
// ErrAlreadyLocked is returned when a lock on the data path is attempted but
5151
// unsuccessful because another Beat instance already has the lock on the same
5252
// data path.
53-
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).")
53+
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)")
5454

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

118118
return nil

0 commit comments

Comments
 (0)