diff --git a/charts/gha-runner-scale-set-controller/templates/manager_cluster_role.yaml b/charts/gha-runner-scale-set-controller/templates/manager_cluster_role.yaml index 0ee3bb53..cc58e3c2 100644 --- a/charts/gha-runner-scale-set-controller/templates/manager_cluster_role.yaml +++ b/charts/gha-runner-scale-set-controller/templates/manager_cluster_role.yaml @@ -78,6 +78,13 @@ rules: - get - patch - update +- apiGroups: + - actions.github.com + resources: + - ephemeralrunnersets/finalizers + verbs: + - patch + - update - apiGroups: - actions.github.com resources: diff --git a/charts/gha-runner-scale-set-controller/templates/manager_single_namespace_watch_role.yaml b/charts/gha-runner-scale-set-controller/templates/manager_single_namespace_watch_role.yaml index f195da55..f0f653d7 100644 --- a/charts/gha-runner-scale-set-controller/templates/manager_single_namespace_watch_role.yaml +++ b/charts/gha-runner-scale-set-controller/templates/manager_single_namespace_watch_role.yaml @@ -52,6 +52,13 @@ rules: - get - patch - update +- apiGroups: + - actions.github.com + resources: + - ephemeralrunnersets/finalizers + verbs: + - patch + - update - apiGroups: - actions.github.com resources: diff --git a/charts/gha-runner-scale-set-controller/tests/template_test.go b/charts/gha-runner-scale-set-controller/tests/template_test.go index 469cdecf..a097b433 100644 --- a/charts/gha-runner-scale-set-controller/tests/template_test.go +++ b/charts/gha-runner-scale-set-controller/tests/template_test.go @@ -169,7 +169,7 @@ func TestTemplate_CreateManagerClusterRole(t *testing.T) { assert.Empty(t, managerClusterRole.Namespace, "ClusterRole should not have a namespace") assert.Equal(t, "test-arc-gha-runner-scale-set-controller-manager-cluster-role", managerClusterRole.Name) - assert.Equal(t, 15, len(managerClusterRole.Rules)) + assert.Equal(t, 16, len(managerClusterRole.Rules)) _, err = helm.RenderTemplateE(t, options, helmChartPath, releaseName, []string{"templates/manager_single_namespace_controller_role.yaml"}) assert.ErrorContains(t, err, "could not find template templates/manager_single_namespace_controller_role.yaml in chart", "We should get an error because the template should be skipped") @@ -843,7 +843,7 @@ func TestTemplate_CreateManagerSingleNamespaceRole(t *testing.T) { assert.Equal(t, "test-arc-gha-runner-scale-set-controller-manager-single-namespace-role", managerSingleNamespaceWatchRole.Name) assert.Equal(t, "demo", managerSingleNamespaceWatchRole.Namespace) - assert.Equal(t, 13, len(managerSingleNamespaceWatchRole.Rules)) + assert.Equal(t, 14, len(managerSingleNamespaceWatchRole.Rules)) } func TestTemplate_ManagerSingleNamespaceRoleBinding(t *testing.T) { diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index b80a869d..ee70bd38 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -102,6 +102,13 @@ rules: - patch - update - watch +- apiGroups: + - actions.github.com + resources: + - ephemeralrunnersets/finalizers + verbs: + - patch + - update - apiGroups: - actions.github.com resources: diff --git a/controllers/actions.github.com/ephemeralrunnerset_controller.go b/controllers/actions.github.com/ephemeralrunnerset_controller.go index 6a90ec78..f4850cf5 100644 --- a/controllers/actions.github.com/ephemeralrunnerset_controller.go +++ b/controllers/actions.github.com/ephemeralrunnerset_controller.go @@ -56,6 +56,7 @@ type EphemeralRunnerSetReconciler struct { //+kubebuilder:rbac:groups=actions.github.com,resources=ephemeralrunnersets,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=actions.github.com,resources=ephemeralrunnersets/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=actions.github.com,resources=ephemeralrunnersets/finalizers,verbs=update;patch //+kubebuilder:rbac:groups=actions.github.com,resources=ephemeralrunners,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=actions.github.com,resources=ephemeralrunners/status,verbs=get