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

Reducing the core group privileges #2848

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

OdedViner
Copy link
Contributor

@OdedViner OdedViner commented Oct 10, 2024

Procedure:
1. Deploy OCP4.17 [4.17.0-0.nightly-2024-10-06-021039]

2. Deploy OCS4.17 [4.17.0-117.stable]

3.Verify storagecluster in Ready State
$ oc get storagecluster
NAME                 AGE   PHASE   EXTERNAL   CREATED AT             VERSION
ocs-storagecluster   37h   Ready              2024-10-08T16:24:24Z   4.17.0

4.Check clusterrole status:
// +kubebuilder:rbac:groups=core,resources=pods;services;serviceaccounts;endpoints;persistentvolumes;persistentvolumeclaims;events;configmaps;secrets;nodes,verbs=*
$ oc edit clusterrole ocs-operator.v4.17.0-117-arcDX0KWGNx65tdjyZ3BPWOaOrKVTvxGaY4Adk
- apiGroups:
  - ""
  resources:
  - configmaps
  - endpoints
  - events
  - nodes
  - persistentvolumeclaims
  - pods
  - secrets
  - serviceaccounts
  - services
  verbs:
  - '*'

5. Add "create" and "delete" verbs
- apiGroups:
  - ""
  resources:
  - configmaps
  - endpoints
  - events
  - nodes
  - persistentvolumeclaims
  - pods
  - secrets
  - serviceaccounts
  - services
  verbs:
  - create
  - delete

6.Delete ocs-operator pod and check ocs-operator pod logs:
$ oc delete pod ocs-operator

$ oc logs ocs-operator
E1010 09:57:25.116815       1 reflector.go:158] "Unhandled Error" err="sigs.k8s.io/controller-runtime/pkg/cache/internal/informers.go:106: Failed to watch *v1.Secret: failed to list *v1.Secret: secrets is forbidden: User \"system:serviceaccount:openshift-storage:ocs-operator\" cannot list resource \"secrets\" in API group \"\" in the namespace \"openshift-storage-extended\"" logger="UnhandledError"
{"level":"error","ts":"2024-10-10T09:58:43Z","logger":"controller-runtime.source.EventHandler","msg":"failed to get informer from cache","error":"Timeout: failed waiting for *v1.PersistentVolumeClaim Informer to sync","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/source.(*Kind[...]).Start.func1.1\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/source/kind.go:76\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func1\n\t/remote-source/app/vendor/k8s.io/apimachinery/pkg/util/wait/loop.go:53\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\t/remote-source/app/vendor/k8s.io/apimachinery/pkg/util/wait/loop.go:54\nk8s.io/apimachinery/pkg/util/wait.PollUntilContextCancel\n\t/remote-source/app/vendor/k8s.io/apimachinery/pkg/util/wait/poll.go:33\nsigs.k8s.io/controller-runtime/pkg/internal/source.(*Kind[...]).Start.func1\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/source/kind.go:64"}

7. Add "list" and "get" verbs
- apiGroups:
  - ""
  resources:
  - configmaps
  - endpoints
  - events
  - nodes
  - persistentvolumeclaims
  - pods
  - secrets
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list

8.Delete ocs-operator pod and check ocs-operator pod logs:
$ oc delete pod ocs-operator

$ oc logs ocs-operator
E1010 10:02:37.316837       1 reflector.go:158] "Unhandled Error" err="sigs.k8s.io/controller-runtime/pkg/cache/internal/informers.go:106: Failed to watch *v1.Secret: unknown (get secrets)" logger="UnhandledError"

{"level":"error","ts":"2024-10-10T10:03:06Z","logger":"controllers.OCSInitialization","msg":"Failed to create/update ux-backend secret","Request.Namespace":"openshift-storage","Request.Name":"ocsinit","error":"secrets \"ux-backend-proxy\" is forbidden: User \"system:serviceaccount:openshift-storage:ocs-operator\" cannot update resource \"secrets\" in API group \"\" in the namespace \"openshift-storage\"","stacktrace":"github.com/red-hat-storage/ocs-operator/v4/controllers/ocsinitialization.(*OCSInitializationReconciler).reconcileUXBackendSecret\n\t/remote-source/app/controllers/ocsinitialization/ocsinitialization_controller.go:629\ngithub.jparrowsec.cn/red-hat-storage/ocs-operator/v4/controllers/ocsinitialization.(*OCSInitializationReconciler).Reconcile\n\t/remote-source/app/controllers/ocsinitialization/ocsinitialization_controller.go:202\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/remote-source/app/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224"}

9. Add "update" and "watch" verb:
- apiGroups:
  - ""
  resources:
  - configmaps
  - endpoints
  - events
  - nodes
  - persistentvolumeclaims
  - pods
  - secrets
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list
  - watch
  - update

10.Delete ocs-operator pod and check ocs-operator pod logs:
$ oc delete pod ocs-operator

$ oc logs ocs-operator
No errors
11. Change code:
// // +kubebuilder:rbac:groups=core,resources=pods;services;serviceaccounts;endpoints;persistentvolumes;persistentvolumeclaims;events;configmaps;secrets;nodes,verbs=get;list;watch;create;update;delete

12.make gen-latest-csv:
export REGISTRY_NAMESPACE=ocs-dev
export IMAGE_TAG=latest
make gen-latest-csv



@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 10, 2024
Copy link
Contributor

openshift-ci bot commented Oct 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iamniting, OdedViner

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 10, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 07c57b1 into red-hat-storage:main Oct 10, 2024
11 checks passed
@@ -114,7 +114,7 @@ var validTopologyLabelKeys = []string{
// +kubebuilder:rbac:groups=ceph.rook.io,resources=cephclusters;cephblockpools;cephfilesystems;cephnfses;cephobjectstores;cephobjectstoreusers;cephrbdmirrors;cephblockpoolradosnamespaces,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=noobaa.io,resources=noobaas,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=watch;create;delete;get;list
// +kubebuilder:rbac:groups=core,resources=pods;services;serviceaccounts;endpoints;persistentvolumes;persistentvolumeclaims;events;configmaps;secrets;nodes,verbs=*
// +kubebuilder:rbac:groups=core,resources=pods;services;serviceaccounts;endpoints;persistentvolumes;persistentvolumeclaims;events;configmaps;secrets;nodes,verbs=get;list;watch;create;update;delete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add the verb patch here too, As when the failure domain is rack ocs-op does patch the nodes to label them with rack labels. Due to the lack of the patch verb ocs-operator install is failing where failuredomain is rack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants