Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions internal/controllers/ipaddressclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,36 @@ var _ = Describe("IPAddressClaimReconciler", func() {
})
})

Context("When the cluster can not be retrieved", func() {
AfterEach(func() {
deleteClaim("test", namespace)
deleteNamespacedPool(poolName, namespace)
})
It("When the cluster cannot be retrieved", func() {
claim := ipamv1.IPAddressClaim{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: namespace,
},
Spec: ipamv1.IPAddressClaimSpec{
ClusterName: clusterName,
PoolRef: corev1.TypedLocalObjectReference{
APIGroup: ptr.To("ipam.cluster.x-k8s.io"),
Kind: "InClusterIPPool",
Name: poolName,
},
},
}
Expect(k8sClient.Create(context.Background(), &claim)).To(Succeed())
Eventually(Get(&claim)).Should(Succeed())

addresses := ipamv1.IPAddressList{}
Consistently(ObjectList(&addresses, client.InNamespace(namespace))).
WithTimeout(5 * time.Second).WithPolling(100 * time.Millisecond).Should(
HaveField("Items", HaveLen(0)))
})
})

Context("When the ipaddressclaim spec.clusterName reference a paused cluster via cluster label", func() {
AfterEach(func() {
deleteClaim("test", namespace)
Expand Down
3 changes: 3 additions & 0 deletions pkg/ipamutil/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func (r *ClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ct
}
if err != nil {
if apierrors.IsNotFound(err) {
if !claim.ObjectMeta.DeletionTimestamp.IsZero() {
return ctrl.Result{}, r.reconcileDelete(ctx, claim)
}
log.Info("IPAddressClaim linked to a cluster that is not found, unable to determine cluster's paused state, skipping reconciliation")
return ctrl.Result{}, nil
}
Expand Down
Loading