-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove schedule-related metrics on schedule delete #6715
Conversation
Signed-off-by: Nilesh Akhade <[email protected]>
if apierrors.IsNotFound(err) { | ||
log.WithError(err).Error("schedule not found") | ||
c.metrics.RemoveSchedule(req.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to consider the case where deletionTimestamp is not nil (user has initiated deletion request) but object is not yet not found (gone from cluster)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scenario you described is when the metadata.deletionTimestamp
is not nil, indicating that a user has initiated a deletion request for the schedule, but the schedule is not yet deleted.
Do you mean we should move the function call for removing schedule-related metrics in the if-block, as shown below?
if schedule.ObjectMeta.DeletionTimestamp != nil {
log.Debug("Got a deletion request for the schedule")
c.metrics.RemoveSchedule(req.Name)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would remove metrics even if schedule is stuck/remain in cluster due to finalizers etc. but yes just questioning if that would be preferred or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the deletion of the schedule gets stuck, the metrics will still be exported. This makes sense because the schedule is not yet deleted. Additionally, the removal of metrics is quick and should never fail. Hence, I believe that removal in the reconciliation cycle after deletion should be preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Codecov Report
@@ Coverage Diff @@
## main #6715 +/- ##
==========================================
+ Coverage 60.28% 60.36% +0.07%
==========================================
Files 238 242 +4
Lines 25256 25983 +727
==========================================
+ Hits 15226 15684 +458
- Misses 8976 9196 +220
- Partials 1054 1103 +49
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @nilesh-akhade
Thank you for contributing to Velero!
Summary of the change
Currently, when a schedule is deleted, the associated metrics are still exported, which leads to inconsistencies in the metrics data. With this PR, we ensure that when a schedule is deleted, the related metrics are correctly removed or no longer exported. This enhances the accuracy and consistency of the metrics data.
Example
If schedule
myschedule
exists with one successful backup and if we access the/metrics
endpoint on the Velero server.After we delete the schedule
myschedule
, the above line is removed(not exported).Does your change fix a particular issue?
Fixes #1333
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.