Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to be able to remove AddressPool finalizer by controller #283

Merged
merged 1 commit into from
Apr 23, 2024
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
2 changes: 2 additions & 0 deletions v2/config/rbac/coil-controller_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ rules:
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- coil.cybozu.com
Expand Down
2 changes: 1 addition & 1 deletion v2/controllers/addresspool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type AddressPoolReconciler struct {

var _ reconcile.Reconciler = &AddressPoolReconciler{}

// +kubebuilder:rbac:groups=coil.cybozu.com,resources=addresspools,verbs=get;list;watch
// +kubebuilder:rbac:groups=coil.cybozu.com,resources=addresspools,verbs=get;list;watch;update;patch
// +kubebuilder:rbac:groups=coil.cybozu.com,resources=addressblocks,verbs=get;list;watch

// Reconcile implements Reconciler interface.
Expand Down
38 changes: 38 additions & 0 deletions v2/e2e/coil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,4 +503,42 @@ var _ = Describe("Coil", func() {
Expect(resp).To(HaveLen(1 << 20))
}
})

It("should delete address pool", func() {
By("creating a dummy address pool")
_, err := kubectl(nil, "apply", "-f", "manifests/dummy_pool.yaml")
Expect(err).NotTo(HaveOccurred())

Eventually(func() error {
ap := coilv2.AddressPool{}
out, err := kubectl(nil, "get", "addresspool", "dummy", "-o", "json")
if err != nil {
return err
}
if err := json.Unmarshal(out, &ap); err != nil {
return err
}
return nil
}).Should(Succeed())

By("deleting the dummy address pool")
_, err = kubectl(nil, "delete", "-f", "manifests/dummy_pool.yaml")
Expect(err).NotTo(HaveOccurred())

Consistently(func() error {
apList := coilv2.AddressPoolList{}
out, err := kubectl(nil, "get", "addresspool", "-o", "json")
if err != nil {
return err
}
if err := json.Unmarshal(out, &apList); err != nil {
return err
}
if len(apList.Items) == 1 {
return nil
}
return fmt.Errorf("the number of AddressPool must be 1")
}).Should(Succeed())

})
})
8 changes: 8 additions & 0 deletions v2/e2e/manifests/dummy_pool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: coil.cybozu.com/v2
kind: AddressPool
metadata:
name: dummy
spec:
blockSizeBits: 0
subnets:
- ipv4: 10.225.0.0/30
Loading