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

Clean up config checks / fix heartbeat NPE #11165

Merged
merged 1 commit into from
May 6, 2019

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Mar 8, 2019

This fixes a bug where heartbeat would encounter an NPE while attempting to free resources during a config check and cleans up some internal interfaces.

This change lets beats choose whether their factories implement a special config check function. If not, it is assumed their creation function will return an error and that this can be used for checking the config. It is further assumed that creation with the factory is fully GC-able, which is not the case for heartbeat, hence the need for a custom CheckConfig method.

@andrewvc andrewvc added bug needs_backport PR is waiting to be backported to other branches. Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team labels Mar 8, 2019
@andrewvc andrewvc self-assigned this Mar 8, 2019
@andrewvc andrewvc requested a review from ruflin March 8, 2019 17:34
@andrewvc andrewvc requested a review from a team as a code owner March 8, 2019 17:34
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime

m1, m1Err := makeTestMon()
assert.NoError(t, m1Err)
require.NoError(t, m1Err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are now require because subsequent assertions make no sense if prior ones fail.

@andrewvc andrewvc force-pushed the fix-bad-check-config branch from 7d0bc02 to c62d376 Compare March 8, 2019 17:36
@andrewvc andrewvc requested a review from a team as a code owner March 9, 2019 00:41
@andrewvc
Copy link
Contributor Author

andrewvc commented Mar 9, 2019

This also fixes a libbeat bug where the dynamic config reloading code would start the runners specified in the factory as part of the check, but never stop them. This uses the proper Check method which should allow cleanup.

I tried adding a test for this, but the code is quite hard to mock and stub. It probably needs a refactor beyond the scope of this PR to become more testable.

Copy link
Collaborator

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

I like the implementation with the Unsafe and Check config.

This will also need a changelog entry.

@andrewvc
Copy link
Contributor Author

@ruflin should be ready for another pass, I think I've addressed all your concerns.

Copy link
Collaborator

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

CI failure looks related.

}
}()

if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use just return err, no additional check needed.

@andrewvc andrewvc force-pushed the fix-bad-check-config branch from b277a43 to 409af72 Compare March 28, 2019 17:08
@andrewvc
Copy link
Contributor Author

@ruflin implemented a totally new approach in 7501885 . This wipes out much of the old work, except what was in the heartbeat folder. We now make the implementation of CheckConfig optional. Only heartbeat implements it at the moment.

@ruflin
Copy link
Collaborator

ruflin commented Apr 8, 2019

I like this change as it is it removes the non implemented methods and allows Heartbeat to move forward with the interface.

Copy link
Collaborator

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Overall change LGTM. You will need to rebase, and can you also add a changelog entry?

@andrewvc andrewvc changed the title [Heartbeat] Fix NPE on config check Clean up config checks / fix heartbeat NPE May 1, 2019
@andrewvc
Copy link
Contributor Author

andrewvc commented May 1, 2019

@ruflin fixed merge conflicts, updated the issue description / title (so that it will make a better commit message) and added a changelog entry. Can I get a final LGTM?

@ruflin
Copy link
Collaborator

ruflin commented May 3, 2019

jenkins, test this

Copy link
Collaborator

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

LGTM. I like the solution that was found here and I hope we didn't miss any side effects.

There are 3 files in vendor directory which changed in this PR which I think shouldn't ...

@@ -4,7 +4,6 @@ package tlsconfig

import (
"crypto/x509"
Copy link
Collaborator

Choose a reason for hiding this comment

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

How did these vendor changes slip in here? Also see below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed via a new squashed commit. Something weird was going on with git, but squashing fixed it. I couldn't remove them in subsequent commits weirdly.

@andrewvc andrewvc force-pushed the fix-bad-check-config branch from 2da47d0 to a93aa27 Compare May 3, 2019 19:34
@ruflin
Copy link
Collaborator

ruflin commented May 6, 2019

@andrewvc The travis build was failing for Heartbeat, but I don't think related at all. I restarted it .

@andrewvc
Copy link
Contributor Author

andrewvc commented May 6, 2019

Merging. Failures are unrelated. Metricbeat tests keep failing for different reasons. Out of three tries, two for package management servers being down.

@andrewvc andrewvc merged commit dcce078 into elastic:master May 6, 2019
@andrewvc andrewvc deleted the fix-bad-check-config branch May 6, 2019 16:36
andrewvc added a commit to andrewvc/beats that referenced this pull request May 6, 2019
This fixes a bug where heartbeat would encounter an NPE while attempting to free resources during a config check and cleans up some internal interfaces.

This change lets beats choose whether their factories implement a special config check function. If not, it is assumed their creation function will return an error and that this can be used for checking the config. It is further assumed that creation with the factory is fully GC-able, which is not the case for heartbeat, hence the need for a custom CheckConfig method.

(cherry picked from commit dcce078)
@andrewvc andrewvc added v7.0.2 and removed needs_backport PR is waiting to be backported to other branches. labels May 6, 2019
@andrewvc andrewvc added the v7.1.0 label May 9, 2019
andrewvc added a commit to andrewvc/beats that referenced this pull request May 9, 2019
This fixes a bug where heartbeat would encounter an NPE while attempting to free resources during a config check and cleans up some internal interfaces.

This change lets beats choose whether their factories implement a special config check function. If not, it is assumed their creation function will return an error and that this can be used for checking the config. It is further assumed that creation with the factory is fully GC-able, which is not the case for heartbeat, hence the need for a custom CheckConfig method.

(cherry picked from commit dcce078)
andrewvc added a commit to andrewvc/beats that referenced this pull request May 29, 2019
This fixes a bug where heartbeat would encounter an NPE while attempting to free resources during a config check and cleans up some internal interfaces.

This change lets beats choose whether their factories implement a special config check function. If not, it is assumed their creation function will return an error and that this can be used for checking the config. It is further assumed that creation with the factory is fully GC-able, which is not the case for heartbeat, hence the need for a custom CheckConfig method.

(cherry picked from commit dcce078)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Filebeat Filebeat Heartbeat libbeat Metricbeat Metricbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.0.2 v7.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants