feat(hub-shim): label runs with their application and filter on it - #7
Closed
ibolton336 wants to merge 2 commits into
Closed
feat(hub-shim): label runs with their application and filter on it#7ibolton336 wants to merge 2 commits into
ibolton336 wants to merge 2 commits into
Conversation
Closes #3. An application-scoped run carried its application only in spec.env as APP_ID, so "which runs belong to application 42?" had no server-side answer — a client had to fetch every run and scan spec.env, which is what the UI's per-application drawer does today. Fine at demo scale, wrong at inventory scale, and on the path of every per-application view. Stamp konveyor.io/application: "<hub id>" at create time on both AgentRun and AgentWorkflowRun, and serve ?application=<id> on both run lists as a label selector the apiserver evaluates. The label is additive to APP_ID, not a replacement: the env var is how the pod learns its application (the harness resolves from Hub at runtime), the label is how the API indexes runs. An env var is not indexable; a label is not visible inside the container. Three things worth calling out: - The numeric-id check moves to invalidApplicationIdReason() and now also guards the AgentWorkflowRun create path, which had none. That path gains a 400 for non-numeric Hub ids — previously the apiserver would have rejected the create outright once a label carried the value. - ?application= on a resource that cannot honour it is a 400, not a silent pass. An ignored filter returns every run, which a per-application view renders as "these all belong to 42" — a wrong answer that looks right. - BadRequestError now maps to 400 at the top-level catch rather than falling through to 500. Known gap: the controller builds each stage AgentRun's labels from scratch instead of inheriting the parent's, so workflow stage runs do not carry the label and ?application= on /api/agentruns finds single runs only. That needs an upstream controller change. Verified end-to-end against a real kube-apiserver (envtest binaries, no cluster): label stored, kubectl -l selects correctly, pre-label runs excluded, all four 400 paths. dev/application-filter-smoke.ts (npm run smoke:appfilter) is the reusable version. ADR 0009's route table and ADR 0010's label section record the contract; the matching amendment to upstream ADR 0006 is filed separately. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Review on the upstream ADR amendment (konveyor/agentic-controller#105) caught a real gap: the guard's /^\d+$/ accepted any digit string, but the harness's hub.ParseAppID is strconv.ParseUint(s, 10, 64) — a 21-digit id passed the shim and then killed the run at startup, the exact doomed-run class the guard exists to pre-empt. Unbounded digits could also exceed the apiserver's 63-char label-value limit. invalidApplicationIdReason now rejects values above uint64 max (BigInt compare, exact at the boundary: ...551615 valid, ...551616 rejected). Smoke gains the overflow reject case; ADR 0010's claim is restated with the bound that makes it true. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ibolton336
added a commit
that referenced
this pull request
Aug 5, 2026
Squash of PR #7 (feat/application-label), landed by direct merge after the base-branch deletion on #6's merge auto-closed the PR. Stamp konveyor.io/application at create time on AgentRun and AgentWorkflowRun; serve ?application=<id> on both run lists as an apiserver label selector. Ids are uint64-bounded (hub.ParseAppID parity), not just digits. BadRequestError maps to 400 at the top-level catch. Smoke: npm run smoke:appfilter. Closes #3 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
Author
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.
Closes #3. Stacked on #6 (ADR renumber) — merge that first.
The problem
An application-scoped run carried its application only in
spec.envasAPP_ID. So "which runs belong to application 42?" has no server-side answer:a client fetches every run and scans
spec.env, which is exactly what theUI's per-application drawer does today. Fine at demo scale, wrong at inventory
scale, and it sits on the path of every per-application view.
The shape
konveyor.io/application: "<hub id>"stamped at create time on both AgentRunand AgentWorkflowRun, and
?application=<id>on both run lists, served as alabel selector the apiserver evaluates.
The label is additive to
APP_ID, not a replacement. The two carry thesame value to different consumers and neither can do the other's job:
APP_IDspec.envkonveyor.io/applicationmetadata.labelsclient.List()selectorThat framing is the whole proposal: upstream ADR 0006 says "the application ID
goes directly on the CR as an env var" and "other resource types are listed
unfiltered". It isn't wrong about the env var — it's using one carrier for two
jobs.
Decisions worth citing
(
hub.ParseAppIDrequires it), capping them at 20 digits — inside theapiserver's 63-char label-value limit. One bounded check pre-empts both a
run the harness would reject at startup and a create the apiserver would
reject outright. The check moved to
invalidApplicationIdReason()and nowalso guards the AgentWorkflowRun create path, which previously had none.
(Second commit: review on 📖 ADR 0006 — application id as a queryable label, not only an env var konveyor/agentic-controller#105 caught that a
plain digits regex is weaker than the harness — a 21-digit id passed the
shim and overflowed
ParseUintat startup. Now an exact BigInt bound.)?application=returns every run, which a per-application view renders as"these all belong to 42" — a wrong answer that looks like a right one.
belong to 42", not "every run that ever touched 42". Pinned by a test.
BadRequestErrornow maps to 400 at the top-level catch (was 500).Known gap
The controller builds each stage AgentRun's labels from scratch rather than
inheriting the parent's, so workflow stage runs don't carry the label —
/api/agentruns?application=42finds single runs only. Upstream controllerchange; flagged in the ADR 0006 amendment.
Verification
End-to-end against a real kube-apiserver (envtest binaries, no cluster — the
default kubeconfig context is a shared demo cluster). Label stored,
kubectl -l konveyor.io/application=42selects correctly at the apiserver,pre-label runs excluded, all four 400 paths.
dev/application-filter-smoke.ts(
npm run smoke:appfilter) is the reusable version — it discovers its ownfixtures and deletes the runs it creates.
Contract recorded in ADR 0009's route table and ADR 0010's label section; the
matching amendment to upstream ADR 0006 is filed separately.
🤖 Generated with Claude Code