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

[Bug]: Exception in Operator when name of added KadaluStorage starts with name of existing KadaluStorage #1058

Open
madoe opened this issue Apr 9, 2024 · 2 comments
Labels
on-user pending on user

Comments

@madoe
Copy link
Contributor

madoe commented Apr 9, 2024

Describe the bug
When the name of a new KadaluStorage starts with the name of an existing KadaluStorage, the following exception is thrown in operator and operator is restarted.

[2024-04-09 13:32:22,578] INFO [main - 526:handle_external_storage_addition] - Updated configmap     name=kadalu-info volname=gfstest
[2024-04-09 13:32:23,247] INFO [main - 531:handle_external_storage_addition] - Deployed External StorageClass       volname=gfstest manifest=/kadalu/templates/external-storageclass.yaml
[2024-04-09 13:32:34,973] INFO [main - 526:handle_external_storage_addition] - Updated configmap    name=kadalu-info volname=gfstest-2
Traceback (most recent call last):
  File "/kadalu/main.py", line 1080, in <module>
    main()
  File "/kadalu/main.py", line 1069, in main
    crd_watch(core_v1_client, k8s_client)
  File "/kadalu/main.py", line 911, in crd_watch
    watch_stream(core_v1_client, k8s_client)
  File "/kadalu/main.py", line 898, in watch_stream
    handle_added(core_v1_client, obj)
  File "/kadalu/main.py", line 582, in handle_added
    handle_external_storage_addition(core_v1_client, obj)
  File "/kadalu/main.py", line 530, in handle_external_storage_addition
    lib_execute(KUBECTL_CMD, APPLY_CMD, "-f", filename)
  File "/kadalu/kadalulib.py", line 184, in execute
    raise CommandException(proc.returncode, out.strip(), err.strip())
kadalulib.CommandException: [1]  Error from server (Forbidden): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"allowVolumeExpansion\":false,\"apiVersion\":\"storage.k8s.io/v1\",\"kind\":\"StorageClass\",\"metadata\":{\"annotations\":{},\"name\":\"kadalu.gfstest-2\"},\"parameters\":{\"gluster_hosts\":\"gfs-1.example.de,gfs-2.example.de,gfs-3.example.de\",\"gluster_options\":\"log-level=INFO\",\"gluster_volname\":\"gfstest-2\",\"hostvol_type\":\"External\",\"single_pv_per_pool\":\"True\"},\"provisioner\":\"kadalu\"}\n"}},"parameters":{"gluster_volname":"gfstest-2"}}
to:
Resource: "storage.k8s.io/v1, Resource=storageclasses", GroupVersionKind: "storage.k8s.io/v1, Kind=StorageClass"
Name: "kadalu.gfstest-2", Namespace: ""
for: "/kadalu/templates/external-storageclass.yaml": error when patching "/kadalu/templates/external-storageclass.yaml": storageclasses.storage.k8s.io "kadalu.gfstest-2" is forbidden: User "system:serviceaccount:kadalu:kadalu-operator" cannot patch resource "storageclasses" in API group "storage.k8s.io" at the cluster scope
[2024-04-09 13:32:36,515] INFO [kadalulib - 432:monitor_proc] - Restarted Process   name=operator

However, the configmap has correctly been updated (includes entries for both gfstest and gfstest-2).

As long as the KadaluStorage gfstest-2 exists, operator will be stuck in a endless restart loop.

To Reproduce
Steps to reproduce the behavior:

  1. Create a KadaluStorage with any name (e.g. test)
  2. Create a second KadaluStorage with a name starting with the name of previous KadaluStorage (e.g. test-1)

Environment:

  • Kadalu Version: [1.2.0]
  • K8S_DIST: [kubernetes]
  • external gluster with single_pv_per_pool=true
@madoe
Copy link
Contributor Author

madoe commented Apr 9, 2024

Oh, it seems this was my mistake. There was a leftover StorageClass named gfstest-2 from previous tests. After deleting this the problem disappeared. But maybe it could beneficial, to add "patch" to rbac?

@leelavg
Copy link
Collaborator

leelavg commented Apr 12, 2024

there is a bug as well, since kds is namespaced and simply creating a storageclass which is clusterscope w/ same name as kds the operator will hit an error. I'm not sure whether that needs any urgent fix.

The other one, patching storageclass, it shouldn't result in a patch in the first place as params of storageclass are immutable and even if we provide the patch verb the resulting operation would fail if the params are changed and if params aren't changed I think that'll be a no-op.

@leelavg leelavg added the on-user pending on user label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-user pending on user
Projects
None yet
Development

No branches or pull requests

2 participants