]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix edit bucket failing in other selected gateways 58244/head
authorNizamudeen A <nia@redhat.com>
Fri, 7 Jun 2024 13:49:42 +0000 (19:19 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 25 Jun 2024 06:18:39 +0000 (11:48 +0530)
even if I select gateway 8002, the bucket policy req seems to go through 8000 and doesn't find the bucket
```
2024-06-07T13:40:33.161+0000 7f563be00700  0 [dashboard DEBUG rest_client] RGW REST API GET req: /hello?policy data: None
2024-06-07T13:40:33.164+0000 7f563be00700  0 [dashboard DEBUG urllib3.connectionpool] http://172.20.0.5:8000 "GET /hello?policy HTTP/1.1" 404 174
2024-06-07T13:40:33.164+0000 7f563be00700  0 [dashboard ERROR rest_client] RGW REST API failed GET req status: 404
2024-06-07T13:40:33.164+0000 7f563be00700  0 [dashboard ERROR exception] Internal Server Error
Traceback (most recent call last):
  File "/ceph/src/pybind/mgr/dashboard/services/exception.py", line 47, in dashboard_exception_handler
    return handler(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/ceph/src/pybind/mgr/dashboard/controllers/_base_controller.py", line 263, in inner
    ret = func(*args, **kwargs)
  File "/ceph/src/pybind/mgr/dashboard/controllers/_rest_controller.py", line 193, in wrapper
    return func(*vpath, **params)
  File "/ceph/src/pybind/mgr/dashboard/controllers/rgw.py", line 463, in get
    result['bucket_policy'] = self._get_policy(bucket_name)
  File "/ceph/src/pybind/mgr/dashboard/controllers/rgw.py", line 381, in _get_policy
    return rgw_client.get_bucket_policy(bucket)
  File "/ceph/src/pybind/mgr/dashboard/rest_client.py", line 543, in func_wrapper
    **kwargs)
  File "/ceph/src/pybind/mgr/dashboard/services/rgw_client.py", line 957, in get_bucket_policy
    raise e
  File "/ceph/src/pybind/mgr/dashboard/services/rgw_client.py", line 949, in get_bucket_policy
    request = request()
  File "/ceph/src/pybind/mgr/dashboard/rest_client.py", line 325, in __call__
    data, raw_content, headers)
  File "/ceph/src/pybind/mgr/dashboard/rest_client.py", line 428, in do_request
    resp.content)
dashboard.rest_client.RequestException: RGW REST API failed request with status code 404
(b'{"Code":"NoSuchBucket","Message":"","BucketName":"hello","RequestId":"tx0000'
 b'0d73bbbad485175ea-0066630dd1-18785-zone1-zg1-realm1","HostId":"18785-zone1-z'
 b'g1-realm1-zg1-realm1"}')
```

But for the same bucket the encryption and other req goes through the correct gateway

```
2024-06-07T13:40:32.704+0000 7f563be00700  0 [dashboard DEBUG urllib3.connectionpool] http://172.20.0.5:8002 "GET /hello?versioning HTTP/1.1" 200 2
2024-06-07T13:40:32.745+0000 7f563be00700  0 [dashboard DEBUG rest_client] RGW REST API GET res status: 200 content: {}
2024-06-07T13:40:32.745+0000 7f563be00700  0 [dashboard INFO rgw_client] Found RGW daemon with configuration: host=172.20.0.5, port=8000, ssl=False
2024-06-07T13:40:32.746+0000 7f563be00700  0 [dashboard INFO rgw_client] Found RGW daemon with configuration: host=172.20.0.5, port=8002, ssl=False
2024-06-07T13:40:32.746+0000 7f563be00700  0 [dashboard DEBUG rest_client] RGW REST API GET req: /hello?encryption data: None
2024-06-07T13:40:32.747+0000 7f563be00700  0 [dashboard DEBUG urllib3.connectionpool] http://172.20.0.5:8002 "GET /hello?encr
```

Fixes: https://tracker.ceph.com/issues/66395
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 4ffd1d4f1a906f3162b3b0930accff66ba2fbf4d)

src/pybind/mgr/dashboard/controllers/rgw.py

index 50b4547a4fead480722592e6c611593873f7ea98..fc3ed0cbbd13825e0eb7fe3137e6fa0197c3defd 100644 (file)
@@ -292,8 +292,8 @@ class RgwBucket(RgwRESTController):
                                              retention_period_days,
                                              retention_period_years)
 
-    def _get_policy(self, bucket: str):
-        rgw_client = RgwClient.admin_instance()
+    def _get_policy(self, bucket: str, daemon_name, owner):
+        rgw_client = RgwClient.instance(owner, daemon_name)
         return rgw_client.get_bucket_policy(bucket)
 
     def _set_policy(self, bucket_name: str, policy: str, daemon_name, owner):
@@ -364,7 +364,7 @@ class RgwBucket(RgwRESTController):
         result['encryption'] = encryption['Status']
         result['versioning'] = versioning['Status']
         result['mfa_delete'] = versioning['MfaDelete']
-        result['bucket_policy'] = self._get_policy(bucket_name)
+        result['bucket_policy'] = self._get_policy(bucket_name, daemon_name, result['owner'])
         result['acl'] = self._get_acl(bucket_name, daemon_name, result['owner'])
 
         # Append the locking configuration.