Skip to content

Commit

Permalink
add thanos config args
Browse files Browse the repository at this point in the history
Introducing missing arguments for thanos config interval and timeout.
thanos-io/thanos#5573
  • Loading branch information
viennaa committed Mar 8, 2023
1 parent 105ae14 commit 018eadd
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12477,6 +12477,32 @@ Duration
</tr>
<tr>
<td>
<code>getConfigInterval</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.Duration">
Duration
</a>
</em>
</td>
<td>
<p>GetConfigInterval is how often the Prometheus config is fetched. Default 30s.</p>
</td>
</tr>
<tr>
<td>
<code>getConfigTimeout</code><br/>
<em>
<a href="#monitoring.coreos.com/v1.Duration">
Duration
</a>
</em>
</td>
<td>
<p>GetConfigTimeout is the Timeout for getting Prometheus config. Default 5s.</p>
</td>
</tr>
<tr>
<td>
<code>volumeMounts</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#volumemount-v1-core">
Expand Down
10 changes: 10 additions & 0 deletions bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19670,6 +19670,16 @@ spec:
= 1h.'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigInterval:
description: GetConfigInterval is how often the Prometheus config
is fetched. Default 30s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigTimeout:
description: GetConfigTimeout is the Timeout for getting Prometheus
config. Default 5s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
grpcListenLocal:
description: If true, the Thanos sidecar listens on the loopback
interface for the gRPC endpoints. It has no effect if `listenLocal`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6683,6 +6683,16 @@ spec:
= 1h.'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigInterval:
description: GetConfigInterval is how often the Prometheus config
is fetched. Default 30s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigTimeout:
description: GetConfigTimeout is the Timeout for getting Prometheus
config. Default 5s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
grpcListenLocal:
description: If true, the Thanos sidecar listens on the loopback
interface for the gRPC endpoints. It has no effect if `listenLocal`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6683,6 +6683,16 @@ spec:
= 1h.'
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigInterval:
description: GetConfigInterval is how often the Prometheus config
is fetched. Default 30s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
getConfigTimeout:
description: GetConfigTimeout is the Timeout for getting Prometheus
config. Default 5s.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
grpcListenLocal:
description: If true, the Thanos sidecar listens on the loopback
interface for the gRPC endpoints. It has no effect if `listenLocal`
Expand Down
10 changes: 10 additions & 0 deletions jsonnet/prometheus-operator/prometheuses-crd.json
Original file line number Diff line number Diff line change
Expand Up @@ -6186,6 +6186,16 @@
"pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$",
"type": "string"
},
"getConfigInterval": {
"description": "GetConfigInterval is how often the Prometheus config is fetched. Default 30s.",
"pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$",
"type": "string"
},
"getConfigTimeout": {
"description": "GetConfigTimeout is the Timeout for getting Prometheus config. Default 5s.",
"pattern": "^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$",
"type": "string"
},
"grpcListenLocal": {
"description": "If true, the Thanos sidecar listens on the loopback interface for the gRPC endpoints. It has no effect if `listenLocal` is true.",
"type": "boolean"
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/monitoring/v1/prometheus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ type ThanosSpec struct {
BlockDuration Duration `json:"blockSize,omitempty"`
// ReadyTimeout is the maximum time Thanos sidecar will wait for Prometheus to start. Eg 10m
ReadyTimeout Duration `json:"readyTimeout,omitempty"`
// GetConfigInterval is how often the Prometheus config is fetched. Default 30s.
GetConfigInterval Duration `json:"getConfigInterval,omitempty"`
// GetConfigTimeout is the Timeout for getting Prometheus config. Default 5s.
GetConfigTimeout Duration `json:"getConfigTimeout,omitempty"`
// VolumeMounts allows configuration of additional VolumeMounts on the output StatefulSet definition.
// VolumeMounts specified will be appended to other VolumeMounts in the thanos-sidecar container.
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
Expand Down
18 changes: 18 additions & 0 deletions pkg/client/applyconfiguration/monitoring/v1/thanosspec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/prometheus/server/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ func createThanosContainer(
if thanos.ReadyTimeout != "" {
thanosArgs = append(thanosArgs, monitoringv1.Argument{Name: "prometheus.ready_timeout", Value: string(thanos.ReadyTimeout)})
}
if thanos.GetConfigTimeout != "" {
thanosArgs = append(thanosArgs, monitoringv1.Argument{Name: "prometheus.get_config_timeout", Value: string(thanos.GetConfigTimeout)})
}
if thanos.GetConfigInterval != "" {
thanosArgs = append(thanosArgs, monitoringv1.Argument{Name: "prometheus.get_config_interval", Value: string(thanos.GetConfigInterval)})
}

containerArgs, err := operator.BuildArgs(thanosArgs, thanos.AdditionalArgs)
if err != nil {
Expand Down
51 changes: 51 additions & 0 deletions pkg/prometheus/server/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,58 @@ func TestConfigReloader(t *testing.T) {
}
}
}
}

func TestThanosGetConfigInterval(t *testing.T) {
sset, err := makeStatefulSetFromPrometheus(monitoringv1.Prometheus{
Spec: monitoringv1.PrometheusSpec{
Thanos: &monitoringv1.ThanosSpec{
GetConfigInterval: "1m",
},
},
})
require.NoError(t, err)

found := false
for _, container := range sset.Spec.Template.Spec.Containers {
if container.Name == "thanos-sidecar" {
for _, flag := range container.Args {
if flag == "--prometheus.get_config_interval=1m" {
found = true
}
}
}
}

if !found {
t.Fatal("Sidecar get_config_interval is not set when it should.")
}
}

func TestThanosGetConfigTimeout(t *testing.T) {
sset, err := makeStatefulSetFromPrometheus(monitoringv1.Prometheus{
Spec: monitoringv1.PrometheusSpec{
Thanos: &monitoringv1.ThanosSpec{
GetConfigTimeout: "30s",
},
},
})
require.NoError(t, err)

found := false
for _, container := range sset.Spec.Template.Spec.Containers {
if container.Name == "thanos-sidecar" {
for _, flag := range container.Args {
if flag == "--prometheus.get_config_timeout=30s" {
found = true
}
}
}
}

if !found {
t.Fatal("Sidecar get_config_timeout is not set when it should.")
}
}

func TestThanosReadyTimeout(t *testing.T) {
Expand Down

0 comments on commit 018eadd

Please sign in to comment.