Repository navigation
Description
Problem Description
devops roadmap eval grades fails on a workstation that has no loki.url setting:
Loki at http://localhost:3100 did not answer: [Errno 111] Connection refused. Set loki.url, or give --loki-url with the address of a Loki that this host reaches.
resolve_loki_url in src/devops_cli/k8s/logql.py uses the option, then loki.url, then DEFAULT_LOKI_URL (http://localhost:3100). Nothing listens on that address unless a person starts a port-forward. The title of #1165 states the rule: service clients use only configured URLs and never fall back to an unconfigured localhost default. DEFAULT_LOKI_URL is still such a fallback. The Grafana datasource reached the same Loki at the same time.
Reproduction Steps
- Leave
loki.urlunset, and start no port-forward to Loki. - Run
devops roadmap eval grades --window 24h.
Expected vs Actual Behavior
Expected: the command reaches the Loki of the cluster, through a port-forward that it opens itself, or it stops before a request with an error that names loki.url.
Actual: the command sends a request to http://localhost:3100 and gets Connection refused.
Environment Diagnostics
devops-cli at origin/main of 2026-11-13, a devcontainer with kubectl access to the cluster.
Logs, Traces, or Terminal Output
Found while writing the agentic workflow spec (#5443). The spec measured the grades with LogQL through the Grafana datasource because of this failure.
Source: #5443
Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches returned no open, maintained tool for configured-URL resolution: the need is a change inside the project's own resolve_loki_url, constant removal and selector settings, which no Loki client or Kubernetes library supplies.
Lacks:
- No configured-URL resolution without a localhost default
- No early error naming loki.url before a request
- No LogQL selector built from the roadmap Service settings
Proposed design
Problem statement
On a host with no loki.url setting, devops roadmap eval grades dials http://localhost:3100 from DEFAULT_LOKI_URL and fails with Connection refused. This breaks the rule of #1165 that a service client uses only a configured URL. The change removes the constant and stops the command before a request with an error that names loki.url. It keeps the kubectl fallback of execute_logql_query. The selector change of the earlier plan is dropped because #5556 already replaced it on main.
Acceptance criteria
Requirement: Explicit Loki URL
resolve_loki_url SHALL return the explicit loki_url argument when it is set.
Scenario: Explicit URL wins
- WHEN
resolve_loki_urlreceiveshttp://loki.example:3100while theloki.urlsetting ishttp://loki.team:3100. - THEN The call returns
http://loki.example:3100.
Requirement: Configured Loki setting
resolve_loki_url SHALL return the loki.url setting when the explicit argument is not set.
Scenario: Setting supplies the URL
- WHEN
resolve_loki_urlreceives no argument and theloki.urlsetting ishttp://loki.team:3100. - THEN The call returns
http://loki.team:3100.
Requirement: Missing Loki URL
resolve_loki_url MUST raise KubernetesLoggingError with a message that names loki.url when neither the argument nor the setting is set.
Scenario: No URL configured
- WHEN
resolve_loki_urlreceives no argument and theloki.urlsetting is unset. - THEN The call raises
KubernetesLoggingErrorwhose message containsloki.url.
Requirement: Explicit URL argument on the query
execute_loki_query MUST declare loki_url with no default value.
Scenario: The query signature has no default
- WHEN A test reads the signature of
execute_loki_querywithinspect.signature. - THEN The parameter
loki_urlhas the defaultinspect.Parameter.empty.
Requirement: Remove the fallback constant
The package MUST NOT define or import DEFAULT_LOKI_URL after the change.
Scenario: The constant is gone
- WHEN A test imports
devops_cli.config.defaultsanddevops_cli.k8s.logql. - THEN Neither module has an attribute
DEFAULT_LOKI_URL.
Requirement: Kubectl fallback without a Loki URL
execute_logql_query SHALL use the kubectl log stream when no loki.url is set and SHALL send no request to a localhost address.
Scenario: No URL falls back to kubectl
- WHEN
execute_logql_queryruns with{namespace="devops"}, noloki.urlsetting and a fake HTTP client that records each request. - THEN The result has source
k8s_fallback, and the fake records no request.
Requirement: Grades command stops before the request
devops roadmap eval grades MUST stop before a Loki request with an error that names loki.url when no URL is configured.
Scenario: Grades with no URL
- WHEN
loki.urlis unset anddevops roadmap eval grades --window 24hruns with no--loki-urland a fake HTTP client that records each request. - THEN The command exits with a non-zero code, its output contains
loki.url, and the fake records no request.
Existing Tool Considered
The alternatives check of 2026-11-23 in the issue body returned none with Tool: none found; the block and its comment list what no tool covers. No open, maintained tool or library covers this need. The change edits the project's own resolve_loki_url, removes DEFAULT_LOKI_URL and keeps the kubectl fallback of execute_logql_query. The cost is about 30 changed lines in src/devops_cli/k8s/logql.py and one constant, under one hour to build, keep and fix.
Key questions
- How should
resolve_loki_urlbehave when neither the option norloki.urlis set?: It MUST raiseKubernetesLoggingErrorwith a message that namesloki.url, and it MUST NOT return a localhost default. (best practice) [sources: src/devops_cli/k8s/logql.py:443, src/devops_cli/config/defaults.py:304, src/devops_cli/commands/roadmap_eval_grades.py:75]- Chosen: Raise
KubernetesLoggingErrorthat namesloki.url. It stops before a request and follows the rule of fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165 that a client uses only a configured URL. - Rejected: Keep
DEFAULT_LOKI_URL. It is the reported defect: the client dials an address that no person configured. - Rejected: Open a port-forward and use localhost. It adds a process lifecycle to the command, and the alternatives check found no tool for it.
- Chosen: Raise
- Should
DEFAULT_LOKI_URLremain as a default inexecute_loki_query?: No. The change MUST remove the constant and MUST require an explicitloki_urlonexecute_loki_query. (best practice) [sources: src/devops_cli/config/defaults.py:304, src/devops_cli/k8s/logql.py:325]- Chosen: Remove the constant and require the argument. No service client keeps an unconfigured localhost default, and each caller resolves the URL once.
- Rejected: Keep the constant for tests only. A test-only default can leak into a production path and keeps the fallback.
- Should
execute_logql_queryandplan_k8s_logsalso requireloki.url?: No.execute_logql_querySHALL skip the Loki request and use its kubectl fallback when no URL is set.plan_k8s_logskeeps its current behavior through that entrypoint. (best practice) [sources: src/devops_cli/k8s/logql.py, src/devops_cli/k8s/cluster_plans.py:112, tests/ai/mcp/test_k8s_logql.py:272]- Chosen: Keep the kubectl fallback when no URL is set. The fallback works with no configuration, and
tests/ai/mcp/test_k8s_logql.py:272proves it. - Rejected: Raise
KubernetesLoggingErrorinexecute_logql_query. It removes a working fallback and breaksplan_k8s_logson a host with noloki.url.
- Chosen: Keep the kubectl fallback when no URL is set. The fallback works with no configuration, and
- Should the grades report build its LogQL selector from settings?: No.
origin/mainalready replaced_SELECTORwithRESULT_LINE_SELECTOR, andServiceConfighas no namespace or app-label field. The change drops this part. (best practice) [sources: src/devops_cli/roadmap/job_grade_report.py:122, openspec/specs/roadmap-job-grades/spec.md:70, src/devops_cli/config/settings.py:1811]- Chosen: Keep
RESULT_LINE_SELECTOR. fix(roadmap): eval grades counts the result lines of Job pods #5556 delivered it on main, and it matches the Service,stageandfix-planpods. - Rejected: Build the selector from settings. No such setting exists, and the static selector is the contract of the dashboard test.
- Chosen: Keep
- Should the grades command open a port-forward when no
loki.urlis set?: No. It SHALL stop before a request with an error that namesloki.url. (best practice) [sources: src/devops_cli/commands/roadmap_eval_grades.py, AGENTS.md]- Chosen: Stop with an error that names
loki.url. The issue allows it, and it adds no process lifecycle to the command. - Rejected: Open a port-forward. It adds a lifecycle, and the alternatives check found no maintained tool for it.
- Chosen: Stop with an error that names
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both enforce the rule that service clients never fall back to an unconfigured localhost URL, but #1165 is the general rule while the candidate applies it to the roadmap eval grades command specifically.dan-petty commentedon Nov 13, 2026
Related defect found in the spec split (2026-11-13)
_SELECTORinsrc/devops_cli/roadmap/job_grade_report.py(line 88 on main) hard-codes the deployment:So
devops roadmap eval gradesreads only one deployment of the roadmap Service. Read the namespace and the app label from settings, as this item reads the Loki URL fromloki.url. Fix both in the same change, because both are about where the grades come from.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: Searches for a Python Loki/LogQL client and for a programmatic port-forward library returned no relevant tool or library, only unrelated documentation pages. The need is an internal change to the project's own
resolve_loki_url(dropDEFAULT_LOKI_URL) and to the hard-coded_SELECTORinjob_grade_report.py, which no external tool can cover.Tool: none found
Lacks:
loki.urlalone and fails before a request when it is unset_SELECTORwith settingsSearches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at 2b7f32c (see proposed design in issue body).
dan-petty commentedon Nov 25, 2026
Return to New: selector requirement conflicts with #5556
This item cannot be implemented as written because the main branch supersedes its design:
Selector from settingsrequirement expects{namespace="team-a", app_kubernetes_io_name="roadmap-service-canary"}from Service settings, and Key Questions keeps both changes together because the report hard-codesapp_kubernetes_io_name="roadmap-service". Onorigin/main, commit1eb3ea4ff(fix(roadmap): eval grades counts the result lines of Job pods #5556 / PR fix(roadmap): eval grades counts the result lines of Job pods #5569) replaced_SELECTORwithRESULT_LINE_SELECTOR: Final = '{namespace="devops", container=~"service|stage|fix-plan"}'(src/devops_cli/roadmap/job_grade_report.py:122,openspec/specs/roadmap-job-grades/spec.md:70-83). It removedapp_kubernetes_io_namebecause the Service,stageJob pods, andfix-planJob pods use different app labels (tests/support/roadmap_job_grades.py:52,60,68,77).ServiceConfig(src/devops_cli/config/settings.py:1811) defines no namespace or app-label field, andtests/prometheus/test_k8s_monitoring_dashboards.py:147-165enforces that every count query inroadmap-service-telemetry.jsonstarts with the staticRESULT_LINESstring.execute_logql_query: Makingresolve_loki_urlraiseKubernetesLoggingErrorwhenloki.urlis unset affectsexecute_logql_query(src/devops_cli/k8s/logql.py:474,497-502), which catchesConnectionErrorandhttpx2timeouts to fall back tokubectllogs (tests/ai/mcp/test_k8s_logql.py:272-288), as well asplan_k8s_logs(src/devops_cli/k8s/cluster_plans.py:112).Returning #5481 to
Newso refinement can remove the obsoleteSelector from settingsrequirement and specify whetherexecute_logql_queryandplan_k8s_logsalso requireloki.url.devops-cli-service commentedon Nov 27, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.248.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.248.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:50 UTC