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 permission for cleanupSubscription on OLM installation #704

Merged
merged 3 commits into from
Oct 24, 2023
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
24 changes: 24 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ rules:
- get
- list
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- pods/exec
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
jiangpengcheng marked this conversation as resolved.
Show resolved Hide resolved
- apiGroups:
- ""
resources:
Expand Down
8 changes: 8 additions & 0 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,11 @@ func ConvertHPAV2ToV2beta2(hpa *autov2.HorizontalPodAutoscaler) *autoscalingv2be

return result
}

func getBackgroundDeletionPolicy() client.DeleteOption {
backgroundDeletion := metav1.DeletePropagationBackground
var deleteOptions client.DeleteOption = &client.DeleteOptions{
PropagationPolicy: &backgroundDeletion,
}
return deleteOptions
}
7 changes: 3 additions & 4 deletions controllers/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (r *FunctionReconciler) ApplyFunctionVPA(ctx context.Context, function *v1a
func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, function *v1alpha1.Function) error {
if !spec.NeedCleanup(function) {
desiredJob := spec.MakeFunctionCleanUpJob(function)
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
if errors.IsNotFound(err) {
return nil
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi
}
} else {
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}
}
Expand All @@ -395,10 +395,9 @@ func (r *FunctionReconciler) ApplyFunctionCleanUpJob(ctx context.Context, functi

desiredJob := spec.MakeFunctionCleanUpJob(function)
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}

}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions controllers/function_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type FunctionReconciler struct {
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods/exec,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=verticalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update;delete
Expand Down
6 changes: 3 additions & 3 deletions controllers/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (r *SinkReconciler) ApplySinkVPA(ctx context.Context, sink *v1alpha1.Sink)
func (r *SinkReconciler) ApplySinkCleanUpJob(ctx context.Context, sink *v1alpha1.Sink) error {
if !spec.NeedCleanup(sink) {
desiredJob := spec.MakeSinkCleanUpJob(sink)
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
if errors.IsNotFound(err) {
return nil
}
Expand Down Expand Up @@ -376,7 +376,7 @@ func (r *SinkReconciler) ApplySinkCleanUpJob(ctx context.Context, sink *v1alpha1
}
} else {
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}
}
Expand All @@ -391,7 +391,7 @@ func (r *SinkReconciler) ApplySinkCleanUpJob(ctx context.Context, sink *v1alpha1

desiredJob := spec.MakeSinkCleanUpJob(sink)
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}

Expand Down
3 changes: 3 additions & 0 deletions controllers/sink_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type SinkReconciler struct {
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods/exec,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=verticalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update;delete
Expand Down
6 changes: 3 additions & 3 deletions controllers/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (r *SourceReconciler) ApplySourceVPA(ctx context.Context, source *v1alpha1.
func (r *SourceReconciler) ApplySourceCleanUpJob(ctx context.Context, source *v1alpha1.Source) error {
if !spec.NeedCleanup(source) {
desiredJob := spec.MakeSourceCleanUpJob(source)
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
if errors.IsNotFound(err) {
return nil
}
Expand Down Expand Up @@ -378,7 +378,7 @@ func (r *SourceReconciler) ApplySourceCleanUpJob(ctx context.Context, source *v1
}
} else {
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}
}
Expand All @@ -393,7 +393,7 @@ func (r *SourceReconciler) ApplySourceCleanUpJob(ctx context.Context, source *v1

desiredJob := spec.MakeSourceCleanUpJob(source)
// delete the cleanup job
if err := r.Delete(ctx, desiredJob); err != nil {
if err := r.Delete(ctx, desiredJob, getBackgroundDeletionPolicy()); err != nil {
return err
}

Expand Down
3 changes: 3 additions & 0 deletions controllers/source_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ type SourceReconciler struct {
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods/exec,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling.k8s.io,resources=verticalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update;delete
Expand Down
Loading