Skip to content

Ignore Kubernetes service-link CLOCKD_PORT env var - #2

Merged
nathan-v merged 1 commit into
mainfrom
fix/k8s-service-links
Jul 14, 2026
Merged

nathan-v merged 1 commit into
mainfrom
fix/k8s-service-links

Conversation

@nathan-v

@nathan-v nathan-v commented Jul 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the production CrashLoopBackOff that took Clockd offline for ~24h.

Kubernetes injects legacy Docker-link env vars for every Service in a namespace: a Service named clockd produces CLOCKD_PORT=tcp://<cluster-ip>:8000 in every pod. Since #1 made env vars override YAML config (for Secret-based credential injection), that injected value beat the ConfigMap's port: 8000 and failed integer validation, crashing the app at startup on every restart.

Changes

  • src/clockd/config.py: wrap the env settings source to drop tcp://… values for the port field. Real integer CLOCKD_PORT values still override YAML as intended.
  • deploy/k8s-example.yaml: set enableServiceLinks: false (with an explanatory comment) so the example manifest doesn't reproduce the collision. This is also the mitigation applied to the live deployment.
  • tests/test_config.py: three regression tests — service-link value ignored with YAML port, without YAML port, and a legitimate env port still winning.

Testing

  • 151 passed locally (pytest -q), ruff check + format clean.

A Service named "clockd" makes Kubernetes inject legacy Docker-link vars
(CLOCKD_PORT=tcp://<cluster-ip>:8000) into every pod in the namespace.
Since env vars now override YAML config, this collided with the CLOCKD_
prefix and crash-looped the pod at startup with a port validation error.

- Filter tcp:// values for the port field out of the env settings source
- Set enableServiceLinks: false in the example k8s manifest
- Add regression tests; real integer CLOCKD_PORT values still override
@nathan-v
nathan-v force-pushed the fix/k8s-service-links branch from 195fa71 to bc5f1f7 Compare July 14, 2026 00:14
@nathan-v
nathan-v enabled auto-merge (squash) July 14, 2026 00:14
@nathan-v
nathan-v merged commit 3a2dd49 into main Jul 14, 2026
3 checks passed
@nathan-v
nathan-v deleted the fix/k8s-service-links branch July 14, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant