1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 15:46:31 +01:00
Files
prometheus-operator/pkg/operator/argument_test.go
Simon Pasquier 9db1527060 feat: use minReadySeconds as default first delay
This commit removes the `dispatchStartDelay` field from the Alertmanager
CRD and uses instead the `minReadySeconds` value as the default
duration to delay the first flush of aggregation groups.

When Kubernetes performs pod updates (due to spec updates or pod
eviction),`minReadySeconds` defines how long a statefulset's pod should
be ready before kube-controller-manager can proceed with the next pod
update. The main use case of `minReadySeconds` is to ensure that
Prometheus has resent all alerts before updating the next pod hence it
makes sense for Alertmanager to wait the same amount of time before
sending alert notifications. Users who want to use another value for
`--dispatch.start-delay` can customize it using the
`.spec.additionalArgs` field.

The removal of `dispatchStartDelay` is possible because the field hasn't
been made available in any public release.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
2026-01-05 12:05:37 +01:00

86 lines
2.0 KiB
Go

// Copyright 2023 The prometheus-operator Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package operator
import (
"testing"
"github.com/stretchr/testify/require"
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
)
func TestBuildArgs(t *testing.T) {
for _, tc := range []struct {
a []v1.Argument
b []v1.Argument
exp []string
err bool
}{
{
a: []v1.Argument{
{Name: "test", Value: "value"},
{Name: "test2-test", Value: "value2"},
{Name: "test3.test", Value: "value3"},
},
b: []v1.Argument{
{Name: "addtest", Value: "value"},
{Name: "addtest2-test", Value: "value2"},
{Name: "addtest3.test", Value: "value3"},
},
exp: []string{
"--test=value",
"--test2-test=value2",
"--test3.test=value3",
"--addtest=value",
"--addtest2-test=value2",
"--addtest3.test=value3",
},
},
{
a: []v1.Argument{
{Name: "test", Value: "value"},
{Name: "test2", Value: "value2"},
},
b: []v1.Argument{
{Name: "addtest", Value: "value"},
{Name: "test2", Value: "value3"},
},
err: true,
},
{
a: []v1.Argument{
{Name: "test", Value: "value"},
{Name: "test2", Value: ""},
},
b: []v1.Argument{
{Name: "addtest", Value: "value"},
{Name: "no-test2", Value: ""},
},
err: true,
},
} {
t.Run("", func(t *testing.T) {
args, err := BuildArgs(tc.a, tc.b)
if tc.err {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, tc.exp, args)
})
}
}