Skip to content
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

Read extra heartbeats once #1076

Closed
wants to merge 1 commit into from
Closed

Conversation

gandarez
Copy link
Member

This PR prevents reading extra heartbeats more than once by setting extra-heartbeats flag to false when rate limited. It also includes an integration test to assert this behavior.

@gandarez gandarez self-assigned this Jul 24, 2024
Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 52.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 63.01%. Comparing base (35e88b4) to head (e4ad352).

@@             Coverage Diff             @@
##           develop    #1076      +/-   ##
===========================================
- Coverage    63.03%   63.01%   -0.03%     
===========================================
  Files          383      383              
  Lines        16504    16511       +7     
===========================================
+ Hits         10403    10404       +1     
- Misses        5533     5537       +4     
- Partials       568      570       +2     
Flag Coverage Δ
unittests 63.01% <52.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
cmd/heartbeat/heartbeat.go 77.25% <100.00%> (+0.36%) ⬆️
cmd/offline/offline.go 70.77% <0.00%> (-1.41%) ⬇️
cmd/params/params.go 85.67% <40.00%> (-0.38%) ⬇️

@gandarez gandarez enabled auto-merge July 24, 2024 16:56
@@ -750,29 +752,20 @@ func readAPIKeyFromCommand(cmdStr string) (string, error) {
return strings.TrimSpace(string(out)), nil
}

var extraHeartbeatsCache *[]heartbeat.Heartbeat // nolint:gochecknoglobals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still want to use a semaphore to be sure it never reads stdin twice. It can't hurt.

if err = offlinecmd.SaveHeartbeats(v, nil, queueFilepath); err == nil {
// it prevents reading extra heartbeats again from stdin when we're rate limited.
// Otherwise, it would fail to read.
v.Set("extra-heartbeats", false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this... it seems brittle.

@gandarez gandarez closed this Jul 24, 2024
auto-merge was automatically disabled July 24, 2024 18:31

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants