Skip to content

Commit 13a195a

Browse files
authored
Fix Google Cloud Function configuration file issues (elastic#22156)
## 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 elastic#20864
1 parent d36a510 commit 13a195a

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
400400
- Do not need Google credentials if not required for the operation. {issue}17329[17329] {pull}21072[21072]
401401
- Fix dependency issues of GCP functions. {issue}20830[20830] {pull}21070[21070]
402402
- Fix catchall bucket config errors by adding more validation. {issue}17572[16282] {pull}20887[16287]
403+
- Fix Google Cloud Function configuration issue. {issue}20864[20864] {pull}22156[22156]
403404

404405
==== Added
405406

libbeat/cfgfile/cfgfile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ func LoadList(file string) ([]*common.Config, error) {
205205
return c, nil
206206
}
207207

208+
func SetConfigPath(path string) {
209+
*configPath = path
210+
}
211+
208212
// GetPathConfig returns ${path.config}. If ${path.config} is not set, ${path.home} is returned.
209213
func GetPathConfig() string {
210214
if *configPath != "" {

x-pack/functionbeat/provider/gcp/pubsub/pubsub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func RunPubSub(ctx context.Context, m gpubsub.Message) error {
2929
ConfigOverrides: config.FunctionOverrides,
3030
}
3131

32+
cfgfile.SetConfigPath("/srv/src/pubsub")
3233
cfgfile.ChangeDefaultCfgfileFlag(settings.Name)
3334

3435
return instance.Run(settings, initFunctionbeat(ctx, m))

x-pack/functionbeat/provider/gcp/storage/storage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func RunCloudStorage(ctx context.Context, e gcp.StorageEvent) error {
2727
ConfigOverrides: config.FunctionOverrides,
2828
}
2929

30+
cfgfile.SetConfigPath("/srv/src/storage")
3031
cfgfile.ChangeDefaultCfgfileFlag(settings.Name)
3132

3233
return instance.Run(settings, initFunctionbeat(ctx, e))

x-pack/functionbeat/scripts/mage/update.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func (Update) VendorBeats() error {
7474
Exclude: []string{
7575
".*_test.go$",
7676
".*.yml",
77+
// XXX GCP function metadata lib must be removed to avoid build failures
78+
// GH issue: https://github.com/googleapis/google-cloud-go/issues/1947
79+
".*cloud.google.com/go.*/functions/metadata.*",
7780
},
7881
}
7982
err = cp.Execute()

0 commit comments

Comments
 (0)