]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
node-proxy: improve HTTP error logging in client
authorGuillaume Abrioux <gabrioux@ibm.com>
Mon, 16 Feb 2026 12:49:46 +0000 (13:49 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Wed, 18 Feb 2026 08:52:38 +0000 (09:52 +0100)
This commit makes it log the http error with the code and the reason
in sessionservice_discover() and log the error code along with the
body in query() for 5xx responses.

Fixes: https://tracker.ceph.com/issues/74749
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
src/ceph-node-proxy/ceph_node_proxy/redfish_client.py

index 652d2dd832b09676cb045c6c41079655db802bfc..d6560f5b4c25af802adbdb6f350a228f83d159c5 100644 (file)
@@ -30,7 +30,10 @@ class RedFishClient(BaseClient):
             json_data: Dict[str, Any] = json.loads(_data)
             self.session_service = json_data["Links"]["Sessions"]["@odata.id"]
         except (URLError, KeyError) as e:
-            msg = f"{_error_msg}: {e}"
+            if isinstance(e, HTTPError):
+                msg = f"{_error_msg}: {e.code} {e.reason}"
+            else:
+                msg = f"{_error_msg}: {e}"
             self.log.error(msg)
             raise RuntimeError
 
@@ -153,5 +156,11 @@ class RedFishClient(BaseClient):
                 self.location = ""
                 self.login()
                 return do_req(req_headers())
+            if isinstance(e, HTTPError) and e.code >= 500:
+                msg = f"HTTP query error: {e.code} {e.reason}"
+                body = e.read().decode("utf-8", errors="replace").strip()
+                if body:
+                    msg += f" — {body[:4096]}{'...' if len(body) > 4096 else ''}"
+                self.log.warning(msg)
             self.log.debug(f"endpoint={endpoint} err={e}")
             raise