Skip to content

fix: sync KRM function resource deletions in specializers#1094

Open
pulkitvats2007-crypto wants to merge 1 commit into
nephio-project:mainfrom
pulkitvats2007-crypto:fix-specializer-krm-deletions-main
Open

fix: sync KRM function resource deletions in specializers#1094
pulkitvats2007-crypto wants to merge 1 commit into
nephio-project:mainfrom
pulkitvats2007-crypto:fix-specializer-krm-deletions-main

Conversation

@pulkitvats2007-crypto
Copy link
Copy Markdown
Contributor

Summary

Fixes a critical issue where KRM function pipelines were unable to delete resources due to append-only reconciliation logic in the Specializer controllers.

Previously, controllers (generic-specializer, ipam-specializer, vlan-specializer) rebuilt prr.Spec.Resources by iterating only over rl.Items. Since deleted resources are absent from rl.Items, they were never removed from the map, resulting in stale ("ghost") resources persisting in the package.

This PR introduces explicit deletion synchronization:

  • Capture original resource paths before running the KRM pipeline.
  • Capture surviving paths after pipeline execution.
  • Diff both sets and explicitly remove missing entries using delete().

This ensures full state reconciliation (create/update/delete) instead of append-only behavior.


Bug

Root Cause:
The controller assumed that iterating over the mutated rl.Items was sufficient to sync state back to prr.Spec.Resources. This ignored deletion semantics entirely.

Resulting Issue:

  • Resources deleted by KRM functions (e.g., via condkptsdk GC) were silently retained.
  • No errors or signals were emitted, leading to misleading "successful" reconciliations.

Fix

  • Added path tracking (originalPaths, survivingPaths)
  • Implemented syncDeletedResources helper to reconcile deletions
  • Applied fix consistently across:
    • generic-specializer
    • ipam-specializer
    • vlan-specializer
  • Added unit tests to prevent regression

Impact

  • Eliminates ghost resources from PackageRevisions
  • Restores correct KRM deletion semantics
  • Prevents downstream GitOps drift and infra conflicts (e.g., duplicate IPs)
  • Improves reliability of Nephio automation in dynamic/topology-changing environments

Signed-off-by: pulkitvats2007-crypto <pulkitvats2007@gmail.com>
@nephio-prow
Copy link
Copy Markdown
Contributor

nephio-prow Bot commented Apr 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign liamfallon for approval by writing /assign @liamfallon in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nephio-prow
Copy link
Copy Markdown
Contributor

nephio-prow Bot commented Apr 15, 2026

Hi @pulkitvats2007-crypto. Thanks for your PR.

I'm waiting for a nephio-project member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant