qdrant-operator 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/PKG-INFO +1 -1
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/pyproject.toml +1 -1
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/pyproject.toml.orig +1 -1
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/helm_adapter.py +24 -3
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/kubernetes_adapter.py +2 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/qdrant_adapter.py +10 -7
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/s3_adapter.py +14 -1
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/LICENSE +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/README.md +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/__init__.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/container.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/domain.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/handlers.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/jwt_adapter.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/main.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/ports.py +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/py.typed +0 -0
- {qdrant_operator-0.3.0 → qdrant_operator-0.3.2}/src/qdrant_operator/usecases.py +0 -0
|
@@ -30,6 +30,7 @@ class HelmAdapter:
|
|
|
30
30
|
chart_version: str,
|
|
31
31
|
values: Mapping[str, Any],
|
|
32
32
|
) -> None:
|
|
33
|
+
await self.recover_pending(release_name, namespace)
|
|
33
34
|
await self.run(
|
|
34
35
|
"upgrade",
|
|
35
36
|
"--install",
|
|
@@ -53,11 +54,31 @@ class HelmAdapter:
|
|
|
53
54
|
logger.info("helm release uninstalled", release=release_name, namespace=namespace)
|
|
54
55
|
|
|
55
56
|
async def release_exists(self, release_name: str, namespace: str) -> bool:
|
|
57
|
+
return bool(await self.release_status(release_name, namespace))
|
|
58
|
+
|
|
59
|
+
async def release_status(self, release_name: str, namespace: str) -> str:
|
|
60
|
+
"""Helm's release status (deployed, failed, pending-upgrade, ...), empty when absent."""
|
|
56
61
|
try:
|
|
57
|
-
await self.run(
|
|
62
|
+
output = await self.run(
|
|
63
|
+
"status", release_name, "--namespace", namespace, "--output", "json"
|
|
64
|
+
)
|
|
58
65
|
except HelmError:
|
|
59
|
-
return
|
|
60
|
-
return
|
|
66
|
+
return ""
|
|
67
|
+
return str(json.loads(output).get("info", {}).get("status", ""))
|
|
68
|
+
|
|
69
|
+
async def recover_pending(self, release_name: str, namespace: str) -> None:
|
|
70
|
+
"""Roll back a release another helm process left mid-operation, or every upgrade fails.
|
|
71
|
+
|
|
72
|
+
Helm refuses to touch a release in a pending-* state ("another operation is in
|
|
73
|
+
progress"); that state is what a killed operator leaves behind.
|
|
74
|
+
"""
|
|
75
|
+
status = await self.release_status(release_name, namespace)
|
|
76
|
+
if not status.startswith("pending-"):
|
|
77
|
+
return
|
|
78
|
+
logger.warning(
|
|
79
|
+
"helm release left pending, rolling back", release=release_name, status=status
|
|
80
|
+
)
|
|
81
|
+
await self.run("rollback", release_name, "--namespace", namespace)
|
|
61
82
|
|
|
62
83
|
async def run(self, *args: str, stdin: bytes | None = None) -> str:
|
|
63
84
|
command = ["helm", *args, *self.kubeconfig_args()]
|
|
@@ -20,6 +20,7 @@ from qdrant_operator.domain import SecretRef
|
|
|
20
20
|
from qdrant_operator.domain import StatefulSetStatus
|
|
21
21
|
|
|
22
22
|
config: Any = kubernetes_config
|
|
23
|
+
MERGE_PATCH = "application/merge-patch+json"
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
async def load_kubernetes_config() -> None:
|
|
@@ -161,6 +162,7 @@ class KubernetesAdapter:
|
|
|
161
162
|
plural=ref.kind.plural,
|
|
162
163
|
name=ref.name,
|
|
163
164
|
body={"status": status},
|
|
165
|
+
_content_type=MERGE_PATCH,
|
|
164
166
|
)
|
|
165
167
|
|
|
166
168
|
async def get_statefulset_status(self, name: str, namespace: str) -> StatefulSetStatus | None:
|
|
@@ -25,13 +25,16 @@ class QdrantAdapter:
|
|
|
25
25
|
|
|
26
26
|
@asynccontextmanager
|
|
27
27
|
async def client(self, node: QdrantNode, timeout: float) -> AsyncGenerator[httpx.AsyncClient]:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
try:
|
|
29
|
+
async with httpx.AsyncClient(
|
|
30
|
+
base_url=node.url,
|
|
31
|
+
headers={"api-key": node.api_key} if node.api_key else {},
|
|
32
|
+
timeout=timeout,
|
|
33
|
+
verify=self.ssl_context(node),
|
|
34
|
+
) as client:
|
|
35
|
+
yield client
|
|
36
|
+
except httpx.TransportError as error:
|
|
37
|
+
raise ConnectionError(f"Qdrant at {node.url} is unreachable: {error}") from error
|
|
35
38
|
|
|
36
39
|
@staticmethod
|
|
37
40
|
def ssl_context(node: QdrantNode) -> ssl.SSLContext | bool:
|
|
@@ -7,6 +7,7 @@ from dataclasses import dataclass
|
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
9
|
import aioboto3
|
|
10
|
+
from boto3.s3.transfer import TransferConfig
|
|
10
11
|
from botocore.config import Config
|
|
11
12
|
from loguru import logger
|
|
12
13
|
|
|
@@ -14,6 +15,8 @@ from qdrant_operator.domain import S3Credentials
|
|
|
14
15
|
from qdrant_operator.domain import S3StorageSpec
|
|
15
16
|
|
|
16
17
|
DELETE_BATCH_SIZE = 1000
|
|
18
|
+
UPLOAD_PART_BYTES = 8 * 1024 * 1024
|
|
19
|
+
UPLOAD_CONCURRENCY = 2
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
@dataclass
|
|
@@ -66,7 +69,17 @@ class S3Adapter:
|
|
|
66
69
|
) -> int:
|
|
67
70
|
reader = ChunkReader(chunks, bytearray())
|
|
68
71
|
async with self.client(storage, credentials) as s3:
|
|
69
|
-
await s3.upload_fileobj(
|
|
72
|
+
await s3.upload_fileobj(
|
|
73
|
+
reader,
|
|
74
|
+
storage.bucket,
|
|
75
|
+
key,
|
|
76
|
+
Config=TransferConfig(
|
|
77
|
+
multipart_threshold=UPLOAD_PART_BYTES,
|
|
78
|
+
multipart_chunksize=UPLOAD_PART_BYTES,
|
|
79
|
+
max_concurrency=UPLOAD_CONCURRENCY,
|
|
80
|
+
max_io_queue=UPLOAD_CONCURRENCY,
|
|
81
|
+
),
|
|
82
|
+
)
|
|
70
83
|
logger.info("s3 upload complete", uri=storage.uri(key), bytes=reader.total)
|
|
71
84
|
return reader.total
|
|
72
85
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|