Repository navigation
fix: remove metric series of deleted profiles and ClusterSummaries - #2031
Merged
gianlucam76 merged 3 commits intoOct 12, 2026
Merged
Conversation
The series labeled by profile and by ClusterSummary are only ever set or incremented, so they outlive the objects they describe. After a delete, matching_clusters keeps the last count of the profile, and reconcile_consecutive_failures and reconcile_last_success_timestamp_seconds keep the last value of the ClusterSummary until the addon-controller restarts. When a cluster is deleted the undeploy is skipped, so a failing feature keeps reporting its failures. Remove the matching_clusters series of a ClusterProfile/Profile once its finalizer is removed, and the series of a ClusterSummary in postFinalizerCleanup, after the undeploy recorded its last outcome. reconcile_duration_seconds and reconcile_operations_total are shared by all the ClusterSummaries of a cluster and are left alone.
Contributor
Author
|
@gianlucam76 could you review this when you have a moment? It does for ClusterProfiles, Profiles and ClusterSummaries what |
Member
|
Thank you @Kitio-Tek Will review it tomorrow morning. thank you again for pushing this! |
gianlucam76
reviewed
Oct 12, 2026
gianlucam76
left a comment
Member
There was a problem hiding this comment.
Thank you @Kitio-Tek so much for detecting it, reporting it and fixing it.
I added two small comments. Let me know what you think. Thank you
A ClusterSummary has one series per feature in each metric, plus one per outcome in reconcileOutcomeCounter, so its series can be deleted by their exact labels instead of walking every series with DeletePartialMatch. The test now records every feature and both outcomes, so a feature or an outcome missing from the loop makes it fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2029
The series labeled by profile and by ClusterSummary are only ever set or incremented, so they outlive the objects they describe. After a ClusterProfile is deleted,
projectsveltos_matching_clusterskeeps its last count. A deleted ClusterSummary keeps itsreconcile_consecutive_failuresandreconcile_last_success_timestamp_seconds, and when its cluster is gone the undeploy is skipped, so a feature that was failing keeps reporting failures that never clear.This adds
clearProfileMetricsandclearClusterSummaryMetricstometrics.go:clearProfileMetricsoncereconcileDeleteCommonsucceeded, next tocleanMaps. It is the counterpart of thetrackMatchingClusterscall inreconcileNormal.postFinalizerCleanupcallsclearClusterSummaryMetrics, so it runs once the finalizer is removed. The undeploy records a lastRemovedoutcome before that, and a ClusterSummary whose deletion is blocked (cluster paused or not ready) keeps its series.clearClusterSummaryMetricsgets the profile labels fromgetProfileLabels, like the recording side, and deletes the series of each feature, and of both outcomes inreconcile_outcome_total, by their exact labels. The series of the same profile on other clusters, and of other profiles on the same cluster, stay.I left
reconcile_duration_secondsandreconcile_operations_totalalone. They are not labeled by profile and are shared by all the ClusterSummaries of a cluster, so they would have to go with the cluster, and an undeploy still running when the cluster goes could record them again. @gianlucam76 do you want them removed too, in a follow-up? I also didn't touch the shard handover: when a ClusterSummary moves to another shard, the old shard's addon-controller keeps its series.outdated_helm_chartis left to its checker, which has its own gap: #2030.Tests, next to the existing
reconcileDeletespecs:matching_clustersseries of a ClusterProfile, and of a Profile, is gone once the finalizer is removed, while the series of the other kind with the same name, and of a Profile with the same name in another namespace, stay.The three removal specs fail on main and pass here.
make testandmake lintpass. On kind,make fvandmake new-fvpass, and so doesmake fv-agentlesson a fresh cluster. With the reproduction steps from the issue,/metricshas no series left for the deleted profiles and ClusterSummaries. Onlyreconcile_duration_secondsandreconcile_operations_totalof the deleted SveltosCluster remain, as said above.Nothing changes while the objects exist: same metrics, labels and values.