diff --git a/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go b/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go index 4dbaa4b74c66..8fbcfcddb521 100644 --- a/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go @@ -827,7 +827,7 @@ func safelyStoreAgentInfo(s saver, reader io.Reader) error { for i := 0; i <= maxRetriesstoreAgentInfo; i++ { backExp.Wait() err = storeAgentInfo(s, reader) - if stderror.Is(err, filelock.ErrAppAlreadyRunning) { + if !stderror.Is(err, filelock.ErrAppAlreadyRunning) { break } }