Cherry-pick #26126 to 7.x: Fix startup with failing configuration #26262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #17391 to 7.x branch. Original message:
What does this PR do?
What is going on is a bit weird race.
Basically we start ok but troubles come on restart.
On restart we apply stored config to start MB (
mb1
) with failing configuration,MB does not exit just reports Failed state because it cannot apply
system/load
on windows.At this time 10 second timer to recover is started otherwise we plan a restart.
Then we pull config from fleet and decide MB should be started.
We start MB
mb2
whilemb1
is still running. We are starting it because check checks for terminal statuses and Failed is one of them.This
mb2
starts reports running, timer for killingmb1
is stopped. Because MB is running and it does not differentiate between processes.mb2
fails ondata.path
conflict withmb1
watcher detects stopped metricbeat and
mb3
is started,mb1
is still running, we dont have any information aboutmb1
anymore anywhere.mb3
fails on same thingmb2
failed and exits.mb1
still running in Failed state and we trymbX
over and over again.This PR adds some closers to watcher, some checks on Failure termination and passing proc so watcher and terminator are killing the process they were designed to kill.
While this fix works, i dont like the whole approach where we handle start/stop/restart from 4-5 places and they can be conflicting. I would like to see this redesigned. But i've spent 5 days chasing this and need some social distancing from the topic so this fix is OK at the moment for me.
How to test:
How it behaved before the fix: we had 3 metricbeats, 2 with stable PID (one for monitoring, one is
mb1
) and then thirds MB process kept changing PID (crash-restart loop)Why is it important?
Fixes #25829
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.