From 5289f4ac3468af5c99f5cef5d9d709b0c2f48074 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Wed, 25 Nov 2026 22:04:51 -0600 Subject: [PATCH] feat: Hold physical claims until IPAM lets go A provider reads a physical claim's absence as proof its address is free. NSO deleted the IPAM claims and removed its finalizer without reading IPAM back, and freed only the first of the two names an address can be held under, so a claim could vanish while IPAM still held it. A physical claim under Delete now stays until every IPAM claim its addresses could be held under here is gone and no IPAM allocation names one. Other modes release as before. Key changes: - verify release for physical claims before the interface is deleted - report Ready=False ReleaseUnverified with the address still held - skip same-named IPAM claims another location holds - keep the reason steady across retries instead of rewriting it Co-Authored-By: Claude Opus 5.5 --- api/v1alpha/networkinterfaceclaim_types.go | 5 + .../networkinterfaceclaim_controller.go | 171 +++++++++-- .../networkinterfaceclaim_release_test.go | 274 ++++++++++++++++++ internal/networkagent/catalog.go | 7 + 4 files changed, 440 insertions(+), 17 deletions(-) create mode 100644 internal/controller/networkinterfaceclaim_release_test.go diff --git a/api/v1alpha/networkinterfaceclaim_types.go b/api/v1alpha/networkinterfaceclaim_types.go index e1f6966a..38a0b383 100644 --- a/api/v1alpha/networkinterfaceclaim_types.go +++ b/api/v1alpha/networkinterfaceclaim_types.go @@ -78,6 +78,11 @@ const ( // its interface released, so it no longer offers one to a workload. NetworkInterfaceClaimReasonReleasing = "Releasing" + // NetworkInterfaceClaimReasonReleaseUnverified means a physical claim is + // being deleted and IPAM still holds one of its addresses, so the claim + // stays until IPAM no longer does. + NetworkInterfaceClaimReasonReleaseUnverified = "ReleaseUnverified" + // NetworkInterfaceClaimReasonProjectNamespaceNotFound means the namespace // addresses are allocated in does not exist in the project's control plane. // The platform provisions it with the project, so its absence says the diff --git a/internal/controller/networkinterfaceclaim_controller.go b/internal/controller/networkinterfaceclaim_controller.go index 52100753..fb16b972 100644 --- a/internal/controller/networkinterfaceclaim_controller.go +++ b/internal/controller/networkinterfaceclaim_controller.go @@ -66,6 +66,10 @@ const ( // Nothing watches the network, the namespace or IPAM, so a rejected claim // needs its own way back. rejectedClaimRetryInterval = time.Minute + + // IPAM sends no event when it finishes releasing, so a physical claim + // waiting on it looks again. + unverifiedReleaseRetryInterval = 10 * time.Second ) // NetworkInterfaceClaimReconciler binds a NetworkInterfaceClaim to a @@ -131,7 +135,7 @@ func (r *NetworkInterfaceClaimReconciler) reconcileClaim( } if !claim.DeletionTimestamp.IsZero() { - return ctrl.Result{}, r.release(ctx, cl, &claim) + return r.release(ctx, cl, &claim) } if controllerutil.AddFinalizer(&claim, networkInterfaceClaimFinalizer) { @@ -1496,71 +1500,84 @@ func (r *NetworkInterfaceClaimReconciler) release( ctx context.Context, cl client.Client, claim *networkingv1alpha.NetworkInterfaceClaim, -) error { +) (ctrl.Result, error) { if !controllerutil.ContainsFinalizer(claim, networkInterfaceClaimFinalizer) { - return nil + return ctrl.Result{}, nil } if err := markReleasing(ctx, cl, claim); err != nil { - return err + return ctrl.Result{}, err } var iface networkingv1alpha.NetworkInterface interfaceKey := client.ObjectKey{Namespace: claim.Namespace, Name: interfaceNameForClaim(claim)} err := cl.Get(ctx, interfaceKey, &iface) if err != nil && !apierrors.IsNotFound(err) { - return fmt.Errorf("failed fetching network interface: %w", err) + return ctrl.Result{}, fmt.Errorf("failed fetching network interface: %w", err) } interfaceExists := err == nil held := interfaceExists && iface.Spec.ClaimRef != nil && iface.Spec.ClaimRef.Name == claim.Name retain := claim.Spec.ReclaimPolicy == networkingv1alpha.NetworkInterfaceReclaimPolicyRetain + verify := claim.Spec.AttachmentMode == networkingv1alpha.NetworkInterfaceAttachmentModePhysical && !retain switch { case held && retain: iface.Spec.ClaimRef = nil if err := cl.Update(ctx, &iface); err != nil { - return fmt.Errorf("failed unbinding network interface: %w", err) + return ctrl.Result{}, fmt.Errorf("failed unbinding network interface: %w", err) } if err := markInterfaceAvailable(ctx, cl, &iface); err != nil { - return err + return ctrl.Result{}, err } case held: if err := r.releaseAddresses(ctx, cl, claim.Namespace, &iface); err != nil { - return err + return ctrl.Result{}, err + } + // The interface records which names the addresses were allocated + // under, so it is kept until IPAM confirms none of them is held. + if verify { + if result, err := r.awaitRelease(ctx, cl, claim, allocationClaimName(&iface), allocationEntries(&iface)); err != nil || !result.IsZero() { + return result, err + } } if controllerutil.RemoveFinalizer(&iface, networkInterfaceFinalizer) { if err := cl.Update(ctx, &iface); err != nil { - return fmt.Errorf("failed clearing network interface finalizer: %w", err) + return ctrl.Result{}, fmt.Errorf("failed clearing network interface finalizer: %w", err) } } if err := cl.Delete(ctx, &iface); err != nil && !apierrors.IsNotFound(err) { - return fmt.Errorf("failed deleting network interface: %w", err) + return ctrl.Result{}, fmt.Errorf("failed deleting network interface: %w", err) } case interfaceExists && iface.Spec.ClaimRef == nil && retain: // A previous attempt unbound the interface and failed before recording // it. Nothing else writes phase for an unbound interface. if err := markInterfaceAvailable(ctx, cl, &iface); err != nil { - return err + return ctrl.Result{}, err } case !retain: // The interface is gone, or never named this claim. Either way the // addresses this claim allocated are named after it. if err := r.releaseClaimAllocations(ctx, cl, claim); err != nil { - return err + return ctrl.Result{}, err + } + if verify && claim.Status.NetworkInterfaceRef != nil { + if result, err := r.awaitRelease(ctx, cl, claim, claim.Name, claimEntries(claim)); err != nil || !result.IsZero() { + return result, err + } } } location, err := r.location(ctx) if err != nil { - return err + return ctrl.Result{}, err } if err := r.syncNetworkContextHold(ctx, cl, claim.Namespace, claim.Spec.Network.Name, location); err != nil { - return err + return ctrl.Result{}, err } controllerutil.RemoveFinalizer(claim, networkInterfaceClaimFinalizer) @@ -1568,11 +1585,124 @@ func (r *NetworkInterfaceClaimReconciler) release( // Deletion can complete after the initial read but before this finalizer // write. The object being gone means the release is already complete. if apierrors.IsNotFound(err) { - return nil + return ctrl.Result{}, nil } - return fmt.Errorf("failed removing finalizer: %w", err) + return ctrl.Result{}, fmt.Errorf("failed removing finalizer: %w", err) } - return nil + return ctrl.Result{}, nil +} + +// awaitRelease holds a physical claim until IPAM no longer holds any of its +// addresses here, under any name they could carry. A provider reads the +// claim's absence as proof the address is free, and IPAM finishes a delete on +// its own schedule. +func (r *NetworkInterfaceClaimReconciler) awaitRelease( + ctx context.Context, + cl client.Client, + claim *networkingv1alpha.NetworkInterfaceClaim, + owner string, + entries []allocationEntry, +) (ctrl.Result, error) { + address, err := r.addressStillHeld(ctx, cl, claim.Namespace, owner, entries) + if err != nil { + return ctrl.Result{}, err + } + if address == "" { + return ctrl.Result{}, nil + } + + if apimeta.SetStatusCondition(&claim.Status.Conditions, metav1.Condition{ + Type: networkingv1alpha.NetworkInterfaceClaimReady, + Status: metav1.ConditionFalse, + Reason: networkingv1alpha.NetworkInterfaceClaimReasonReleaseUnverified, + ObservedGeneration: claim.Generation, + Message: fmt.Sprintf("IPAM still holds address %s, so the claim is kept until it is released", address), + }) { + if err := cl.Status().Update(ctx, claim); err != nil { + return ctrl.Result{}, fmt.Errorf("failed reporting an unverified release: %w", err) + } + } + return ctrl.Result{RequeueAfter: unverifiedReleaseRetryInterval}, nil +} + +// addressStillHeld returns an address IPAM still holds for the claim in this +// location, or nothing once every IPClaim the addresses could be named by is +// gone and no IPAllocation names one. An IPClaim another location holds under +// the same name is that location's, and does not count. +func (r *NetworkInterfaceClaimReconciler) addressStillHeld( + ctx context.Context, + cl client.Client, + namespace string, + owner string, + entries []allocationEntry, +) (string, error) { + if len(entries) == 0 { + return "", nil + } + + routing, err := r.resolveProject(ctx, cl, namespace) + if err != nil { + return "", fmt.Errorf("cannot verify the release of addresses claimed by %q: %w", owner, err) + } + location, err := r.location(ctx) + if err != nil { + return "", fmt.Errorf("cannot verify the release of addresses claimed by %q: %w", owner, err) + } + ipamClient, err := r.IPAM.ClientForProject(routing.project) + if err != nil { + return "", fmt.Errorf("failed building IPAM client: %w", err) + } + + names := map[string]allocationEntry{} + for _, entry := range entries { + for _, name := range ipClaimNames(owner, entry.discriminator, location) { + names[name] = entry + } + } + + for name, entry := range names { + ipClaim := &ipamv1alpha1.IPClaim{} + err := ipamClient.Get(ctx, client.ObjectKey{Namespace: routing.projectNamespace, Name: name}, ipClaim) + if apierrors.IsNotFound(err) { + continue + } + if err != nil { + return "", fmt.Errorf("failed reading IPClaim %q: %w", name, err) + } + if allocationServesLocation(ipClaim, location) { + return heldAddress(entry.address, ipClaim.Status.AllocatedCIDR), nil + } + } + + var allocations ipamv1alpha1.IPAllocationList + if err := ipamClient.List(ctx, &allocations, client.InNamespace(routing.projectNamespace)); err != nil { + return "", fmt.Errorf("failed listing IPAllocations: %w", err) + } + for i := range allocations.Items { + allocation := &allocations.Items[i] + if allocation.Spec.ClaimRef == nil { + continue + } + entry, named := names[allocation.Spec.ClaimRef.Name] + if !named { + continue + } + if held := allocation.Spec.Scope[ipamScopeRoleLocation].Name; held != "" && held != location.Name { + continue + } + return heldAddress(entry.address, allocation.Status.AllocatedCIDR), nil + } + return "", nil +} + +func heldAddress(recorded, allocated string) string { + if recorded != "" { + return recorded + } + if allocated != "" { + return allocated + } + return "an address" } // markReleasing withdraws Prepared and Ready from a claim being deleted, before @@ -1584,6 +1714,13 @@ func markReleasing(ctx context.Context, cl client.Client, claim *networkingv1alp networkingv1alpha.NetworkInterfaceClaimPrepared, networkingv1alpha.NetworkInterfaceClaimReady, } { + // A later step of the release names what it waits on in Ready, and + // restating Releasing would hide it. + if current := apimeta.FindStatusCondition(claim.Status.Conditions, conditionType); current != nil && + current.Status == metav1.ConditionFalse && + current.Reason == networkingv1alpha.NetworkInterfaceClaimReasonReleaseUnverified { + continue + } changed = apimeta.SetStatusCondition(&claim.Status.Conditions, metav1.Condition{ Type: conditionType, Status: metav1.ConditionFalse, diff --git a/internal/controller/networkinterfaceclaim_release_test.go b/internal/controller/networkinterfaceclaim_release_test.go new file mode 100644 index 00000000..d59995ff --- /dev/null +++ b/internal/controller/networkinterfaceclaim_release_test.go @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +package controller + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/require" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + ipamv1alpha1 "go.miloapis.com/ipam/pkg/apis/ipam/v1alpha1" + locationsv1alpha1 "go.miloapis.com/locations/api/v1alpha1" + + networkingv1alpha "go.datum.net/network-services-operator/api/v1alpha" +) + +const physicalClaimName = "server-data" + +// boundPhysicalClaim stands up what a bound physical claim leaves behind: the +// claim, its interface, and an IPClaim under each of the given names. NSO +// refuses to bind physical claims until switch ports can be held, so the state +// is written directly, the way the bind path writes it. +func boundPhysicalClaim(s *scenario, ipClaimNames ...string) (*networkingv1alpha.NetworkInterfaceClaim, string) { + s.t.Helper() + name := physicalClaimName + + claim := s.createClaim(name, networkingv1alpha.NetworkInterfaceClaimSpec{ + InterfaceName: "data", + AttachmentMode: networkingv1alpha.NetworkInterfaceAttachmentModePhysical, + AttachmentPoint: physicalAttachmentPoint("Ethernet1/12"), + IPFamilies: []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}, + ReclaimPolicy: networkingv1alpha.NetworkInterfaceReclaimPolicyDelete, + }) + s.reconcile(claim) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(s.t, err) + var address string + for _, ipClaimName := range ipClaimNames { + ipClaim := physicalIPClaim(ipClaimName, testLocationName) + require.NoError(s.t, ipamClient.Create(s.ctx, ipClaim)) + require.NoError(s.t, ipamClient.Get(s.ctx, client.ObjectKeyFromObject(ipClaim), ipClaim)) + if address == "" { + address = ipClaim.Status.AllocatedCIDR + } + } + require.NotEmpty(s.t, address) + + claim = s.getClaim(name) + networkContext := &networkingv1alpha.NetworkContext{} + networkContext.Spec.Network.Name = "default" + iface := &networkingv1alpha.NetworkInterface{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: s.namespace, + Name: name, + Annotations: map[string]string{allocationClaimAnnotation: name}, + Finalizers: []string{networkInterfaceFinalizer}, + }, + Spec: interfaceSpecForClaim(claim, networkContext), + } + iface.Spec.Addresses = []networkingv1alpha.NetworkInterfaceAddress{{ + Family: networkingv1alpha.IPv4Protocol, Address: address, Primary: true, + }} + require.NoError(s.t, s.client.Create(s.ctx, iface)) + + claim.Status.NetworkInterfaceRef = &networkingv1alpha.LocalNetworkInterfaceRef{Name: name} + require.NoError(s.t, s.client.Status().Update(s.ctx, claim)) + return s.getClaim(name), address +} + +func physicalIPClaim(name, location string) *ipamv1alpha1.IPClaim { + ipClaim := &ipamv1alpha1.IPClaim{} + ipClaim.Namespace = testProjectNS + ipClaim.Name = name + ipClaim.Spec = ipamv1alpha1.IPClaimSpec{ + IPFamily: ipamv1alpha1.IPFamily(networkingv1alpha.IPv4Protocol), + ReclaimPolicy: ipamv1alpha1.ReclaimDelete, + Scope: map[string]ipamv1alpha1.ScopeRef{ + ipamScopeRoleNetwork: {APIGroup: datumNetworkingAPIGroup, Kind: "Network", Name: "default"}, + ipamScopeRoleLocation: {APIGroup: datumNetworkingAPIGroup, Kind: "Location", Name: location}, + }, + } + return ipClaim +} + +func physicalIPClaimNames(claimName string) []string { + return ipClaimNames(claimName, familyDiscriminator(networkingv1alpha.IPv4Protocol), + locationsv1alpha1.LocationReference{Name: testLocationName}) +} + +func (s *scenario) claimGone(name string) bool { + s.t.Helper() + var claim networkingv1alpha.NetworkInterfaceClaim + err := s.client.Get(s.ctx, client.ObjectKey{Namespace: s.namespace, Name: name}, &claim) + if apierrors.IsNotFound(err) { + return true + } + require.NoError(s.t, err) + return false +} + +func (s *scenario) requireReleaseUnverified(name, address string) { + s.t.Helper() + require.False(s.t, s.claimGone(name), "the claim must stay while IPAM holds its address") + ready := conditionOf(s.getClaim(name), networkingv1alpha.NetworkInterfaceClaimReady) + require.NotNil(s.t, ready) + require.Equal(s.t, metav1.ConditionFalse, ready.Status) + require.Equal(s.t, networkingv1alpha.NetworkInterfaceClaimReasonReleaseUnverified, ready.Reason) + require.Contains(s.t, ready.Message, address) + for _, name := range physicalIPClaimNames(name) { + require.NotContains(s.t, ready.Message, name, "the reason must not name NSO's IPAM claims") + } + _, err := s.getInterface(name) + require.NoError(s.t, err, "the interface records the IPAM names and must outlive an unverified release") +} + +func TestPhysicalReleaseCompletesOnceIPAMLetsGo(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, _ := boundPhysicalClaim(s, names[0]) + + s.deleteClaim(claim) + + require.True(t, s.claimGone(physicalClaimName)) + _, err := s.getInterface(physicalClaimName) + require.True(t, apierrors.IsNotFound(err)) + require.Zero(t, s.ipam.storedAnywhere(t)) +} + +func TestPhysicalReleaseWaitsWhileIPAMRefusesTheDelete(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, _ := boundPhysicalClaim(s, names[0]) + s.ipam.refuseRelease(names[0], errors.New("ipam is unavailable")) + + require.NoError(t, s.client.Delete(s.ctx, claim)) + _, err := s.reconciler.reconcileClaim(s.ctx, s.client, s.events, client.ObjectKeyFromObject(claim)) + require.Error(t, err) + require.False(t, s.claimGone(physicalClaimName)) + + s.ipam.refuseRelease(names[0], nil) + s.reconcile(claim) + require.True(t, s.claimGone(physicalClaimName), "a release that fails is retried, and completes once IPAM answers") +} + +func TestPhysicalReleaseWaitsForALingeringAllocation(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, address := boundPhysicalClaim(s, names[0]) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(t, err) + lingering := &ipamv1alpha1.IPAllocation{} + lingering.Namespace = testProjectNS + lingering.Name = "lingering" + lingering.Spec.ClaimRef = &ipamv1alpha1.LocalRef{Name: names[0]} + lingering.Spec.Scope = map[string]ipamv1alpha1.ScopeRef{ipamScopeRoleLocation: {Name: testLocationName}} + require.NoError(t, ipamClient.Create(s.ctx, lingering)) + + s.deleteClaim(claim) + s.requireReleaseUnverified(physicalClaimName, address) + s.reconcile(claim) + s.requireReleaseUnverified(physicalClaimName, address) + + require.NoError(t, ipamClient.Get(s.ctx, client.ObjectKeyFromObject(lingering), lingering)) + lingering.Spec.ClaimRef = nil + require.NoError(t, ipamClient.Update(s.ctx, lingering)) + s.reconcile(claim) + require.True(t, s.claimGone(physicalClaimName)) +} + +func TestPhysicalReleaseFreesEveryNameAnAddressIsHeldUnder(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, _ := boundPhysicalClaim(s, names...) + + s.deleteClaim(claim) + require.False(t, s.claimGone(physicalClaimName), "one pass frees one name, so the claim waits for the other") + + s.reconcile(claim) + require.True(t, s.claimGone(physicalClaimName)) + require.Zero(t, s.ipam.storedAnywhere(t), "both names must be released") +} + +func TestPhysicalReleaseIgnoresAnotherLocationsAllocation(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, _ := boundPhysicalClaim(s, names[1]) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(t, err) + foreign := physicalIPClaim(names[0], "location-elsewhere") + require.NoError(t, ipamClient.Create(s.ctx, foreign)) + + s.deleteClaim(claim) + require.True(t, s.claimGone(physicalClaimName), "another location's same-named allocation is not this claim's") + require.NoError(t, ipamClient.Get(s.ctx, client.ObjectKeyFromObject(foreign), foreign), + "another location's allocation must be left alone") +} + +func TestPhysicalReleaseKeepsItsReasonAcrossPasses(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, address := boundPhysicalClaim(s, names[0]) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(t, err) + lingering := &ipamv1alpha1.IPAllocation{} + lingering.Namespace = testProjectNS + lingering.Name = "lingering" + lingering.Spec.ClaimRef = &ipamv1alpha1.LocalRef{Name: names[0]} + require.NoError(t, ipamClient.Create(s.ctx, lingering)) + + s.deleteClaim(claim) + first := s.getClaim(physicalClaimName).ResourceVersion + s.reconcile(claim) + s.requireReleaseUnverified(physicalClaimName, address) + require.Equal(t, first, s.getClaim(physicalClaimName).ResourceVersion, + "a pass that finds nothing new must not rewrite the claim") +} + +// Verified release is for physical claims. Compute's claims release as they +// always have, so a lingering allocation does not hold them. +func TestVirtualReleaseIsUnchanged(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + claim := s.createClaim("web-0-eth0", networkingv1alpha.NetworkInterfaceClaimSpec{ + InterfaceName: "eth0", + IPFamilies: []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}, + ReclaimPolicy: networkingv1alpha.NetworkInterfaceReclaimPolicyDelete, + }) + s.reconcile(claim) + require.NotNil(t, s.getClaim("web-0-eth0").Status.NetworkInterfaceRef) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(t, err) + lingering := &ipamv1alpha1.IPAllocation{} + lingering.Namespace = testProjectNS + lingering.Name = "lingering" + lingering.Spec.ClaimRef = &ipamv1alpha1.LocalRef{Name: ipClaimName("web-0-eth0", familyDiscriminator(networkingv1alpha.IPv4Protocol))} + require.NoError(t, ipamClient.Create(s.ctx, lingering)) + + s.deleteClaim(s.getClaim("web-0-eth0")) + require.True(t, s.claimGone("web-0-eth0")) +} + +// An interface removed out of band takes the record of its IPAM names with it, +// so the claim falls back to the names derived from itself and still waits. +func TestPhysicalReleaseWaitsWhenTheInterfaceIsAlreadyGone(t *testing.T) { + s := newScenario(t, true, []networkingv1alpha.IPFamily{networkingv1alpha.IPv4Protocol}) + names := physicalIPClaimNames(physicalClaimName) + claim, _ := boundPhysicalClaim(s, names[0]) + + ipamClient, err := s.ipam.ClientForProject(testProject) + require.NoError(t, err) + lingering := &ipamv1alpha1.IPAllocation{} + lingering.Namespace = testProjectNS + lingering.Name = "lingering" + lingering.Spec.ClaimRef = &ipamv1alpha1.LocalRef{Name: names[0]} + require.NoError(t, ipamClient.Create(s.ctx, lingering)) + + iface, err := s.getInterface(physicalClaimName) + require.NoError(t, err) + iface.Finalizers = nil + require.NoError(t, s.client.Update(s.ctx, iface)) + require.NoError(t, s.client.Delete(s.ctx, iface)) + + s.deleteClaim(claim) + require.False(t, s.claimGone(physicalClaimName)) + ready := conditionOf(s.getClaim(physicalClaimName), networkingv1alpha.NetworkInterfaceClaimReady) + require.Equal(t, networkingv1alpha.NetworkInterfaceClaimReasonReleaseUnverified, ready.Reason) +} diff --git a/internal/networkagent/catalog.go b/internal/networkagent/catalog.go index aac3dd52..8fae67c1 100644 --- a/internal/networkagent/catalog.go +++ b/internal/networkagent/catalog.go @@ -476,6 +476,13 @@ func claimRefusals() []ReasonInfo { {reasonAddressClassMissing, retained("it holds no address of a class the workload now asks for, such as a public address")}, {reasonReclaimPolicyMismatch, retained("its addresses were kept under a different rule for what happens when the instance goes away")}, {reasonAttachmentPointMismatch, retained("it is wired to a different switch port, or for a different purpose, from the one the server's claim now names")}, + {networkingv1alpha.NetworkInterfaceClaimReasonReleaseUnverified, ReasonInfo{ + Actionability: ActionabilityTransient, Scope: ScopeInstance, + Explanation: "This server's network interface is being removed, and the platform is waiting for " + + "its address to be returned before it finishes.", + Remediation: remediationWait, Skill: SkillInterfaceTriage, + ExpectedDuration: windowRemoval, + }}, {networkingv1alpha.NetworkInterfaceClaimReasonPhysicalAttachmentUnsupported, ReasonInfo{ Actionability: ActionabilityPlatform, Scope: ScopeInstance, Explanation: "This server's network interface asks to reach its network through a switch port, " +