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

Add timeout support for vault client #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ If your configuration is right and Vault is running on the same host as the agen

`frequency` How often to run the snapshot agent. Examples: `30s`, `1h`. See https://golang.org/pkg/time/#ParseDuration for a full list of valid time units.

`timeout` (Optional) Time out when running snapshot. Examples: `300s`, `1h`. Default: `60s`. See https://golang.org/pkg/time/#ParseDuration for a full list of valid time units.


### Default authentication mode
`role_id` Specifies the role_id used to call the Vault API. See the authentication steps below.
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Configuration struct {
Address string `json:"addr"`
Retain int64 `json:"retain"`
Frequency string `json:"frequency"`
Timeout string `json:"timeout,omitempty"`
AWS S3Config `json:"aws_storage"`
Local LocalConfig `json:"local_storage"`
GCP GCPConfig `json:"google_storage"`
Expand Down
8 changes: 8 additions & 0 deletions snapshot_agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func (s *Snapshotter) ConfigureVaultClient(config *config.Configuration) error {
if config.Address != "" {
vaultConfig.Address = config.Address
}

if config.Timeout != "" {
t, err := time.ParseDuration(config.Timeout)
if err == nil {
vaultConfig.HttpClient.Timeout = t
log.Printf("Vault http client timeout has been set to %s", vaultConfig.HttpClient.Timeout)
}
}
tlsConfig := &vaultApi.TLSConfig{
Insecure: true,
}
Expand Down