Repository navigation
fix(k8s): prevent deploy-stack and port-forward from unconditionally overwriting config with localhost (#637) - #638
Merged
dan-petty merged 1 commit intoSep 27, 2026
Conversation
…overwriting config with localhost (#637) Problem: `devops k8s deploy-stack` unconditionally launched background port-forward daemons and invoked `configure-urls`, overwriting custom endpoints in `config.yaml` with loopback (`http://localhost:...`) addresses. Furthermore, `_resolve_accessible_url` probed preferred localhost ports before checking the actual detected cluster URL, silently replacing reachable cluster endpoints whenever localhost ports were occupied. Additionally, `devops k8s port-forward` automatically mutated configuration files. Solution: - Make port-forwarding and configuration updates opt-in for `deploy-stack` via `--port-forward / --no-port-forward` and `--configure-urls / --no-configure-urls` (both defaulting to `False`). - Make configuration updates opt-in for `port-forward` via `--update-config / --no-update-config` (defaulting to `False`). - Invert resolution priority in `_resolve_accessible_url`: test `detected_url` reachability first; only fallback to localhost if `detected_url` is unreachable or unconfigured. - Protect existing custom remote endpoints (including `settings.ai.ollama_urls`) from being overwritten by loopback addresses in `_should_update_url` and `_update_ollama_urls`. - Decompose `deploy_stack` and `port_forward` to satisfy cyclomatic complexity and nesting limits. - Update CLI reference documentation and add comprehensive unit tests. Verification: - `uv run pytest tests/test_k8s_networking.py tests/test_k8s.py`: 70 tests passed. - `uv run devops ci`: All 10 quality gates passed (coverage >= 90%, zero errors). Closes #637
dan-petty
marked this pull request as ready for review
September 27, 2026 08:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #637 by preventing
devops k8s deploy-stackanddevops k8s port-forwardfrom unconditionally mutating configuration files and starting background port-forwarding daemons by default.Key Changes
--port-forward / --no-port-forward(default:False) and--configure-urls / --no-configure-urls(default:False) todevops k8s deploy-stack.deploy_stackinto discrete helper functions (_deploy_helm_repos,_apply_manifest_files,_install_single_release,_post_deploy_networking,_post_deploy_credentials) reducing cyclomatic complexity to--update-config / --no-update-config(default:False) todevops k8s port-forward.port_forwardinto_build_port_forward_details,_collect_port_forward_services, and_launch_port_forwards._resolve_accessible_url: testdetected_urlreachability first; only fallback to localhost ifdetected_urlis unreachable or unconfigured._should_update_urland_update_ollama_urlsto ensure existing custom endpoints (such as remote Ollama inference hosts) are never overwritten by loopback addresses.settings.telemetry.README.md,docs/CLI_REFERENCE.md,docs/commands/k8s.md).tests/test_k8s_networking.pycovering flag defaults, priority resolution, Ollama URL preservation, and service spec mapping.tests/test_k8s.pyfor reachable endpoint preference.Verification
uv run devops ci): Passed with 100% compliance across all 10 quality gates.tests/test_k8s_networking.pyandtests/test_k8s.pypassed (70 tests total).Closes #637