@@ -96,22 +96,18 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
9696 if co .CreationTimestamp .Time .Before (startTime ) {
9797 return
9898 }
99- m .Record (monitorapi.Condition {
100- Level : monitorapi .Info ,
101- Locator : monitorapi .OperatorLocator (co .Name ),
102- Message : "created" ,
103- })
99+ m .AddIntervals (monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Info ).
100+ Locator (monitorapi .NewLocator ().ClusterOperator (co .Name )).
101+ Message (monitorapi .NewMessage ().HumanMessage ("created" )).BuildNow ())
104102 },
105103 DeleteFunc : func (obj interface {}) {
106104 co , ok := obj .(* configv1.ClusterOperator )
107105 if ! ok {
108106 return
109107 }
110- m .Record (monitorapi.Condition {
111- Level : monitorapi .Warning ,
112- Locator : monitorapi .OperatorLocator (co .Name ),
113- Message : "deleted" ,
114- })
108+ m .AddIntervals (monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Warning ).
109+ Locator (monitorapi .NewLocator ().ClusterOperator (co .Name )).
110+ Message (monitorapi .NewMessage ().HumanMessage ("deleted" )).BuildNow ())
115111 },
116112 UpdateFunc : func (old , obj interface {}) {
117113 co , ok := obj .(* configv1.ClusterOperator )
@@ -150,39 +146,33 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
150146 nil ,
151147 )
152148
153- cvChangeFns := []func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Condition {
154- func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Condition {
155- var conditions []monitorapi.Condition
149+ cvChangeFns := []func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Interval {
150+ func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Interval {
151+ var intervals []monitorapi.Interval
156152 if len (cv .Status .History ) == 0 {
157153 return nil
158154 }
159155 if len (oldCV .Status .History ) == 0 {
160- conditions = append (conditions , monitorapi.Condition {
161- Level : monitorapi .Warning ,
162- Locator : locateClusterVersion (cv ),
163- Message : fmt .Sprintf ("cluster converging to %s" , versionOrImage (cv .Status .History [0 ])),
164- })
165- return conditions
156+ intervals = append (intervals , monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Warning ).
157+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
158+ Message (monitorapi .NewMessage ().HumanMessagef ("cluster converging to %s" , versionOrImage (cv .Status .History [0 ]))).BuildNow ())
159+ return intervals
166160 }
167161 cvNew , cvOld := cv .Status .History [0 ], oldCV .Status .History [0 ]
168162 switch {
169163 case cvNew .State == configv1 .CompletedUpdate && cvOld .State != cvNew .State :
170- conditions = append (conditions , monitorapi.Condition {
171- Level : monitorapi .Warning ,
172- Locator : locateClusterVersion (cv ),
173- Message : fmt .Sprintf ("cluster reached %s" , versionOrImage (cvNew )),
174- })
164+ intervals = append (intervals , monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Warning ).
165+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
166+ Message (monitorapi .NewMessage ().HumanMessagef ("cluster reached %s" , versionOrImage (cvNew ))).BuildNow ())
175167 case cvNew .State == configv1 .PartialUpdate && cvOld .State == cvNew .State && cvOld .Image != cvNew .Image :
176- conditions = append (conditions , monitorapi.Condition {
177- Level : monitorapi .Warning ,
178- Locator : locateClusterVersion (cv ),
179- Message : fmt .Sprintf ("cluster upgrading to %s without completing %s" , versionOrImage (cvNew ), versionOrImage (cvOld )),
180- })
168+ intervals = append (intervals , monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Warning ).
169+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
170+ Message (monitorapi .NewMessage ().HumanMessagef ("cluster upgrading to %s without completing %s" , versionOrImage (cvNew ), versionOrImage (cvOld ))).BuildNow ())
181171 }
182- return conditions
172+ return intervals
183173 },
184- func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Condition {
185- var conditions []monitorapi.Condition
174+ func (cv , oldCV * configv1.ClusterVersion ) []monitorapi.Interval {
175+ var intervals []monitorapi.Interval
186176 for i := range cv .Status .Conditions {
187177 s := & cv .Status .Conditions [i ]
188178 previous := findOperatorStatusCondition (oldCV .Status .Conditions , s .Type )
@@ -206,14 +196,12 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
206196 if s .Type == configv1 .ClusterStatusConditionType ("Failing" ) && s .Status == configv1 .ConditionTrue {
207197 level = monitorapi .Error
208198 }
209- conditions = append (conditions , monitorapi.Condition {
210- Level : level ,
211- Locator : locateClusterVersion (cv ),
212- Message : msg ,
213- })
199+ intervals = append (intervals , monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , level ).
200+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
201+ Message (monitorapi .NewMessage ().HumanMessage (msg )).BuildNow ())
214202 }
215203 }
216- return conditions
204+ return intervals
217205 },
218206 }
219207
@@ -229,22 +217,18 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
229217 if cv .CreationTimestamp .Time .Before (startTime ) {
230218 return
231219 }
232- m .Record (monitorapi.Condition {
233- Level : monitorapi .Info ,
234- Locator : locateClusterVersion (cv ),
235- Message : "created" ,
236- })
220+ m .AddIntervals (monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Info ).
221+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
222+ Message (monitorapi .NewMessage ().HumanMessage ("created" )).BuildNow ())
237223 },
238224 DeleteFunc : func (obj interface {}) {
239225 cv , ok := obj .(* configv1.ClusterVersion )
240226 if ! ok {
241227 return
242228 }
243- m .Record (monitorapi.Condition {
244- Level : monitorapi .Warning ,
245- Locator : locateClusterVersion (cv ),
246- Message : "deleted" ,
247- })
229+ m .AddIntervals (monitorapi .NewInterval (monitorapi .SourceClusterOperatorMonitor , monitorapi .Warning ).
230+ Locator (monitorapi .NewLocator ().ClusterVersion (cv )).
231+ Message (monitorapi .NewMessage ().HumanMessage ("deleted" )).BuildNow ())
248232 },
249233 UpdateFunc : func (old , obj interface {}) {
250234 cv , ok := obj .(* configv1.ClusterVersion )
@@ -259,7 +243,7 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
259243 return
260244 }
261245 for _ , fn := range cvChangeFns {
262- m .Record (fn (cv , oldCV )... )
246+ m .AddIntervals (fn (cv , oldCV )... )
263247 }
264248 },
265249 },
@@ -275,10 +259,6 @@ func versionOrImage(h configv1.UpdateHistory) string {
275259 return h .Version
276260}
277261
278- func locateClusterVersion (cv * configv1.ClusterVersion ) string {
279- return fmt .Sprintf ("clusterversion/%s" , cv .Name )
280- }
281-
282262func findOperatorVersionChange (old , new []configv1.OperandVersion ) []string {
283263 var changed []string
284264 for i := 0 ; i < len (new ); i ++ {
0 commit comments