Skip to content

Commit

Permalink
Fix Google Cloud Function configuration file issues (#22156)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR adds a new function to to `cfgfile` to set the path to the configuration file of a Beat. This fixes the issue on GCP with Functionbeat.

## Why is it important?

ATM Functionbeat cannot run on GCP.

## Related issues

Closes #20864
  • Loading branch information
kvch authored Oct 26, 2020
1 parent d36a510 commit 13a195a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Do not need Google credentials if not required for the operation. {issue}17329[17329] {pull}21072[21072]
- Fix dependency issues of GCP functions. {issue}20830[20830] {pull}21070[21070]
- Fix catchall bucket config errors by adding more validation. {issue}17572[16282] {pull}20887[16287]
- Fix Google Cloud Function configuration issue. {issue}20864[20864] {pull}22156[22156]

==== Added

Expand Down
4 changes: 4 additions & 0 deletions libbeat/cfgfile/cfgfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func LoadList(file string) ([]*common.Config, error) {
return c, nil
}

func SetConfigPath(path string) {
*configPath = path
}

// GetPathConfig returns ${path.config}. If ${path.config} is not set, ${path.home} is returned.
func GetPathConfig() string {
if *configPath != "" {
Expand Down
1 change: 1 addition & 0 deletions x-pack/functionbeat/provider/gcp/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func RunPubSub(ctx context.Context, m gpubsub.Message) error {
ConfigOverrides: config.FunctionOverrides,
}

cfgfile.SetConfigPath("/srv/src/pubsub")
cfgfile.ChangeDefaultCfgfileFlag(settings.Name)

return instance.Run(settings, initFunctionbeat(ctx, m))
Expand Down
1 change: 1 addition & 0 deletions x-pack/functionbeat/provider/gcp/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func RunCloudStorage(ctx context.Context, e gcp.StorageEvent) error {
ConfigOverrides: config.FunctionOverrides,
}

cfgfile.SetConfigPath("/srv/src/storage")
cfgfile.ChangeDefaultCfgfileFlag(settings.Name)

return instance.Run(settings, initFunctionbeat(ctx, e))
Expand Down
3 changes: 3 additions & 0 deletions x-pack/functionbeat/scripts/mage/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (Update) VendorBeats() error {
Exclude: []string{
".*_test.go$",
".*.yml",
// XXX GCP function metadata lib must be removed to avoid build failures
// GH issue: https://github.com/googleapis/google-cloud-go/issues/1947
".*cloud.google.com/go.*/functions/metadata.*",
},
}
err = cp.Execute()
Expand Down

0 comments on commit 13a195a

Please sign in to comment.