-
Notifications
You must be signed in to change notification settings - Fork 6
fix(scheduler): derive K8s service_url default at runtime (closes #179)#181
Open
initializ-mk wants to merge 1 commit into
Open
fix(scheduler): derive K8s service_url default at runtime (closes #179) #181initializ-mk wants to merge 1 commit into
initializ-mk wants to merge 1 commit into
Conversation
Pre-fix, the K8s scheduler backend's runtime constructor hard-errored when scheduler.kubernetes.service_url was empty: Error: kubernetes scheduler backend: scheduler.kubernetes.service_url is required ...even though the build-time schedule-manifest stage at forge-cli/build/schedule_manifest_stage.go already knew how to default the same field to http://<agent_id>.<namespace>.svc:<port>/ when unset. Two adjacent code paths reaching opposite conclusions for the same missing field — operators who deployed in-cluster without an explicit service_url couldn't start the agent. Fix: mirror the build-time default in the runtime constructor. - K8sBackendConfig gains a Port int field; selectScheduleBackend plumbs r.cfg.Port into it. - NewKubernetesBackend (and the -WithClient test seam) derives http://<agent_id>.<namespace>.svc:<port>/ when cfg.ServiceURL is empty. defaultK8sServiceURL is the shared helper. - Port=0 falls back to 8080 (matches the runner's listen-port default at forge-cli/runtime/runner.go:152-153). - The hard-error branch is gone — there's no scenario in-cluster where we can't derive a sensible default. - Operator override semantics unchanged: an explicit service_url always wins. Pinned by TestKubernetesBackend_ServiceURLExplicitOverride. Tests added: - TestKubernetesBackend_ServiceURLDefaultDerivation — the #179 pin: empty ServiceURL + Port=9090 → http://my-agent.ns-a.svc:9090/ - TestKubernetesBackend_ServiceURLDefaultPortFallback — Port=0 falls back to 8080 - TestKubernetesBackend_ServiceURLExplicitOverride — explicit ServiceURL (e.g. https://gateway.example.com/...) passes through untouched Docs: - docs/deployment/scheduler-kubernetes.md — new "service_url defaulting" subsection; YAML comment updated to note the auto-derivation - docs/core-concepts/scheduling.md — YAML comment updated with cross-link - CHANGELOG.md — Unreleased / Fixed entry
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
Closes #179. The runtime K8s scheduler backend was hard-erroring when `scheduler.kubernetes.service_url` was unset, even though the build-time `schedule_manifest_stage` already knew how to default the same field. This PR mirrors the build-time default in the runtime so an in-cluster agent without an explicit `service_url` comes up cleanly.
```
Before (in-cluster, no service_url in forge.yaml)
Error: kubernetes scheduler backend: scheduler.kubernetes.service_url is required
After
ServiceURL auto-derived to http://<agent_id>..svc:/
```
Changes
Code
Tests
`forge-cli/runtime/scheduler_k8s_backend_test.go`:
Docs
Test plan
Risks
Low. The change only adds a fallback for a previously-fatal path. Operators with an explicit `service_url` (the supported configuration today) see no change in behavior — pinned by `TestKubernetesBackend_ServiceURLExplicitOverride`. Field-backed defaults match the build stage's behavior 1:1, so newly-derived URLs identical to what `forge package` would have written.