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

[Filebeat] Add pubsub_alternative_host to gcp pubsub input #23215

Merged
merged 5 commits into from
Dec 22, 2020

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Dec 18, 2020

What does this PR do?

Adds an option to set a custom pubsub alternative host to pubsub input.

Why is it important?

To be able to start the input using the GCP Pubsub emulator we needed a way to configure it to point to our testing host and bypass credential initialization.

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 (we do not want to document that as it is intended for testing)
    - [ ] 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.

@marc-gr marc-gr added enhancement Filebeat Filebeat needs_backport PR is waiting to be backported to other branches. Team:Security-External Integrations labels Dec 18, 2020
@marc-gr marc-gr requested a review from a team December 18, 2020 15:02
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Dec 18, 2020
@marc-gr marc-gr mentioned this pull request Dec 18, 2020
2 tasks
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 18, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #23215 updated

  • Start Time: 2020-12-22T10:46:46.680+0000

  • Duration: 46 min 35 sec

Test stats 🧪

Test Results
Failed 0
Passed 2445
Skipped 263
Total 2708

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 2445
Skipped 263
Total 2708

return nil, fmt.Errorf("grpc.Dial: %v", err)
}
opts = append(opts, option.WithGRPCConn(conn), option.WithTelemetryDisabled())
} else if in.CredentialsFile != "" {
Copy link
Member

Choose a reason for hiding this comment

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

The PubsubAlternativeHost and Credentials* options are not mutually exclusive, right?

Suggested change
} else if in.CredentialsFile != "" {
}
if in.CredentialsFile != "" {

@@ -36,6 +36,8 @@ type config struct {

// JSON blob containing authentication credentials and key.
CredentialsJSON []byte `config:"credentials_json"`

PubsubAlternativeHost string `config:"pubsub_alternative_host"`
Copy link
Member

Choose a reason for hiding this comment

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

I'm debating about the pubsub prefix. I thinking to remove it since the package is called pubsub and the in config it will be part of the gcp-pubsub input.

Suggested change
PubsubAlternativeHost string `config:"pubsub_alternative_host"`
// Overrides the default Pub/Sub service address and disables TLS. For testing.
AlternativeHost string `config:"alternative_host"`

// this will be typically set because we want to point the input to a testing pubsub emulator
conn, err := grpc.Dial(in.PubsubAlternativeHost, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("grpc.Dial: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("grpc.Dial: %v", err)
return nil, fmt.Errorf("grpc.Dial: %w", err)

Comment on lines 15 to 17
"google.golang.org/grpc"

"cloud.google.com/go/pubsub"
"github.com/pkg/errors"
"google.golang.org/api/option"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"google.golang.org/grpc"
"cloud.google.com/go/pubsub"
"github.com/pkg/errors"
"google.golang.org/api/option"
"cloud.google.com/go/pubsub"
"github.com/pkg/errors"
"google.golang.org/api/option"
"google.golang.org/grpc"

// this will be typically set because we want to point the input to a testing pubsub emulator
conn, err := grpc.Dial(in.AlternativeHost, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("grpc.Dial: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this error more descriptive? "cannot connect to alternative_host" or similar

@marc-gr marc-gr requested a review from adriansr December 21, 2020 11:22
@marc-gr marc-gr force-pushed the pubsub-alt-host branch 2 times, most recently from dc20b57 to 7a947e3 Compare December 21, 2020 15:14
@marc-gr marc-gr merged commit 545598f into elastic:master Dec 22, 2020
@marc-gr marc-gr deleted the pubsub-alt-host branch December 22, 2020 11:51
@marc-gr marc-gr removed the needs_backport PR is waiting to be backported to other branches. label Dec 22, 2020
marc-gr added a commit to marc-gr/beats that referenced this pull request Dec 22, 2020
…3215)

* Add pubsub_alternative_host to gcp pubsub input

* Apply suggestions

* Add changelog entry

* Add new option comment

* Make error more descriptive and reorder imports

(cherry picked from commit 545598f)
marc-gr added a commit to marc-gr/beats that referenced this pull request Dec 22, 2020
…3215)

* Add pubsub_alternative_host to gcp pubsub input

* Apply suggestions

* Add changelog entry

* Add new option comment

* Make error more descriptive and reorder imports

(cherry picked from commit 545598f)
marc-gr added a commit that referenced this pull request Dec 22, 2020
…23245)

* Add pubsub_alternative_host to gcp pubsub input

* Apply suggestions

* Add changelog entry

* Add new option comment

* Make error more descriptive and reorder imports

(cherry picked from commit 545598f)
marc-gr added a commit that referenced this pull request Dec 22, 2020
…23244)

* Add pubsub_alternative_host to gcp pubsub input

* Apply suggestions

* Add changelog entry

* Add new option comment

* Make error more descriptive and reorder imports

(cherry picked from commit 545598f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants