-
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] Refactor config system #23467
Conversation
The rationale here is that doing so resolves any file permissions issues that may be present due to the suite directory being shared to the container as read only OR due to incompatible UIDs between the docker container and the host. Fixes elastic/synthetics#156
@@ -220,15 +234,7 @@ func makeAddSummary(monitorType string) jobs.JobWrapper { | |||
if state.remaining == 0 { | |||
up := state.up | |||
down := state.down | |||
if monitorType == "browser" { |
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.
Now handled directly in the browser type
|
||
// setupOnlineDir is run in environments with internet access and attempts to make sure the node env | ||
// is setup correctly. | ||
func setupOnlineDir(dir string) (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.
I don't have tests for this because this requires an internet connection and NPM to be functioning. Our E2E tests in synthetics will ultimately catch issues here. See #23346
Pinging @elastic/uptime (Team:Uptime) |
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.
Wow that was big! Overall this looks good.
I made a few comments, but no blockers. Also seems like your imports are random. I know we have discussed that before (about how annoying go fmt doesnt fix it), but it just make the code look dirty.
@@ -131,22 +124,30 @@ func (bt *Heartbeat) Run(b *beat.Beat) error { | |||
} | |||
|
|||
// RunStaticMonitors runs the `heartbeat.monitors` portion of the yaml config if present. | |||
func (bt *Heartbeat) RunStaticMonitors(b *beat.Beat) error { | |||
func (bt *Heartbeat) RunStaticMonitors(b *beat.Beat) (stop func(), 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.
I think this can be change to RunMonitors
, seems that there is only one type of monitor at this level of the code.
@@ -89,29 +90,30 @@ func (jf *jobFactory) checkConfig() error { | |||
return nil | |||
} | |||
|
|||
func (jf *jobFactory) makeJobs() (j []jobs.Job, endpoints int, err error) { | |||
func (jf *jobFactory) makePlugin() (plugin2 plugin.Plugin, 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.
Why the names returned parameters? Seems that the code always defines the return in the statement of the function.
} | ||
|
||
j = append(j, wrappers.WithURLField(u, job)) | ||
} | ||
|
||
return j, len(jf.config.Hosts), nil | ||
return plugin.Plugin{Jobs: j, Close: nil, Endpoints: len(jf.config.Hosts)}, nil |
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.
Instead of having the caller know if Close
is set, it would be better to always set it (to an empty function).
Or add a Close()
function directly on the plugin that does the checking and calling of the actual function.
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.
Will do in a follow-up!
"github.com/elastic/beats/v7/libbeat/common" | ||
"github.com/elastic/beats/v7/libbeat/logp" | ||
"github.com/elastic/beats/v7/x-pack/heartbeat/monitors/browser/synthexec" | ||
) | ||
|
||
func init() { | ||
monitors.RegisterActive("browser", create) | ||
monitors.RegisterActive("synthetic/browser", create) | ||
plugin.Register("browser", create, "synthetic", "synthetics/synthetic") |
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.
Why the rename form synthetics/browser
to just synthetics/synthetic
? That just seems like weird naming.
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.
In the future we'd like to have a synthetics/api
, and we use the browser language across the board from UI to backend
* Refactors the config for synthetics suites to act as regular monitors under `heartbeat.monitors` rather than have the new top-level `synthetic.suites` syntax we've been using so far. * Changes the behavior of local suites to copy their data into the container rather than run directly off the shared docker volume * Adds a first-class notion of aliasing to monitor types, so that `synthetics/http` monitors show up as `http`, and not as a distinct type (applies to all monitor types) * Simplifies the types associated with monitor plugins into a new `plugin.Plugin{}` struct, rather than passing around multiple values everywhere. * See https://github.com/elastic/beats/pull/23467/files#diff-7f1e5387c4757cca1e98483a5678e377a28ca5f9d77b267a4121a14249c96b82R7 for an example of the new config syntax #### More on the change to copying local tests into the container The rationale here is that doing so resolves any file permissions issues that may be present due to the suite directory being shared to the container as read only OR due to incompatible UIDs between the docker container and the host. Fixes elastic/synthetics#156 Fixes elastic#23823 As a note, no tests are added here due to the complexity of testing this small amount of I/O functionality, however, any issues should be caught by our E2E tests in https://github.com/elastic/synthetics/tree/master/__tests__/e2e . I've opened an issue to improve this situation here: elastic#23346 (cherry picked from commit fb25ded)
…dows-7 * upstream/master: (332 commits) Use ECS v1.8.0 (elastic#24086) Add support for postgresql csv logs (elastic#23334) [Heartbeat] Refactor config system (elastic#23467) [CI] install docker-compose with retry (elastic#24069) Add nodes to filebeat-kubernetes.yaml ClusterRole - fixes elastic#24051 (elastic#24052) updating manifest files for filebeat threatintel module (elastic#24074) Add Zeek Signatures (elastic#23772) Update Beats to ECS 1.8.0 (elastic#23465) Support running Docker logging plugin on ARM64 (elastic#24034) Fix ec2 metricset fields.yml and add integration test (elastic#23726) Only build targz and zip versions of Beats if PACKAGES is set in agent (elastic#24060) [Filebeat] Add field definitions for known Netflow/IPFIX vendor fields (elastic#23773) [Elastic Agent] Enroll with Fleet Server (elastic#23865) [Filebeat] Convert logstash logEvent.action objects to strings (elastic#23944) [Ingest Management] Fix reloading of log level for services (elastic#24055) Add Agent standalone k8s manifest (elastic#23679) [Metricbeat][Kubernetes] Extend state_node with more conditions (elastic#23905) [CI] googleStorageUploadExt step (elastic#24048) Check fields are documented for aws metricsets (elastic#23887) Update go-concert to 0.1.0 (elastic#23770) ...
* Refactors the config for synthetics suites to act as regular monitors under `heartbeat.monitors` rather than have the new top-level `synthetic.suites` syntax we've been using so far. * Changes the behavior of local suites to copy their data into the container rather than run directly off the shared docker volume * Adds a first-class notion of aliasing to monitor types, so that `synthetics/http` monitors show up as `http`, and not as a distinct type (applies to all monitor types) * Simplifies the types associated with monitor plugins into a new `plugin.Plugin{}` struct, rather than passing around multiple values everywhere. * See https://github.com/elastic/beats/pull/23467/files#diff-7f1e5387c4757cca1e98483a5678e377a28ca5f9d77b267a4121a14249c96b82R7 for an example of the new config syntax #### More on the change to copying local tests into the container The rationale here is that doing so resolves any file permissions issues that may be present due to the suite directory being shared to the container as read only OR due to incompatible UIDs between the docker container and the host. Fixes elastic/synthetics#156 Fixes #23823 As a note, no tests are added here due to the complexity of testing this small amount of I/O functionality, however, any issues should be caught by our E2E tests in https://github.com/elastic/synthetics/tree/master/__tests__/e2e . I've opened an issue to improve this situation here: #23346 (cherry picked from commit fb25ded)
This PR:
heartbeat.monitors
rather than have the new top-levelsynthetic.suites
syntax we've been using so far.synthetics/http
monitors show up ashttp
, and not as a distinct type (applies to all monitor types)plugin.Plugin{}
struct, rather than passing around multiple values everywhere.More on the change to copying local tests into the container
The rationale here is that doing so resolves any file permissions issues that may be present due to the suite directory being shared to the container as read only OR due to incompatible UIDs between the docker container and the host.
Fixes elastic/synthetics#156
Fixes #23823
As a note, no tests are added here due to the complexity of testing this small amount of I/O functionality, however, any issues should be caught by our E2E tests in https://github.com/elastic/synthetics/tree/master/__tests__/e2e . I've opened an issue to improve this situation here: #23346
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Related issues
Takes over from #23347
Fixes elastic/synthetics#156
Fixes elastic/uptime#271
Use cases
Screenshots
Logs