fix: black formatting, line length, pyright type narrowing
- Apply black reformatting to deployer.py, cluster_info.py, deploy_k8s.py - Shorten docstrings exceeding 88 char line limit - Add assert for pyright Optional type narrowing on tls list Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>pull/740/head
parent
63325f68a7
commit
3da23683f6
|
|
@ -70,13 +70,11 @@ class Deployer(ABC):
|
|||
pass
|
||||
|
||||
def prepare(self, skip_cluster_management):
|
||||
"""Create cluster infrastructure (namespace, PVs, services) without starting pods.
|
||||
"""Create cluster infra (namespace, PVs, services) without pods.
|
||||
|
||||
Only supported for k8s deployers. Compose deployers raise an error.
|
||||
"""
|
||||
raise DeployerException(
|
||||
"prepare is only supported for k8s deployments"
|
||||
)
|
||||
raise DeployerException("prepare is only supported for k8s deployments")
|
||||
|
||||
|
||||
class DeployerException(Exception):
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ class ClusterInfo:
|
|||
certificate = (certificates or {}).get(host_name)
|
||||
|
||||
if use_tls:
|
||||
assert tls is not None
|
||||
tls.append(
|
||||
client.V1IngressTLS(
|
||||
hosts=(
|
||||
|
|
@ -835,9 +836,12 @@ class ClusterInfo:
|
|||
containers, init_containers, services, volumes = self._build_containers(
|
||||
single_pod_map, image_pull_policy
|
||||
)
|
||||
annotations, labels, affinity, tolerations = (
|
||||
self._build_common_pod_metadata(services)
|
||||
)
|
||||
(
|
||||
annotations,
|
||||
labels,
|
||||
affinity,
|
||||
tolerations,
|
||||
) = self._build_common_pod_metadata(services)
|
||||
|
||||
# Add pod-name label so Services can target specific pods
|
||||
if multi_pod:
|
||||
|
|
@ -860,9 +864,12 @@ class ClusterInfo:
|
|||
selector_labels["app.kubernetes.io/component"] = pod_name
|
||||
|
||||
# Add CA certificate volume and env vars if configured
|
||||
_ca_secret, ca_volume, ca_mounts, ca_envs = (
|
||||
self.get_ca_certificate_resources()
|
||||
)
|
||||
(
|
||||
_ca_secret,
|
||||
ca_volume,
|
||||
ca_mounts,
|
||||
ca_envs,
|
||||
) = self.get_ca_certificate_resources()
|
||||
if ca_volume:
|
||||
volumes.append(ca_volume)
|
||||
for container in containers:
|
||||
|
|
@ -1112,9 +1119,7 @@ class ClusterInfo:
|
|||
spec=client.V1ServiceSpec(
|
||||
type="ExternalName",
|
||||
external_name=config["host"],
|
||||
ports=[
|
||||
client.V1ServicePort(port=port, name=f"port-{port}")
|
||||
],
|
||||
ports=[client.V1ServicePort(port=port, name=f"port-{port}")],
|
||||
),
|
||||
)
|
||||
resources.append(svc)
|
||||
|
|
@ -1130,9 +1135,7 @@ class ClusterInfo:
|
|||
),
|
||||
spec=client.V1ServiceSpec(
|
||||
cluster_ip="None",
|
||||
ports=[
|
||||
client.V1ServicePort(port=port, name=f"port-{port}")
|
||||
],
|
||||
ports=[client.V1ServicePort(port=port, name=f"port-{port}")],
|
||||
),
|
||||
)
|
||||
resources.append(svc)
|
||||
|
|
|
|||
|
|
@ -439,7 +439,9 @@ class K8sDeployer(Deployer):
|
|||
|
||||
for resource in resources:
|
||||
if opts.o.dry_run:
|
||||
print(f"Dry run: would create external service: {resource.metadata.name}")
|
||||
print(
|
||||
f"Dry run: would create external service: {resource.metadata.name}"
|
||||
)
|
||||
continue
|
||||
|
||||
svc_name = resource.metadata.name
|
||||
|
|
@ -478,9 +480,7 @@ class K8sDeployer(Deployer):
|
|||
namespace=target_ns, label_selector=label_selector
|
||||
)
|
||||
pod_ips = [
|
||||
p.status.pod_ip
|
||||
for p in pods.items
|
||||
if p.status and p.status.pod_ip
|
||||
p.status.pod_ip for p in pods.items if p.status and p.status.pod_ip
|
||||
]
|
||||
|
||||
if not pod_ips:
|
||||
|
|
@ -497,13 +497,9 @@ class K8sDeployer(Deployer):
|
|||
),
|
||||
subsets=[
|
||||
client.V1EndpointSubset(
|
||||
addresses=[
|
||||
client.V1EndpointAddress(ip=ip) for ip in pod_ips
|
||||
],
|
||||
addresses=[client.V1EndpointAddress(ip=ip) for ip in pod_ips],
|
||||
ports=[
|
||||
client.CoreV1EndpointPort(
|
||||
port=port, name=f"port-{port}"
|
||||
)
|
||||
client.CoreV1EndpointPort(port=port, name=f"port-{port}")
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def _random_suffix(length: int = 2) -> str:
|
|||
|
||||
|
||||
def _timestamp_id() -> str:
|
||||
"""Generate a sortable timestamp ID (100ms resolution, 2024 epoch) with random suffix."""
|
||||
"""Generate sortable timestamp ID with random suffix."""
|
||||
now_ms = int(time.time() * 1000)
|
||||
offset = (now_ms - EPOCH_2024) // 100 # 100ms resolution
|
||||
return f"{_base36(offset)}{_random_suffix()}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue