Skip to content

v2.6.1 — YAML apply 502 fix

Choose a tag to compare

@vurulkan vurulkan released this 02 Oct 14:47
· 41 commits to main since this release

v2.6.1 — YAML apply returned 502 (fix)

Two bugs combined to turn every apply attempt into a Cloudflare 502 for the
deployed instance. This patch fixes both.

Fixes

  • Served YAML was missing apiVersion and kind. Typed client-go objects
    come back with an empty TypeMeta; sigs.k8s.io/yaml.Marshal honors the
    json omitempty tag and drops both fields. When the operator posted that
    same YAML to apply, the dynamic client built an unstructured object with no
    GVK and the API server rejected the body with "object has no kind". Each
    YAML GET handler (Pod, Deployment, DaemonSet, StatefulSet, HPA, Service,
    ConfigMap, Ingress, CronJob, Job) now sets TypeMeta explicitly before
    marshaling.
  • Apply handler returned 502 Bad Gateway for every error. 502 at the
    origin triggers Cloudflare's branded error page, which hid the real
    message. The handler now maps the underlying k8s API error to its proper
    HTTP status:
    • NotFound → 404
    • Conflict (stale resourceVersion) → 409
    • Forbidden → 403
    • Invalid / BadRequest / RequestEntityTooLarge → 400
    • Timeout / ServerTimeout → 504
    • ServiceUnavailable → 503
    • InternalError → 500
    • Client-side validation we raised (name/namespace mismatch, missing
      resourceVersion, YAML parse) → 422 Unprocessable Entity

Only a true upstream outage reaches 5xx now, which Cloudflare passes
through unchanged.

Belt-and-braces

The Apply path also injects apiVersion/kind on the submitted object when
GVK is empty, so a YAML that was fetched by a browser tab on 2.6.0 (before
TypeMeta was populated) keeps working after this upgrade.

Upgrade

docker pull ghcr.io/vurulkan/kubernetes-openconsole:2.6.1
docker rm -f openconsole && \
  docker run -d --name openconsole -p 8080:8080 -e DATA_PATH=/tmp/app.db \
    ghcr.io/vurulkan/kubernetes-openconsole:2.6.1

No schema change. Any browser tab that was holding YAML from 2.6.0 should
Reload before editing (header button) to pick up the full YAML including
apiVersion/kind.