-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Heartbeat] Fix missing monitor status on 1 of 2 attempts #36704
Conversation
Pinging @elastic/uptime (Team:Uptime) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
@@ -99,25 +100,22 @@ func TestLightweightUrls(t *testing.T) { | |||
|
|||
func TestLightweightSummaries(t *testing.T) { | |||
t.Parallel() | |||
scenarioDB.RunTag(t, "lightweight", func(t *testing.T, mtr *framework.MonitorTestRun, err error) { | |||
scenarioDB.RunTagWithSeparateTwists(t, "lightweight", StdAttemptTwists, func(t *testing.T, mtr *framework.MonitorTestRun, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now run these tests with both 1 and 2 max_attempts
}) | ||
} | ||
|
||
func TestBrowserSummaries(t *testing.T) { | ||
t.Parallel() | ||
scenarioDB.RunTag(t, "browser", func(t *testing.T, mtr *framework.MonitorTestRun, err error) { | ||
scenarioDB.RunTagWithSeparateTwists(t, "browser", StdAttemptTwists, func(t *testing.T, mtr *framework.MonitorTestRun, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now run these tests with both 1 and 2 max_attempts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -56,20 +56,24 @@ func (ssp *BrowserStateStatusPlugin) EachEvent(event *beat.Event, jobErr error) | |||
} | |||
|
|||
func (ssp *BrowserStateStatusPlugin) BeforeSummary(event *beat.Event) BeforeSummaryActions { | |||
ssp.cssp.js.Status = monitorstate.StatusDown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we already set the Status here, it can be safely removed from the common BeforeSummary -
beats/heartbeat/monitors/wrappers/summarizer/plugstatestat.go
Lines 144 to 148 in a51b909
if ssp.js.Down > 0 { | |
ssp.js.Status = monitorstate.StatusDown | |
} else { | |
ssp.js.Status = monitorstate.StatusUp | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do it the other way and leave that in common since we still need that for common
// mutate the js into the state for the next attempt | ||
ssp.js.BumpAttempt() | ||
} | ||
eventext.MergeEventFields(event, fields) | ||
|
||
logp.L().Debugf("attempt info: %v == %v && %d < %d", ssp.js.Status, lastStatus, ssp.js.Attempt, ssp.js.MaxAttempts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add last vs current status and attempts. Felt more descriptive -
logp.L().Debugf("attempt info: current(%v) == lastStatus(%v) && attempts(%d < %d)", ssp.js.Status, lastStatus, ssp.js.Attempt, ssp.js.MaxAttempts)
) [Heartbeat] Fix missing monitor.status value in initial attempt where max_attempts > 2. Introduced in elastic#36623 adding tests to the scenario runner as well. Original cause was this PR elastic#36519 that did not produce the correct monitor.status: down when the monitor is retried with the second attempt.
Proposed commit message
[Heartbeat] Fix missing
monitor.status
value in initial attempt where max_attempts > 2. Introduced in #36623 adding tests to the scenario runner as well.Original cause was this PR #36519 that did not produce the correct monitor.status: down when the monitor is retried with the second attempt.
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Use the following monitor config with JSON output to console enabled
output.console: ~
Related issues
Use cases
Screenshots
Logs