Skip to content

Commit

Permalink
add go-max-procs annotation (#333)
Browse files Browse the repository at this point in the history
* add go-max-procs annotation

* Update changelog

Co-authored-by: Christopher Swenson <[email protected]>
  • Loading branch information
packageman and Christopher Swenson authored Apr 28, 2022
1 parent 15f3572 commit 0e73c98
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Features:
* Add agent-enable-quit annotation [GH-330](https://github.com/hashicorp/vault-k8s/pull/330)
* Add go-max-procs annotation [GH-333](https://github.com/hashicorp/vault-k8s/pull/333)

## 0.15.0 (March 21, 2022)

Expand Down
4 changes: 4 additions & 0 deletions agent-inject/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ type Vault struct {
// make a request to the Vault server.
ClientTimeout string

// GoMaxProcs sets the Vault Agent go max procs.
GoMaxProcs string

// LogLevel sets the Vault Agent log level. Defaults to info.
LogLevel string

Expand Down Expand Up @@ -337,6 +340,7 @@ func New(pod *corev1.Pod, patches []*jsonpatch.JsonPatchOperation) (*Agent, erro
ClientKey: pod.Annotations[AnnotationVaultClientKey],
ClientMaxRetries: pod.Annotations[AnnotationVaultClientMaxRetries],
ClientTimeout: pod.Annotations[AnnotationVaultClientTimeout],
GoMaxProcs: pod.Annotations[AnnotationVaultGoMaxProcs],
LogLevel: pod.Annotations[AnnotationVaultLogLevel],
LogFormat: pod.Annotations[AnnotationVaultLogFormat],
Namespace: pod.Annotations[AnnotationVaultNamespace],
Expand Down
3 changes: 3 additions & 0 deletions agent-inject/agent/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ const (
// AnnotationVaultClientTimeout sets the request timeout when communicating with Vault.
AnnotationVaultClientTimeout = "vault.hashicorp.com/client-timeout"

// AnnotationVaultGoMaxProcs sets the Vault Agent go max procs.
AnnotationVaultGoMaxProcs = "vault.hashicorp.com/go-max-procs"

// AnnotationVaultLogLevel sets the Vault Agent log level.
AnnotationVaultLogLevel = "vault.hashicorp.com/log-level"

Expand Down
7 changes: 7 additions & 0 deletions agent-inject/agent/container_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
func (a *Agent) ContainerEnvVars(init bool) ([]corev1.EnvVar, error) {
var envs []corev1.EnvVar

if a.Vault.GoMaxProcs != "" {
envs = append(envs, corev1.EnvVar{
Name: "GOMAXPROCS",
Value: a.Vault.GoMaxProcs,
})
}

if a.Vault.ClientTimeout != "" {
envs = append(envs, corev1.EnvVar{
Name: "VAULT_CLIENT_TIMEOUT",
Expand Down
1 change: 1 addition & 0 deletions agent-inject/agent/container_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestContainerEnvs(t *testing.T) {
{Agent{Vault: Vault{ClientTimeout: "5s"}}, []string{"VAULT_CONFIG", "VAULT_CLIENT_TIMEOUT"}},
{Agent{Vault: Vault{ClientMaxRetries: "0", ClientTimeout: "5s"}}, []string{"VAULT_CONFIG", "VAULT_MAX_RETRIES", "VAULT_CLIENT_TIMEOUT"}},
{Agent{ConfigMapName: "foobar", Vault: Vault{ClientMaxRetries: "0", ClientTimeout: "5s", LogLevel: "info", ProxyAddress: "http://proxy:3128"}}, []string{"VAULT_MAX_RETRIES", "VAULT_CLIENT_TIMEOUT", "VAULT_LOG_LEVEL", "HTTPS_PROXY"}},
{Agent{Vault: Vault{GoMaxProcs: "1"}}, []string{"VAULT_CONFIG", "GOMAXPROCS"}},
}

for _, tt := range tests {
Expand Down

0 comments on commit 0e73c98

Please sign in to comment.