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

Cherry-pick #16287 to 7.6: Fix timeout option of Functionbeat #16578

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Functionbeat*

- Fix timeout option of GCP functions. {issue}16282[16282] {pull}16287[16287]

==== Added

Expand Down
7 changes: 3 additions & 4 deletions x-pack/functionbeat/manager/gcp/template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"path/filepath"
"time"

cloudfunctions "google.golang.org/api/cloudfunctions/v1"
yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -115,7 +114,7 @@ func (d *defaultTemplateBuilder) cloudFunction(name string, config *fngcp.Functi
Runtime: runtime,
ServiceAccountEmail: config.ServiceAccountEmail,
SourceArchiveUrl: sourceArchiveURL,
Timeout: config.Timeout.String(),
Timeout: config.Timeout,
VpcConnector: config.VPCConnector,
}
}
Expand All @@ -142,8 +141,8 @@ func (d *defaultTemplateBuilder) RawTemplate(name string) (string, error) {
},
}

if config.Timeout > 0*time.Second {
properties["timeout"] = config.Timeout.String()
if config.Timeout != "" {
properties["timeout"] = config.Timeout
}
if config.MemorySize != "" {
properties["availableMemoryMb"] = config.MemorySize
Expand Down
3 changes: 1 addition & 2 deletions x-pack/functionbeat/provider/gcp/gcp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ package gcp

import (
"fmt"
"time"
)

// FunctionConfig stores the configuration of a Google Cloud Function
type FunctionConfig struct {
Description string `config:"description"`
MemorySize string `config:"memory_size"`
Timeout time.Duration `config:"timeout" validate:"nonzero,positive"`
Timeout string `config:"timeout"`
ServiceAccountEmail string `config:"service_account_email"`
Labels map[string]string `config:"labels"`
VPCConnector string `config:"vpc_connector"`
Expand Down