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 workstation with no loki.url, devops roadmap eval grades uses DEFAULT_LOKI_URL (http://localhost:3100), sends a request, and fails with Connection refused. This violates the rule of #1165 that service clients use only configured URLs. The grades report also hard-codes the roadmap Service selector to namespace devops and app label roadmap-service, so it reads only one deployment. The fix removes the localhost fallback, stops before a request with an error that names loki.url, and builds the selector from settings.
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:3100whileloki.urlis unset. - THEN It returns
http://loki.example:3100.
Requirement: Configured Loki setting
resolve_loki_url SHALL return the loki.url setting when no explicit loki_url argument is set.
Scenario: Setting supplies URL
- WHEN
resolve_loki_urlreceives no argument andloki.urlishttp://loki.team:3100. - THEN It returns
http://loki.team:3100.
Requirement: Missing Loki URL
resolve_loki_url SHALL raise KubernetesLoggingError that names loki.url when neither the explicit argument nor the setting is set.
Scenario: No URL configured
- WHEN
resolve_loki_urlreceives no argument andloki.urlis unset. - THEN It raises
KubernetesLoggingErrorwhose message containsloki.url, and no HTTP request is sent.
Requirement: No localhost default in query
execute_loki_query SHALL require an explicit loki_url and SHALL NOT use DEFAULT_LOKI_URL as a default.
Scenario: Direct query without URL
- WHEN
execute_loki_queryis called without aloki_urlargument. - THEN The call raises
TypeErrorand no request tohttp://localhost:3100is made.
Requirement: Remove fallback constant
The source SHALL NOT define or import DEFAULT_LOKI_URL after the change.
Scenario: Fallback constant is gone
- WHEN The test searches
src/devops_cliforDEFAULT_LOKI_URL. - THEN The search returns no match.
Requirement: Grades command fails early
devops roadmap eval grades SHALL 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-url. - THEN The command exits with an error that contains
loki.urland sends no request tohttp://localhost:3100.
Requirement: Selector from settings
The grades report SHALL build its LogQL stream selector from the configured namespace and app label of the roadmap Service.
Scenario: Configured roadmap Service
- WHEN The roadmap Service namespace setting is
team-aand the app label setting isroadmap-service-canary. - THEN The selector is {namespace="team-a", app_kubernetes_io_name="roadmap-service-canary"}.
Existing Tool Considered
The alternatives check of 2026-11-17 in the issue body returned none with Tool: none found. No open, maintained tool or library covers this need. The change edits the project's own resolve_loki_url, removes DEFAULT_LOKI_URL, and reads the selector from settings. This is not a new tool, so it has no separate build cost.
Key questions
- How should
resolve_loki_urlbehave when neither the option norloki.urlis set?: It SHALL stop before any request withKubernetesLoggingErrorthat namesloki.url; it SHALL NOT useDEFAULT_LOKI_URL. (best practice) [sources: src/devops_cli/k8s/logql.py:414, src/devops_cli/config/defaults.py:290]- Chosen: Raise
KubernetesLoggingErrornamingloki.url. It stops before a request and follows the fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165 rule. - Rejected: Keep
DEFAULT_LOKI_URL. This is the reported defect: an unconfigured localhost fallback. - Rejected: Open a port-forward and use localhost. The issue allows a stop; a hidden port-forward adds lifecycle work, and the alternatives check found no tool for it.
- Chosen: Raise
- Should
DEFAULT_LOKI_URLremain as a default inexecute_loki_query?: No. Remove the constant and its imports, and makeexecute_loki_queryrequire an explicitloki_url. (best practice) [sources: src/devops_cli/config/defaults.py:290, src/devops_cli/k8s/logql.py:19, src/devops_cli/k8s/logql.py:324, src/devops_cli/k8s/logql.py:421]- Chosen: Remove
DEFAULT_LOKI_URLand require an explicit URL. No service client may use an unconfigured localhost default. - Rejected: Keep the constant for tests only. A test-only default can leak into production paths and keeps the fallback.
- Chosen: Remove
- Where should the grades report get the namespace and app label for its selector?: From the roadmap Service settings, with the current values as defaults if the settings are absent. (best practice) [sources: src/devops_cli/roadmap/job_grade_report.py:88, src/devops_cli/commands/roadmap_eval_grades.py:75]
- Chosen: Read the namespace and app label from settings. The reply asks for it, and the hard-coded selector reads only one deployment.
- Rejected: Keep
_SELECTORhard-coded. It ignores other deployments and contradicts the reply.
- Should the selector fix be in the same change as the Loki URL fix?: Yes. Fix both in one change because both control where the grades come from. (best practice) [sources: src/devops_cli/roadmap/job_grade_report.py:88, src/devops_cli/commands/roadmap_eval_grades.py:75]
- Chosen: Fix both in one change. The reply says both are about where the grades come from.
- Rejected: Split the selector fix into another issue. It is a small change in the same command path, and the reply asks for one change.
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.