Skip to content

fix(k8s): cloudflare sync and url configuration overwrite existing settings #666

Closed

Description

@dan-petty

Summary

Found in the release/v0.2.23 review (line numbers at 7fdaa9d).

  1. FQDN URL configuration can send provider API keys to an ingress host.
    • k8s configure-urls in FQDN mode always overwrites ai.gateway_url, forces ai.gateway_enabled=True, and rewrites ai.tasks.chat/analysis.api_base_url, whichever provider those tasks use (src/devops_cli/commands/k8s/networking.py:654-661). The same happens via deploy-stack --configure-urls and port-forward --update-config.
    • The gateway host is found by matching "llm-gateway" as a substring of any Ingress backend in any namespace (:555-603). The namespace-aware CONST_K8S_INGRESS_SERVICE_PATTERNS goes unused.
    • With ai.provider: claude/openai/copilot, chat and analysis requests go to https://ai.<domain>/v1 carrying the provider's API key.
    • tests/test_k8s_networking.py:238-266 asserts the forced gateway_enabled.
  2. cloudflare tunnel sync deletes existing tunnel settings. It PUTs a full replacement configuration (generated rules plus a 404) without reading the current one (src/devops_cli/cloudflare/client.py:353-381, :445-465; src/devops_cli/commands/cloudflare.py:456-467, :532-534). Other hostname routes, path rules, originRequest settings and warp-routing are silently removed, and --dry-run lists only the new rules.
  3. Tunnel lookup can pick a deleted tunnel (unconfirmed against the live API). resolve_tunnel_id filters by name only and takes result[0], without is_deleted=false (client.py:320-338). A deleted-and-recreated tunnel can resolve to the dead one.
  4. cloudflare dns delete <name> deletes every record at that name. It removes records of all types, so dns delete @ also removes apex MX, TXT and CAA records. There is no type filter, no check of the "Managed by devops-cli" comment, and no confirmation (commands/cloudflare.py:294-333).
  5. DNS listing reads only one page. It fetches per_page=100 and never follows result_info (client.py:237-255). Zones with more records truncate dns list, report real records as "not found" on delete, and make dns sync POST duplicates and abort part-way.
  6. An explicit k8s.addressing: nodeport is overridden. It becomes FQDN whenever k8s.domain is set (networking.py:726-737). tests/test_k8s_networking.py:200-219 asserts the override.
  7. The Valkey guard checks the wrong field. The new guard against localhost overwriting a remote endpoint checks valkey.url, but then rewrites valkey.host and valkey.port (networking.py:433-441).

Remediation Plan

  1. In FQDN mode, update only endpoints that are unset or local (_should_update_url). Never force gateway_enabled, and never rewrite task api_base_url for non-gateway providers. Discover the gateway through CONST_K8S_INGRESS_SERVICE_PATTERNS, with namespace matching.
  2. Read the current tunnel configuration, merge the generated rules into it, and preserve all other settings. Show additions and removals in --dry-run.
  3. Filter out deleted tunnels.
  4. Add a --type filter to dns delete, and delete only records marked as managed unless forced.
  5. Paginate DNS listing.
  6. Honour an explicit addressing mode.
  7. Guard on host and port.
  8. Add tests for each item, and fix the two tests that assert the current behaviour.

Activity

  1. added this to the v0.2.23 milestone on Sep 28, 2026
  2. added
    type/bug
    scope/k8s
    priority/p1-high
    on Sep 28, 2026
  3. dan-petty commented on Sep 28, 2026

    @dan-petty
    OwnerAuthor

    Closed by #676, merged into release/v0.2.23.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/k8stype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions