Skip to content

Commit 04e9c9e

Browse files
committed
chore: drop check for AlertmanagerV1
Signed-off-by: Jan Fajerski <[email protected]>
1 parent db430aa commit 04e9c9e

File tree

2 files changed

+0
-175
lines changed

2 files changed

+0
-175
lines changed

pkg/manifests/config.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const (
5353
configKey = "config.yaml"
5454
)
5555

56-
var errAlertmanagerV1NotSupported = errors.New("alertmanager's apiVersion=v1 is no longer supported, v2 has been available since Alertmanager 0.16.0")
5756
var reservedPrometheusExternalLabels = []string{"prometheus", "prometheus_replica", "cluster"}
5857

5958
type Config struct {
@@ -202,31 +201,6 @@ func (u *UserWorkloadConfiguration) checkThanosRulerEvaluationInterval() error {
202201
return nil
203202
}
204203

205-
func (u *UserWorkloadConfiguration) checkAlertmanagerVersion() error {
206-
if u.Prometheus != nil {
207-
for _, amConfig := range u.Prometheus.AlertmanagerConfigs {
208-
if alertmanagerV1(amConfig.APIVersion) {
209-
return fmt.Errorf("%w: found in prometheus.additionalAlertmanagerConfigs", errAlertmanagerV1NotSupported)
210-
}
211-
}
212-
}
213-
if u.ThanosRuler != nil {
214-
for _, amConfig := range u.ThanosRuler.AlertmanagersConfigs {
215-
if alertmanagerV1(amConfig.APIVersion) {
216-
return fmt.Errorf("%w: found in thanosRuler.additionalAlertmanagerConfigs", errAlertmanagerV1NotSupported)
217-
}
218-
}
219-
}
220-
221-
return nil
222-
}
223-
224-
func alertmanagerV1(version string) bool {
225-
// Only meant to guide users by failing early in case v1 Alertmanager is still referenced,
226-
// this is not meant to validate the apiVersion field.
227-
return version == "v1"
228-
}
229-
230204
func (u *UserWorkloadConfiguration) check() error {
231205
if u == nil {
232206
return nil
@@ -244,12 +218,6 @@ func (u *UserWorkloadConfiguration) check() error {
244218
return err
245219
}
246220

247-
// TODO: remove after 4.19
248-
// Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use.
249-
if err := u.checkAlertmanagerVersion(); err != nil {
250-
return err
251-
}
252-
253221
return nil
254222
}
255223

@@ -606,19 +574,6 @@ func (c *Config) LoadEnforcedBodySizeLimit(pcr PodCapacityReader, ctx context.Co
606574
return nil
607575
}
608576

609-
func (c *Config) checkAlertmanagerVersion() error {
610-
if c.ClusterMonitoringConfiguration == nil || c.ClusterMonitoringConfiguration.PrometheusK8sConfig == nil {
611-
return nil
612-
}
613-
614-
for _, amConfig := range c.ClusterMonitoringConfiguration.PrometheusK8sConfig.AlertmanagerConfigs {
615-
if alertmanagerV1(amConfig.APIVersion) {
616-
return fmt.Errorf("%w: found in prometheusK8s.additionalAlertmanagerConfigs", errAlertmanagerV1NotSupported)
617-
}
618-
}
619-
return nil
620-
}
621-
622577
func (c *Config) Precheck() error {
623578
if c.ClusterMonitoringConfiguration.PrometheusK8sConfig.CollectionProfile != FullCollectionProfile && !c.CollectionProfilesFeatureGateEnabled {
624579
return fmt.Errorf("%w: collectionProfiles is currently a TechPreview feature behind the \"MetricsCollectionProfiles\" feature-gate, to be able to use a profile different from the default (\"full\") please enable it first", ErrConfigValidation)
@@ -647,12 +602,6 @@ func (c *Config) Precheck() error {
647602
// Prometheus-Adapter is replaced with Metrics Server by default from 4.16
648603
metrics.DeprecatedConfig.WithLabelValues("openshift-monitoring/cluster-monitoring-config", "k8sPrometheusAdapter", "4.16").Set(d)
649604

650-
// TODO: remove after 4.19
651-
// Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use.
652-
if err := c.checkAlertmanagerVersion(); err != nil {
653-
return err
654-
}
655-
656605
return nil
657606
}
658607

pkg/manifests/config_test.go

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -278,85 +278,6 @@ thanosRuler:
278278
}
279279
}
280280

281-
// TestNewUserConfigFromStringUnsupportedAlertmanagerVersion is a temp test
282-
// TODO: remove after 4.19
283-
// Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use.
284-
func TestNewUserConfigFromStringUnsupportedAlertmanagerVersion(t *testing.T) {
285-
tcs := []struct {
286-
name string
287-
configString func() string
288-
shouldFail bool
289-
}{
290-
{
291-
name: "unsupported alertmanager version in thanosRuler.additionalAlertmanagerConfigs",
292-
configString: func() string {
293-
return `
294-
thanosRuler:
295-
additionalAlertmanagerConfigs:
296-
- apiVersion: v1`
297-
},
298-
shouldFail: true,
299-
},
300-
{
301-
name: "unsupported alertmanager version in prometheus.additionalAlertmanagerConfigs",
302-
configString: func() string {
303-
return `
304-
prometheus:
305-
additionalAlertmanagerConfigs:
306-
- apiVersion: v1`
307-
},
308-
shouldFail: true,
309-
},
310-
{
311-
name: "supported alertmanager version in thanosRuler.additionalAlertmanagerConfigs",
312-
configString: func() string {
313-
return `
314-
thanosRuler:
315-
additionalAlertmanagerConfigs:
316-
- apiVersion: v2`
317-
},
318-
},
319-
{
320-
name: "supported alertmanager version in prometheus.additionalAlertmanagerConfigs",
321-
configString: func() string {
322-
return `
323-
prometheus:
324-
additionalAlertmanagerConfigs:
325-
- apiVersion: v2`
326-
},
327-
},
328-
{
329-
name: "default alertmanager version in thanosRuler.additionalAlertmanagerConfigs",
330-
configString: func() string {
331-
return `
332-
thanosRuler:
333-
additionalAlertmanagerConfigs:
334-
- scheme: foo`
335-
},
336-
},
337-
{
338-
name: "default alertmanager version in prometheus.additionalAlertmanagerConfigs",
339-
configString: func() string {
340-
return `
341-
prometheus:
342-
additionalAlertmanagerConfigs:
343-
- scheme: foo`
344-
},
345-
},
346-
}
347-
348-
for _, tc := range tcs {
349-
t.Run(tc.name, func(t *testing.T) {
350-
_, err := NewUserConfigFromString(tc.configString())
351-
if tc.shouldFail {
352-
require.ErrorIs(t, err, errAlertmanagerV1NotSupported)
353-
return
354-
}
355-
require.NoError(t, err)
356-
})
357-
}
358-
}
359-
360281
func TestTelemeterClientConfig(t *testing.T) {
361282
truev, falsev := true, false
362283

@@ -838,48 +759,3 @@ func TestDeprecatedConfig(t *testing.T) {
838759
})
839760
}
840761
}
841-
842-
// TestUnsupportedAlertmanagerVersion is a temp test
843-
// TODO: remove after 4.19
844-
// Only to assist with the migration to Prometheus 3; fail early if Alertmanager v1 is still in use.
845-
func TestUnsupportedAlertmanagerVersion(t *testing.T) {
846-
for _, tc := range []struct {
847-
name string
848-
config string
849-
shouldFail bool
850-
}{
851-
{
852-
name: "using unsupported Alertmanager v1 API",
853-
config: `prometheusK8s:
854-
additionalAlertmanagerConfigs:
855-
- apiVersion: v1
856-
`,
857-
shouldFail: true,
858-
},
859-
{
860-
name: "using supported Alertmanager v2 API",
861-
config: `prometheusK8s:
862-
additionalAlertmanagerConfigs:
863-
- apiVersion: v2
864-
`,
865-
},
866-
{
867-
name: "using default value",
868-
config: `prometheusK8s:
869-
additionalAlertmanagerConfigs:
870-
- scheme: foo
871-
`,
872-
},
873-
} {
874-
t.Run(tc.name, func(t *testing.T) {
875-
c, err := NewConfigFromString(tc.config, true)
876-
require.NoError(t, err)
877-
err = c.Precheck()
878-
if tc.shouldFail {
879-
require.ErrorIs(t, err, errAlertmanagerV1NotSupported)
880-
} else {
881-
require.NoError(t, err)
882-
}
883-
})
884-
}
885-
}

0 commit comments

Comments
 (0)