From 81521f6c7d7fb8970cc62fccd339e30dbc986e6a Mon Sep 17 00:00:00 2001 From: Daniel Hall Date: Wed, 29 Apr 2026 14:20:37 +1000 Subject: [PATCH] Remove AlertmanagerInhibitions test (moved to CAO) The inhibitions test has been moved to the configure-alertmanager-operator repo's e2e suite. Remove it from osde2e along with the now-unused prometheus/alertmanager dependency. Signed-off-by: Daniel Hall Co-Authored-By: Claude Opus 4.6 --- go.mod | 6 -- go.sum | 4 - pkg/e2e/osd/inhibitions.go | 203 ------------------------------------- 3 files changed, 213 deletions(-) delete mode 100644 pkg/e2e/osd/inhibitions.go diff --git a/go.mod b/go.mod index e55f0064d0..442f166d64 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,6 @@ require ( github.com/operator-framework/operator-lifecycle-manager v0.22.0 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.74.0 github.com/prometheus-operator/prometheus-operator/pkg/client v0.74.0 - github.com/prometheus/alertmanager v0.28.1 github.com/prometheus/client_golang v1.23.2 github.com/prometheus/common v0.67.5 // indirect github.com/spf13/afero v1.12.0 @@ -107,7 +106,6 @@ require ( github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/golang/glog v1.2.5 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -126,7 +124,6 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -134,7 +131,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/openshift-online/ocm-api-model/clientapi v0.0.453 // indirect github.com/openshift-online/ocm-api-model/model v0.0.453 // indirect @@ -143,7 +139,6 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/procfs v0.16.1 // indirect - github.com/prometheus/sigv4 v0.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect @@ -176,7 +171,6 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/apiextensions-apiserver v0.35.1 // indirect k8s.io/component-base v0.35.2 // indirect k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect diff --git a/go.sum b/go.sum index 5aec5bdb09..455b129200 100644 --- a/go.sum +++ b/go.sum @@ -296,8 +296,6 @@ github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.74.0 h github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.74.0/go.mod h1:wAR5JopumPtAZnu0Cjv2PSqV4p4QB09LMhc6fZZTXuA= github.com/prometheus-operator/prometheus-operator/pkg/client v0.74.0 h1:SyBTzvFuVshDNjDVALs6+NgOy3qh8/xlAsyqB1SzHbI= github.com/prometheus-operator/prometheus-operator/pkg/client v0.74.0/go.mod h1:FlcnLo14zQxL6P1yPrV22kYBqyAT0ZRRytv98+B7lBQ= -github.com/prometheus/alertmanager v0.28.1 h1:BK5pCoAtaKg01BYRUJhEDV1tqJMEtYBGzPw8QdvnnvA= -github.com/prometheus/alertmanager v0.28.1/go.mod h1:0StpPUDDHi1VXeM7p2yYfeZgLVi/PPlt39vo9LQUHxM= github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= @@ -306,8 +304,6 @@ github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTU github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= -github.com/prometheus/sigv4 v0.1.0 h1:FgxH+m1qf9dGQ4w8Dd6VkthmpFQfGTzUeavMoQeG1LA= -github.com/prometheus/sigv4 v0.1.0/go.mod h1:doosPW9dOitMzYe2I2BN0jZqUuBrGPbXrNsTScN18iU= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= diff --git a/pkg/e2e/osd/inhibitions.go b/pkg/e2e/osd/inhibitions.go deleted file mode 100644 index 8ee5358abf..0000000000 --- a/pkg/e2e/osd/inhibitions.go +++ /dev/null @@ -1,203 +0,0 @@ -package osd - -import ( - "context" - "reflect" - "time" - - "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - configV1 "github.com/openshift/api/config/v1" - "github.com/openshift/osde2e-common/pkg/clients/openshift" - "github.com/openshift/osde2e-common/pkg/clients/prometheus" - "github.com/openshift/osde2e/pkg/common/helper" - "github.com/openshift/osde2e/pkg/common/label" - alertmanagerConfig "github.com/prometheus/alertmanager/config" - "gopkg.in/yaml.v3" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/util/retry" -) - -const ( - AlertmanagerConfigFileName = "alertmanager.yaml" - AlertmanagerConfigSecretName = "alertmanager-main" - MonitoringNamespace = "openshift-monitoring" - IdentityProviderName = "oidcidp" -) - -var _ = ginkgo.Describe("[Suite: operators] AlertmanagerInhibitions", label.Operators, func() { - h := helper.New() - - ginkgo.It("should exist", func(ctx context.Context) { - alertmanagerConfigSecret, err := h.Kube().CoreV1().Secrets(MonitoringNamespace).Get(ctx, AlertmanagerConfigSecretName, metav1.GetOptions{}) - Expect(err).NotTo(HaveOccurred()) - - // looks for a section in the alertmanager config for inhibit_rules - alertmanagerConfigData := alertmanagerConfigSecret.Data[AlertmanagerConfigFileName] - Expect(string(alertmanagerConfigData)).To(ContainSubstring("inhibit_rules")) - - config := alertmanagerConfig.Config{} - Expect(yaml.Unmarshal(alertmanagerConfigData, &config)).Should(Succeed()) - - // look for all the inhibition rules we expect - tests := []struct { - name string - expectedTarget string - expectedSource string - expectedEqual []string - expectedPresent bool - }{ - { - name: "negative test", - expectedSource: "FakeSource", - expectedTarget: "ImaginaryTarget", - expectedEqual: []string{ - "namespace", - }, - expectedPresent: false, - }, - { - name: "ClusterOperatorDegraded inhibits ClusterOperatorDown", - expectedSource: "ClusterOperatorDegraded", - expectedTarget: "ClusterOperatorDown", - expectedEqual: []string{ - "namespace", - "name", - }, - expectedPresent: true, - }, - { - name: "KubeNodeNotReady inhibits KubeNodeUnreachable", - expectedSource: "KubeNodeNotReady", - expectedTarget: "KubeNodeUnreachable", - expectedEqual: []string{ - "node", - "instance", - }, - expectedPresent: true, - }, - } - - for _, test := range tests { - // confirm there's a single rule that: - // * matches the target - // * matches the source - // * matches the equals - var rulePresent bool - for _, rule := range config.InhibitRules { - // match the equals - if reflect.DeepEqual(rule.Equal, test.expectedEqual) { - // match the source - if rule.SourceMatch["alertname"] == test.expectedSource { - // match the target - rulePresent = rule.TargetMatchRE["alertname"].Match([]byte(test.expectedTarget)) - } - } - } - Expect(rulePresent).To(Equal(test.expectedPresent), test.name) - } - }) - - ginkgo.It("inhibits ClusterOperatorDegraded", func(ctx context.Context) { - // define an IdP that will cause the authentication operator to degrade - degradingIdentityProvider := configV1.IdentityProvider{ - Name: IdentityProviderName, - MappingMethod: "claim", - IdentityProviderConfig: configV1.IdentityProviderConfig{ - Type: configV1.IdentityProviderTypeOpenID, - OpenID: &configV1.OpenIDIdentityProvider{ - ClientID: "does-not-exist", - ClientSecret: configV1.SecretNameReference{ - Name: "does-not-exist", - }, - Claims: configV1.OpenIDClaims{ - PreferredUsername: []string{ - "preferred_username", - }, - Name: []string{ - "name", - }, - Email: []string{ - "email", - }, - }, - Issuer: "https://www.idp-issuer.example.com", - }, - }, - } - - // Clean up the IDP if it already existed for some reason - cleanup(ctx, h) - - // send the IdP in as a patch to the cluster oauth. this will cause the - // authentication cluster operator to degrade, and since there is only one - // pod, it will also be down. - err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { - oauthcfg, err := h.Cfg().ConfigV1().OAuths().Get(ctx, "cluster", metav1.GetOptions{}) - Expect(err).To(BeNil()) - if oauthcfg.Spec.IdentityProviders != nil { - oauthcfg.Spec.IdentityProviders = append(oauthcfg.Spec.IdentityProviders, degradingIdentityProvider) - } else { - oauthcfg.Spec.IdentityProviders = []configV1.IdentityProvider{ - degradingIdentityProvider, - } - } - _, err = h.Cfg().ConfigV1().OAuths().Update(ctx, oauthcfg, metav1.UpdateOptions{}) - return err - }) - Expect(err).NotTo(HaveOccurred(), "failed to update cluster oauth") - - // clean up after this test completes - defer func() { - cleanup(ctx, h) - }() - - // the clusteroperatordown/degraded alerts take several minutes to trip - time.Sleep(3 * time.Minute) - - oc, err := openshift.NewFromRestConfig(h.GetConfig(), ginkgo.GinkgoLogr) - Expect(err).NotTo(HaveOccurred(), "unable to create openshift client") - prom, err := prometheus.New(ctx, oc) - Expect(err).NotTo(HaveOccurred(), "unable to create prometheus client") - prometheusApiClient := prom.GetClient() - - timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - alerts, err := prometheusApiClient.Alerts(timeout) - Expect(err).To(BeNil()) - - // confirm the source is firing and the target isn't by cycling through all - // the returned alerts - operatorDownAlertPresent := false - for _, alert := range alerts.Alerts { - if alert.Labels["alertname"] == "ClusterOperatorDown" && alert.Labels["name"] == "authentication" { - operatorDownAlertPresent = true - } - if alert.Labels["alertname"] == "ClusterOperatorDegraded" && alert.Labels["name"] == "authentication" { - operatorDownAlertPresent = true - } - } - Expect(operatorDownAlertPresent).To(BeTrue()) - }) -}) - -func cleanup(ctx context.Context, h *helper.H) { - err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { - oauthcfg, err := h.Cfg().ConfigV1().OAuths().Get(ctx, "cluster", metav1.GetOptions{}) - Expect(err).To(BeNil()) - foundidx := -1 - for i, idp := range oauthcfg.Spec.IdentityProviders { - if idp.Name == IdentityProviderName { - foundidx = i - break - } - } - if foundidx >= 0 { - oauthcfg.Spec.IdentityProviders = append(oauthcfg.Spec.IdentityProviders[:foundidx], oauthcfg.Spec.IdentityProviders[foundidx+1:]...) - _, err = h.Cfg().ConfigV1().OAuths().Update(ctx, oauthcfg, metav1.UpdateOptions{}) - } - return err - }) - Expect(err).To(BeNil()) -}