1- // Copyright (c) 2021-2025 Tigera, Inc. All rights reserved.
1+ // Copyright (c) 2021-2024 Tigera, Inc. All rights reserved.
22
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -68,7 +68,6 @@ var _ = Describe("Monitor controller tests", func() {
6868 Expect (apis .AddToScheme (scheme )).NotTo (HaveOccurred ())
6969 Expect (appsv1 .SchemeBuilder .AddToScheme (scheme )).NotTo (HaveOccurred ())
7070 Expect (rbacv1 .SchemeBuilder .AddToScheme (scheme )).NotTo (HaveOccurred ())
71- Expect (monitoringv1 .AddToScheme (scheme )).NotTo (HaveOccurred ())
7271
7372 // Create a client that will have a crud interface of k8s objects.
7473 ctx = context .Background ()
@@ -86,7 +85,6 @@ var _ = Describe("Monitor controller tests", func() {
8685 mockStatus .On ("ReadyToMonitor" )
8786 mockStatus .On ("RemoveDeployments" , mock .Anything )
8887 mockStatus .On ("RemoveCertificateSigningRequests" , common .TigeraPrometheusNamespace )
89- mockStatus .On ("SetDegraded" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return ()
9088 mockStatus .On ("SetMetaData" , mock .Anything ).Return ()
9189
9290 // Create an object we can use throughout the test to do the monitor reconcile loops.
@@ -137,107 +135,6 @@ var _ = Describe("Monitor controller tests", func() {
137135 r .tierWatchReady .MarkAsReady ()
138136 })
139137
140- Context ("prometheus resources" , func () {
141- BeforeEach (func () {
142- // Add the Prometheus and Alertmanager instances
143- prom := & monitoringv1.Prometheus {
144- ObjectMeta : metav1.ObjectMeta {
145- Name : monitor .CalicoNodePrometheus ,
146- Namespace : common .TigeraPrometheusNamespace ,
147- },
148- Status : monitoringv1.PrometheusStatus {
149- Conditions : []monitoringv1.Condition {
150- {
151- Type : monitoringv1 .Available ,
152- Status : monitoringv1 .ConditionTrue ,
153- },
154- {
155- Type : monitoringv1 .Reconciled ,
156- Status : monitoringv1 .ConditionTrue ,
157- },
158- },
159- },
160- }
161- Expect (cli .Create (ctx , prom )).To (BeNil ())
162-
163- alertManager := & monitoringv1.Alertmanager {
164- ObjectMeta : metav1.ObjectMeta {
165- Name : monitor .CalicoNodeAlertmanager ,
166- Namespace : common .TigeraPrometheusNamespace ,
167- },
168- Status : monitoringv1.AlertmanagerStatus {
169- Conditions : []monitoringv1.Condition {
170- {
171- Type : monitoringv1 .Available ,
172- Status : monitoringv1 .ConditionTrue ,
173- },
174- {
175- Type : monitoringv1 .Reconciled ,
176- Status : monitoringv1 .ConditionTrue ,
177- },
178- },
179- },
180- }
181- Expect (cli .Create (ctx , alertManager )).To (BeNil ())
182- })
183-
184- It ("should degrade if the prometheus statefulset isn't ready" , func () {
185- prom := & monitoringv1.Prometheus {}
186- Expect (cli .Get (ctx , client.ObjectKey {Name : monitor .CalicoNodePrometheus , Namespace : common .TigeraPrometheusNamespace }, prom )).NotTo (HaveOccurred ())
187-
188- patch := client .MergeFrom (prom .DeepCopy ())
189- prom .Status .Conditions = []monitoringv1.Condition {
190- {
191- Type : monitoringv1 .Available ,
192- Status : monitoringv1 .ConditionFalse ,
193- },
194- {
195- Type : monitoringv1 .Reconciled ,
196- Status : monitoringv1 .ConditionTrue ,
197- },
198- }
199- Expect (cli .Patch (ctx , prom , patch )).To (Succeed ())
200-
201- _ , err := r .Reconcile (ctx , reconcile.Request {})
202- Expect (err ).ShouldNot (HaveOccurred ())
203-
204- mockStatus .AssertCalled (GinkgoT (), "SetDegraded" ,
205- operatorv1 .ResourceNotReady ,
206- "Prometheus component is not available" ,
207- mock .Anything ,
208- mock .Anything ,
209- )
210- })
211-
212- It ("should degrade if the alertmanager statefulset isn't ready" , func () {
213- alertManager := & monitoringv1.Alertmanager {}
214- Expect (cli .Get (ctx , client.ObjectKey {Name : monitor .CalicoNodeAlertmanager , Namespace : common .TigeraPrometheusNamespace }, alertManager )).NotTo (HaveOccurred ())
215-
216- patch := client .MergeFrom (alertManager .DeepCopy ())
217- alertManager .Status .Conditions = []monitoringv1.Condition {
218- {
219- Type : monitoringv1 .Available ,
220- Status : monitoringv1 .ConditionFalse ,
221- },
222- {
223- Type : monitoringv1 .Reconciled ,
224- Status : monitoringv1 .ConditionTrue ,
225- },
226- }
227- Expect (cli .Patch (ctx , alertManager , patch )).To (Succeed ())
228-
229- _ , err := r .Reconcile (ctx , reconcile.Request {})
230- Expect (err ).ShouldNot (HaveOccurred ())
231-
232- mockStatus .AssertCalled (GinkgoT (), "SetDegraded" ,
233- operatorv1 .ResourceNotReady ,
234- "Alertmanager component is not available" ,
235- mock .Anything ,
236- mock .Anything ,
237- )
238- })
239- })
240-
241138 Context ("controller reconciliation" , func () {
242139 var (
243140 am = & monitoringv1.Alertmanager {}
0 commit comments