1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 15:46:31 +01:00

Merge pull request #6282 from simonpasquier/fix-missing-continue-conversion

fix: convert `continue` field between v1alpha1 and v1beta1 AlertmanagerConfig versions
This commit is contained in:
Simon Pasquier
2024-02-02 14:00:59 +01:00
committed by GitHub
3 changed files with 14 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ func convertRouteFrom(in *v1alpha1.Route) (*Route, error) {
out := &Route{
Receiver: in.Receiver,
Continue: in.Continue,
GroupBy: in.GroupBy,
GroupWait: in.GroupWait,
GroupInterval: in.GroupInterval,

View File

@@ -32,6 +32,7 @@ func convertRouteTo(in *Route) (*v1alpha1.Route, error) {
out := &v1alpha1.Route{
Receiver: in.Receiver,
Continue: in.Continue,
GroupBy: in.GroupBy,
GroupWait: in.GroupWait,
GroupInterval: in.GroupInterval,

View File

@@ -937,6 +937,7 @@ func testAlertmanagerConfigVersions(t *testing.T) {
Spec: monitoringv1alpha1.AlertmanagerConfigSpec{
Route: &monitoringv1alpha1.Route{
Receiver: "webhook",
Continue: true,
Matchers: []monitoringv1alpha1.Matcher{{
Name: "job",
Value: "webapp.+",
@@ -963,6 +964,8 @@ func testAlertmanagerConfigVersions(t *testing.T) {
t.Fatalf("expected %#v matcher, got %#v", expected, amcfgV1beta1Converted.Spec.Route.Matchers)
}
require.True(t, amcfgV1beta1Converted.Spec.Route.Continue)
amcfgV1beta1 := &monitoringv1beta1.AlertmanagerConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "amcfg-v1beta1",
@@ -970,6 +973,7 @@ func testAlertmanagerConfigVersions(t *testing.T) {
Spec: monitoringv1beta1.AlertmanagerConfigSpec{
Route: &monitoringv1beta1.Route{
Receiver: "webhook",
Continue: true,
Matchers: []monitoringv1beta1.Matcher{{
Name: "job",
Value: "webapp.+",
@@ -982,13 +986,19 @@ func testAlertmanagerConfigVersions(t *testing.T) {
},
}
if _, err := framework.MonClientV1beta1.AlertmanagerConfigs(alertmanager.Namespace).Create(context.Background(), amcfgV1beta1, metav1.CreateOptions{}); err != nil {
amcfgV1beta1, err = framework.MonClientV1beta1.AlertmanagerConfigs(alertmanager.Namespace).Create(context.Background(), amcfgV1beta1, metav1.CreateOptions{})
if err != nil {
t.Fatalf("failed to create v1beta1 AlertmanagerConfig object: %v", err)
}
if _, err := framework.MonClientV1alpha1.AlertmanagerConfigs(alertmanager.Namespace).Get(context.Background(), amcfgV1beta1.Name, metav1.GetOptions{}); err != nil {
require.True(t, amcfgV1beta1.Spec.Route.Continue)
amcfgV1alpha1, err = framework.MonClientV1alpha1.AlertmanagerConfigs(alertmanager.Namespace).Get(context.Background(), amcfgV1beta1.Name, metav1.GetOptions{})
if err != nil {
t.Fatalf("failed to get v1alpha1 AlertmanagerConfig object: %v", err)
}
require.True(t, amcfgV1alpha1.Spec.Route.Continue)
}
// e2e test to validate that all possible fields in an AlertmanagerConfig CR are