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

Start to split filebeat/channel up #17655

Merged
merged 5 commits into from
Apr 30, 2020
Merged

Start to split filebeat/channel up #17655

merged 5 commits into from
Apr 30, 2020

Conversation

urso
Copy link

@urso urso commented Apr 9, 2020

  • Refactoring

What does this PR do?

The Factory in filebeat/channel package wraps the publisher pipeline, in order to add some shutdown propagation support, but also to modify the beat.ClientConfig when an input is configured. The channel.Connector reads and applies common settings for all inputs, configures Guaranteed sending, and hooks up a global counter with each beat.Client, in order to track live events.

This change reduces the responsibilities of the factory, by splitting them up. A package libbeat/publisher/pipetool is introduced to provide helper functions for modifying a beat.Pipeline before and after Connect. This centers support for more functionality on the beat.PipelineConnector and beat.Client interfaces, instead of incompatible types wrapping the pipeline.

The Factory in filebeat/channel will not modify the input configuration or the beat.Client anymore. It is only required to add shutdown signaling to the pipeline (which we will remove in the future as well). The filebeat/channel provides a helper function for decorating a cfgfile.RunnerFactory, such that common configurations are still applied as before. Again, by centering around a small set of common interfaces, reduce the effort to integrate future input refactorings.

All in all, the filebeat/channel factory still provides the same functionality as before (for now), but splits the different functionalities into 3 separate interfaces.

Why is it important?

Support ease of integration of new input API, based on RunnerFactory only.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
    - [ ] I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@urso urso added in progress Pull request is currently in progress. refactoring Filebeat Filebeat libbeat Team:Services (Deprecated) Label for the former Integrations-Services team labels Apr 9, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@@ -235,8 +237,11 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
return err
}

fb.pipeline = pipetool.WithPipelineEventCounter(b.Publisher, wgEvents)
fb.pipeline = pipetool.WithDefaultGuarantees(fb.pipeline, beat.GuaranteedSend)
Copy link
Author

Choose a reason for hiding this comment

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

When doing this change I noticed wgEvents was propably not hooked up correctly. This PR might fix an issue or flaky tests with shutdown timeout not working correctly.

@urso urso requested review from ycombinator and kvch April 9, 2020 22:22
@urso urso changed the title Fb pipetool Start to split filebeat/channel up Apr 10, 2020
@urso urso marked this pull request as draft April 10, 2020 14:09
@urso urso added review [zube]: In Review and removed in progress Pull request is currently in progress. [zube]: In Progress labels Apr 15, 2020
@urso urso marked this pull request as ready for review April 15, 2020 13:42
@@ -62,7 +62,7 @@ func newCrawler(

// Start starts the crawler with all inputs
func (c *crawler) Start(
pipeline beat.Pipeline,
pipeline beat.PipelineConnector,
Copy link
Author

Choose a reason for hiding this comment

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

PipelineConnector is the 'smaller' interface. I hope to merge Pipeline and PipelineConnector interfaces in the future, such that Pipeline will not have any extra methods anymore.


type onCreateFactory struct {
factory cfgfile.RunnerFactory
edit onCreateWrapper
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: call this create instead of edit?

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM.

@urso
Copy link
Author

urso commented Apr 16, 2020

Jenkins, run tests

@urso
Copy link
Author

urso commented Apr 16, 2020

jenkins run the tests please

urso added 2 commits April 29, 2020 14:26
The Factory in filebeat/channel package wraps the publisher pipeline, in order to
add some shutdown propagation support, but also to modify the
beat.ClientConfig when an input is configured. The channel.Connector reads and
applies common settings for all inputs, configures Guaranteed sending,
and hooks up a global counter with each beat.Client, in order to track
live events.

This change reduces the responsibilities of the factory, by splitting
them up. A package libbeat/publisher/pipetool is introduced to provide
helper functions for modifying a beat.Pipeline before and after
Connect. This centers support for more functionality on the beat.PipelineConnector
and beat.Client interfaces, instead of incompatible types wrapping the
pipeline.
The Factory in filebeat/channel will not modify the input configuration
or the beat.Client anymore. It is only required to add shutdown
signaling to the pipeline (which we will remove in the future as well).
The filebeat/channel provides a helper function for decorating a
cfgfile.RunnerFactory, such that common configurations are still applied
as before. Again, by centering around a small set of common interfaces,
reduce the effort to integrate future input refactorings.

All in all, the filebeat/channel factory still provides the same
functionality as before (for now), but splits the different
functionalities into 3 separate interfaces.
urso added 2 commits April 29, 2020 14:26
The way the counter support is setup is very specific for filebeat
and how Filebeat hooks up a global ACKer, and the Registrar for storing
file.State. Moving it to filebeat to not encourage someone to use a it.
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 29, 2020

💔 Build Failed

Pipeline View Test View Changes Artifacts preview stats

Expand to view the summary

Build stats

Test stats 🧪

Test Results
Failed 1
Passed 7696
Skipped 1238
Total 8935

Test errors

Expand to view the tests failures

  • Name: Build and Test / Filebeat Windows / test_close_renamed – test_harvester.Test

    • Status: FAILED
    • Age: 2
    • Duration: 0.557
    • Error Details: [Errno 2] No such file or directory: 'C:\Users\jenkins\workspace\Beats_beats-beats-mbp_PR-17655\src\github.com\elastic\beats\filebeat\build\system-tests\run\test_harvester.Test.test_close_renamed\registry/filebeat/data.json'

Steps errors

Expand to view the steps failures

  • Name: Mage build unitTest

    • Description: mage build unitTest

    • Result: FAILURE

    • Duration: 10 min 3 sec<

    • Start Time: 2020-04-29T16:04:16.609+0000

  • Name: Make -C generator/_templates/metricbeat test

    • Description: make -C generator/_templates/metricbeat test

    • Result: FAILURE

    • Duration: 2 min 26 sec<

    • Start Time: 2020-04-29T16:00:15.798+0000

Log output

Expand to view the last 100 lines of log output

[2020-04-29T16:41:56.184Z] [success] 4.72% test_base.Test.test_fields_not_under_root: 1.3330s
[2020-04-29T16:41:56.184Z] [success] 2.25% test_monitor.Test.test_http_json_0_up: 0.6341s
[2020-04-29T16:41:56.184Z] [success] 2.21% test_monitor.Test.test_json_simple_comparisons_1__foo_true_: 0.6236s
[2020-04-29T16:41:56.184Z] [success] 2.21% test_monitor.Test.test_json_simple_comparisons_2__foo_3_: 0.6229s
[2020-04-29T16:41:56.185Z] [success] 2.21% test_monitor.Test.test_http_json_2_down: 0.6227s
[2020-04-29T16:41:56.185Z] [success] 2.20% test_monitor.Test.test_json_simple_comparisons_0__foo_bar_: 0.6213s
[2020-04-29T16:41:56.185Z] [success] 2.19% test_monitor.Test.test_http_json_1_down: 0.6187s
[2020-04-29T16:41:56.185Z] [success] 1.31% test_base.Test.test_base: 0.3687s
[2020-04-29T16:41:56.185Z] ----------------------------------------------------------------------
[2020-04-29T16:41:56.185Z] Ran 25 tests in 34.879s
[2020-04-29T16:41:56.185Z] 
[2020-04-29T16:41:56.185Z] OK (SKIP=9)
[2020-04-29T16:41:56.185Z] >> python test: Unit Testing Complete
[2020-04-29T16:41:56.237Z] Recording test results
[2020-04-29T16:42:01.859Z] Archiving artifacts
[2020-04-29T16:44:04.415Z] 
Creating appsearch_7918a246f6f8_appsearch_1      ... done
.Stopping appsearch_7918a246f6f8_appsearch_1      ... 
[2020-04-29T16:44:04.415Z] Stopping appsearch_7918a246f6f8_elasticsearch_1  ... 
[2020-04-29T16:44:04.415Z] 
Stopping appsearch_7918a246f6f8_appsearch_1      ... done

Stopping appsearch_7918a246f6f8_elasticsearch_1  ... done
Removing appsearch_7918a246f6f8_appsearch_1      ... 
[2020-04-29T16:44:04.415Z] Removing appsearch_7918a246f6f8_elasticsearch_1  ... 
[2020-04-29T16:44:06.326Z] 
Removing appsearch_7918a246f6f8_elasticsearch_1  ... done

Removing appsearch_7918a246f6f8_appsearch_1      ... done
Creating cockroachdb_7918a246f6f8_cockroachdb_1  ... 
[2020-04-29T16:44:12.491Z] 
Creating cockroachdb_7918a246f6f8_cockroachdb_1  ... done
.Stopping cockroachdb_7918a246f6f8_cockroachdb_1  ... 
[2020-04-29T16:44:12.491Z] 
Stopping cockroachdb_7918a246f6f8_cockroachdb_1  ... done
Removing cockroachdb_7918a246f6f8_cockroachdb_1  ... 
[2020-04-29T16:44:13.485Z] 
Removing cockroachdb_7918a246f6f8_cockroachdb_1  ... done
Creating coredns_7918a246f6f8_coredns_1          ... 
[2020-04-29T16:44:23.585Z] 
Creating coredns_7918a246f6f8_coredns_1          ... done
.Stopping coredns_7918a246f6f8_coredns_1          ... 
[2020-04-29T16:44:23.585Z] 
Stopping coredns_7918a246f6f8_coredns_1          ... done
Removing coredns_7918a246f6f8_coredns_1          ... 
[2020-04-29T16:44:24.798Z] 
Removing coredns_7918a246f6f8_coredns_1          ... done
Creating ibmmq_7918a246f6f8_ibmmq_1              ... 
[2020-04-29T16:44:52.859Z] 
Creating ibmmq_7918a246f6f8_ibmmq_1              ... done
.Stopping ibmmq_7918a246f6f8_ibmmq_1              ... 
[2020-04-29T16:44:52.860Z] 
Stopping ibmmq_7918a246f6f8_ibmmq_1              ... done
Removing ibmmq_7918a246f6f8_ibmmq_1              ... 
[2020-04-29T16:44:53.814Z] 
Removing ibmmq_7918a246f6f8_ibmmq_1              ... done
Creating mssql_7918a246f6f8_mssql_1              ... 
[2020-04-29T16:45:17.717Z] 
Creating mssql_7918a246f6f8_mssql_1              ... done
..Stopping mssql_7918a246f6f8_mssql_1              ... 
[2020-04-29T16:45:27.744Z] 
Stopping mssql_7918a246f6f8_mssql_1              ... done
Removing mssql_7918a246f6f8_mssql_1              ... 
[2020-04-29T16:45:31.966Z] 
Removing mssql_7918a246f6f8_mssql_1              ... done
Creating openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... 
[2020-04-29T16:45:38.949Z] 
Creating openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... done
.Stopping openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... 
[2020-04-29T16:45:39.483Z] 
Stopping openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... done
Removing openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... 
[2020-04-29T16:45:40.879Z] 
Removing openmetrics_7918a246f6f8_openmetrics-node_exporter_1 ... done
Creating redisenterprise_944048c6fa54e151_redisenterprise_1   ... 
[2020-04-29T16:48:22.730Z] 
Creating redisenterprise_944048c6fa54e151_redisenterprise_1   ... done
..Stopping redisenterprise_944048c6fa54e151_redisenterprise_1   ... 
[2020-04-29T16:48:28.062Z] 
Stopping redisenterprise_944048c6fa54e151_redisenterprise_1   ... done
Removing redisenterprise_944048c6fa54e151_redisenterprise_1   ... 
[2020-04-29T16:48:29.013Z] 
Removing redisenterprise_944048c6fa54e151_redisenterprise_1   ... done
Creating sql_7918a246f6f8_mysql_1                             ... 
[2020-04-29T16:48:52.954Z] 
Creating sql_7918a246f6f8_mysql_1                             ... done
.Stopping sql_7918a246f6f8_mysql_1                             ... 
[2020-04-29T16:48:52.954Z] 
Stopping sql_7918a246f6f8_mysql_1                             ... done
Removing sql_7918a246f6f8_mysql_1                             ... 
[2020-04-29T16:48:53.222Z] 
Removing sql_7918a246f6f8_mysql_1                             ... done
Creating stan_7918a246f6f8_stan_1                             ... 
[2020-04-29T16:49:06.021Z] 
Creating stan_7918a246f6f8_stan_1                             ... done
...Stopping stan_7918a246f6f8_stan_1                             ... 
[2020-04-29T16:49:16.405Z] 
Stopping stan_7918a246f6f8_stan_1                             ... done
Removing stan_7918a246f6f8_stan_1                             ... 
[2020-04-29T16:49:23.015Z] 
Removing stan_7918a246f6f8_stan_1                             ... done
.
[2020-04-29T16:49:23.015Z] [success] 62.55% test_xpack_base.Test.test_dashboards: 94.9845s
[2020-04-29T16:49:23.015Z] [success] 5.22% test_activemq.ActiveMqTest_0.test_broker_metrics_collected: 7.9320s
[2020-04-29T16:49:23.015Z] [success] 4.09% test_statsd.Test.test_server: 6.2157s
[2020-04-29T16:49:23.015Z] [success] 3.15% test_xpack_base.Test.test_migration: 4.7855s
[2020-04-29T16:49:23.015Z] [success] 2.49% test_sql.Test.test_query: 3.7800s
[2020-04-29T16:49:23.015Z] [success] 2.09% test_xpack_base.Test.test_template: 3.1752s
[2020-04-29T16:49:23.015Z] [success] 1.96% test_openmetrics.Test.test_openmetrics: 2.9834s
[2020-04-29T16:49:23.015Z] [success] 1.83% test_stan.TestStan.test_metricset_2_subscriptions: 2.7798s
[2020-04-29T16:49:23.015Z] [success] 1.67% test_appsearch.Test.test_stats: 2.5424s
[2020-04-29T16:49:23.015Z] [success] 1.56% test_redisenterprise.Test_0.test_metricset_0_node: 2.3665s
[2020-04-29T16:49:23.015Z] [success] 1.53% test_redisenterprise.Test_0.test_metricset_1_proxy: 2.3193s
[2020-04-29T16:49:23.015Z] [success] 1.18% test_stan.TestStan.test_metricset_1_channels: 1.7900s
[2020-04-29T16:49:23.015Z] [success] 1.00% test_activemq.ActiveMqTest_1.test_topic_metrics_collected: 1.5222s
[2020-04-29T16:49:23.015Z] [success] 0.97% test_activemq.ActiveMqTest_0.test_topic_metrics_collected: 1.4781s
[2020-04-29T16:49:23.015Z] [success] 0.95% test_ibmmq.Test.test_qmgr: 1.4458s
[2020-04-29T16:49:23.016Z] [success] 0.95% test_activemq.ActiveMqTest_1.test_broker_metrics_collected: 1.4404s
[2020-04-29T16:49:23.016Z] [success] 0.91% test_stan.TestStan.test_metricset_0_stats: 1.3836s
[2020-04-29T16:49:23.016Z] [success] 0.90% test_mssql.Test.test_performance: 1.3658s
[2020-04-29T16:49:23.016Z] [success] 0.88% test_cockroachdb.Test.test_status: 1.3402s
[2020-04-29T16:49:23.016Z] [success] 0.88% test_coredns.Test.test_stats: 1.3294s
[2020-04-29T16:49:23.016Z] [success] 0.87% test_activemq.ActiveMqTest_1.test_queue_metrics_collected: 1.3139s
[2020-04-29T16:49:23.016Z] [success] 0.83% test_activemq.ActiveMqTest_0.test_queue_metrics_collected: 1.2561s
[2020-04-29T16:49:23.016Z] [success] 0.83% test_mssql.Test.test_status: 1.2538s
[2020-04-29T16:49:23.016Z] [success] 0.70% test_xpack_base.Test.test_start_stop: 1.0649s
[2020-04-29T16:49:23.016Z] ----------------------------------------------------------------------
[2020-04-29T16:49:23.016Z] Ran 24 tests in 919.808s
[2020-04-29T16:49:23.016Z] 
[2020-04-29T16:49:23.016Z] OK
[2020-04-29T16:49:23.016Z] >> python test: Integration Testing Complete
[2020-04-29T16:49:23.016Z] >> Stopping Docker test environment...
[2020-04-29T16:49:28.420Z] Recording test results
[2020-04-29T16:49:33.913Z] Archiving artifacts
[2020-04-29T16:49:35.338Z] + curl -sSLo codecov https://codecov.io/bash
[2020-04-29T16:49:35.912Z] + FILE=auditbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f auditbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=filebeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f filebeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=heartbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f heartbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=libbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f libbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=metricbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f metricbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=packetbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f packetbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=winlogbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f winlogbeat/build/coverage/full.cov ]
[2020-04-29T16:49:35.912Z] + FILE=journalbeat/build/coverage/full.cov
[2020-04-29T16:49:35.912Z] + [ -f journalbeat/build/coverage/full.cov ]
[2020-04-29T16:49:37.796Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-17655
[2020-04-29T16:49:38.044Z] [INFO] getVaultSecret: Getting secrets
[2020-04-29T16:49:38.097Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-04-29T16:49:38.741Z] + chmod 755 generate-build-data.sh
[2020-04-29T16:49:38.741Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-17655/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-17655/runs/14 FAILURE 4866519
[2020-04-29T16:49:38.991Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-17655/runs/14/steps/?limit=10000 -o steps-info.json
[2020-04-29T16:49:39.542Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-17655/runs/14/tests/?status=FAILED -o tests-errors.json

@urso urso merged commit bc8123a into elastic:master Apr 30, 2020
@urso urso deleted the fb-pipetool branch April 30, 2020 19:43
@urso urso added the needs_backport PR is waiting to be backported to other branches. label Apr 30, 2020
@urso urso added v7.9.0 and removed needs_backport PR is waiting to be backported to other branches. labels Jul 3, 2020
urso pushed a commit to urso/beats that referenced this pull request Jul 3, 2020
urso pushed a commit that referenced this pull request Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Filebeat Filebeat libbeat refactoring review Team:Services (Deprecated) Label for the former Integrations-Services team v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants