kubernetes api: avoid overriding content-type header in kubernetes-asyncio, pass in via arg instead (main) (#1605)
- instead of overriding the content-type header globally, pass 'application/merge-patch+json' to self.custom_api.patch_namespaced_custom_object() directly - bump kubernetes-asyncio to 29.0.0 - fixes potential issues with global override of the header in kubernetes-asyncio - copy of #1602 for main
This commit is contained in:
parent
6e9c14aea6
commit
5a4902b6d4
@ -216,13 +216,7 @@ class K8sAPI:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def _patch_job(self, crawl_id, body, pluraltype="crawljobs") -> dict:
|
async def _patch_job(self, crawl_id, body, pluraltype="crawljobs") -> dict:
|
||||||
content_type = self.api_client.default_headers.get("Content-Type")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.api_client.set_default_header(
|
|
||||||
"Content-Type", "application/merge-patch+json"
|
|
||||||
)
|
|
||||||
|
|
||||||
await self.custom_api.patch_namespaced_custom_object(
|
await self.custom_api.patch_namespaced_custom_object(
|
||||||
group="btrix.cloud",
|
group="btrix.cloud",
|
||||||
version="v1",
|
version="v1",
|
||||||
@ -230,6 +224,7 @@ class K8sAPI:
|
|||||||
plural=pluraltype,
|
plural=pluraltype,
|
||||||
name=f"{pluraltype[:-1]}-{crawl_id}",
|
name=f"{pluraltype[:-1]}-{crawl_id}",
|
||||||
body={"spec": body},
|
body={"spec": body},
|
||||||
|
_content_type="application/merge-patch+json",
|
||||||
)
|
)
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
# pylint: disable=broad-except
|
# pylint: disable=broad-except
|
||||||
@ -237,12 +232,6 @@ class K8sAPI:
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return {"error": str(exc)}
|
return {"error": str(exc)}
|
||||||
|
|
||||||
finally:
|
|
||||||
if content_type:
|
|
||||||
self.api_client.set_default_header("Content-Type", content_type)
|
|
||||||
else:
|
|
||||||
del self.api_client.default_headers["Content-Type"]
|
|
||||||
|
|
||||||
async def print_pod_logs(self, pod_names, lines=100):
|
async def print_pod_logs(self, pod_names, lines=100):
|
||||||
"""print pod logs"""
|
"""print pod logs"""
|
||||||
for pod in pod_names:
|
for pod in pod_names:
|
||||||
|
@ -9,7 +9,7 @@ email-validator
|
|||||||
#fastapi-users[mongodb]==9.2.2
|
#fastapi-users[mongodb]==9.2.2
|
||||||
loguru
|
loguru
|
||||||
aiofiles
|
aiofiles
|
||||||
kubernetes-asyncio==25.11.0
|
kubernetes-asyncio==29.0.0
|
||||||
kubernetes
|
kubernetes
|
||||||
aiobotocore
|
aiobotocore
|
||||||
redis>=5.0.0
|
redis>=5.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user