@@ -176,25 +176,53 @@ func getNotificationHealth(obj *unstructured.Unstructured) (*HealthStatus, error
176
176
return nil , err
177
177
}
178
178
179
- var h Health = HealthUnknown
179
+ status := & HealthStatus {
180
+ Health : HealthUnknown ,
181
+ Ready : true ,
182
+ }
183
+
184
+ if errorMessage != "" {
185
+ status .Message = errorMessage
186
+ status .Health = HealthUnhealthy
187
+ status .Ready = false
188
+ return status , nil
189
+ }
190
+
180
191
if sentCount > 0 {
181
- h = HealthHealthy
192
+ status . Health = HealthHealthy
182
193
if failedCount > 0 || pendingCount > 0 {
183
- h = HealthWarning
194
+ status . Health = HealthWarning
184
195
}
185
196
} else {
186
197
if pendingCount > 0 {
187
- h = HealthWarning
198
+ status . Health = HealthWarning
188
199
}
189
200
if failedCount > 0 {
190
- h = HealthUnhealthy
201
+ status . Health = HealthUnhealthy
191
202
}
192
203
}
193
204
194
- status := & HealthStatus {Health : h }
205
+ // Check lastFailed timestamp
206
+ lastFailedTime , found , err := unstructured .NestedString (obj .Object , "status" , "lastFailed" )
207
+ if err != nil {
208
+ return nil , err
209
+ }
210
+
211
+ if found && lastFailedTime != "" {
212
+ parsedLastFailedTime , err := time .Parse (time .RFC3339 , lastFailedTime )
213
+ if err != nil {
214
+ return nil , fmt .Errorf ("failed to parse lastFailed timestamp: %w" , err )
215
+ }
195
216
196
- if errorMessage != "" {
197
- status .Message = errorMessage
217
+ timeSinceLastFailure := time .Since (parsedLastFailedTime )
218
+
219
+ if timeSinceLastFailure <= 12 * time .Hour {
220
+ status .Health = HealthWarning
221
+ status .Message = fmt .Sprintf ("Failed %s ago" , duration .HumanDuration (timeSinceLastFailure ))
222
+ if timeSinceLastFailure <= time .Hour {
223
+ status .Health = HealthUnhealthy
224
+ }
225
+ }
198
226
}
199
227
200
228
return status , nil
0 commit comments