Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzu committed Dec 31, 2024
1 parent b3d715f commit fa19126
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ resources:
- bases/infrastructure.cluster.x-k8s.io_incusmachinetemplates.yaml
# +kubebuilder:scaffold:crdkustomizeresource

commonLabels:
cluster.x-k8s.io/v1beta1: v1alpha1

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
Expand Down
2 changes: 1 addition & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adds namespace to all resources.
namespace: cluster-api-provider-incus-system
namespace: capincus-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
Expand Down
9 changes: 9 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- cluster.x-k8s.io
resources:
- clusters
- machines
- machinesets
verbs:
- get
- list
Expand Down
6 changes: 5 additions & 1 deletion internal/controller/incusmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type IncusMachineReconciler struct {
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=incusmachines/finalizers,verbs=update
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=get;list;watch
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machines,verbs=get;list;watch
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=machinesets,verbs=get;list;watch
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down Expand Up @@ -153,7 +155,9 @@ func (r *IncusMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request
// Note: Finalizers in general can only be added when the deletionTimestamp is not set.
if incusMachine.ObjectMeta.DeletionTimestamp.IsZero() && !controllerutil.ContainsFinalizer(incusMachine, infrav1alpha1.MachineFinalizer) {
controllerutil.AddFinalizer(incusMachine, infrav1alpha1.MachineFinalizer)
return ctrl.Result{}, nil
return ctrl.Result{
Requeue: true,
}, nil
}

// Handle deleted machines
Expand Down

0 comments on commit fa19126

Please sign in to comment.