Skip to content

reconcile: delete finalizer during reconcile only for resources that do not have any cleanup tasks#1902

Open
AndrewChubatiuk wants to merge 2 commits intomasterfrom
fix-do-not-delete-finalizer-on-vm-resources
Open

reconcile: delete finalizer during reconcile only for resources that do not have any cleanup tasks#1902
AndrewChubatiuk wants to merge 2 commits intomasterfrom
fix-do-not-delete-finalizer-on-vm-resources

Conversation

@AndrewChubatiuk
Copy link
Contributor

@AndrewChubatiuk AndrewChubatiuk commented Feb 28, 2026

currently reconcile functions for VMAgent, VMAuth and VMCluster remove finalizer on non-empty DeletionTimestamp, which may lead to dangling resources. This PR keeps finalizer for these resources when DeletionTimestamp is not empty to let respective controller handle resource removal.

additionally:

  • made diff more human readable. fixes Improve diff support #1821
  • fixed API templates to remove extra newlines from generated markdown
  • remove finalizer for VMServiceScrape and VMPodscrape during reconcile as both resources have no cleanup actions needed
  • aligned diffDeep and diffDeepDerivative signature with same functions from equality packages
  • removed impact of metadata change on a need to recreate STS due to PVC changes
  • added RevisionHistoryLimit to a list of STS mutable fields to avoid its unneeded recreation

Summary by cubic

Keep finalizers during reconcile only for resources that require cleanup (VMAgent, VMAuth, VMCluster); drop them for core K8s and scrape resources. Diff logs are now structured field maps, and logs use NamespacedName.String().

  • Bug Fixes

    • Finalizers: remove only for ConfigMap/Secret/Service/RBAC/HPA/VPA/Ingress/HTTPRoute/PDB/DaemonSet/Deployment/StatefulSet/VMPodScrape/VMServiceScrape; keep for VMAgent/VMAuth/VMCluster. collectGarbage honors this and waits on deletion.
    • StatefulSet: ignore PVC metadata when deciding to recreate; compare Spec only and normalize immutable fields (incl. RevisionHistoryLimit); log spec_diff.
    • Diff API: fixed argument order; tests and changelog updated.
  • Refactors

    • Diff output: field-level map keyed by JSON paths under a root (e.g., spec/data/binaryData/subjects/rules/roleRef); treats empty slices/maps as equal; labels/annotations included. Reconcilers log these as structured fields (e.g., spec_diff, data_diff).
    • Logs: consistent NamespacedName.String() usage and clearer messages across reconcile and vmdistributed.

Written for commit 299a15a. Summary will update on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 21 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/CHANGELOG.md">

<violation number="1" location="docs/CHANGELOG.md:23">
P1: Custom agent: **Changelog Review Agent**

This changelog entry violates the mandatory structure: it lacks required issue/PR references and describes internal implementation details instead of a clear user-visible before/after outcome.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@AndrewChubatiuk AndrewChubatiuk force-pushed the fix-do-not-delete-finalizer-on-vm-resources branch 8 times, most recently from 47418d4 to ed152c7 Compare March 1, 2026 05:44
- convert NamespacedName to string in logs
- update diffDeepDerivative, now slices and maps and considered equal if length of both is 0 (not only of the first maps as it was before), before labels and annotations diff was ignored
- do not take PVC metadata diff into account during checking if STS should be recreated since metadata update is covered by a separate function
- prettify reconcile diff
- fixed diffDeep and diffDeepDerivative signature, arguments were swapped before
@AndrewChubatiuk AndrewChubatiuk force-pushed the fix-do-not-delete-finalizer-on-vm-resources branch from ed152c7 to 299a15a Compare March 1, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve diff support

2 participants