Commit 961a409
authored
feat(credentials): Wave 5 — CP resolves credentials and injects CREDENTIAL_IDS into runner pods (RHOAIENG-55817) (#1128)
## Summary
- **CP**: `resolveCredentialIDs()` pages SDK credentials and builds a
`provider→id` map; `ensureCredentialRoleBindings()` grants
`credential:token-reader` RoleBinding per credential to the session SA;
`buildEnv()` injects `CREDENTIAL_IDS` JSON env var into runner pods
- **Runner**: `_fetch_credential()` migrated from legacy endpoint to
`GET /api/ambient/v1/credentials/{id}/token` using `CREDENTIAL_IDS` map;
Jira `apiToken`→`token`, Google `accessToken`→`token` (full SA JSON
written to `GOOGLE_APPLICATION_CREDENTIALS`)
- **Tests**: 8 existing credential tests updated for new
`CREDENTIAL_IDS` contract; 1 new test added; 29/29 credential tests
passing, 622 total pass
## Credential Flow
```
Session start → CP calls sdk.Credentials().ListAll()
→ builds {"github": "id1", "jira": "id2"} map
→ grants credential:token-reader RoleBinding per provider to session SA
→ injects CREDENTIAL_IDS={"github": "id1", ...} into pod env
Runner start → reads CREDENTIAL_IDS
→ calls GET /api/ambient/v1/credentials/{id}/token per provider
→ sets GITHUB_TOKEN, GITLAB_TOKEN, JIRA_API_TOKEN, GOOGLE_APPLICATION_CREDENTIALS
```
## Files Changed
< /dev/null | Component | File | Change |
|---|---|---|
| CP | `kube_reconciler.go` | `resolveCredentialIDs`,
`ensureCredentialRoleBindings`, `buildEnv` updated, `provisionSession`
wired |
| Runner | `platform/auth.py` | `_fetch_credential` URL + field mapping;
Google/Jira updated; dead stub removed |
| Tests | `test_shared_session_credentials.py` | Updated for
`CREDENTIAL_IDS` contract; 1 new test |
| Docs | `control-plane.spec.md` | Removed `other` from token response;
updated status to implemented |
| Docs | `control-plane.guide.md` | Restructured with dev context
reference; gap table updated |
| Docs | `.claude/context/control-plane-development.md` | Fixed
operator→CP refs; added `CREDENTIAL_IDS` section |
## Test plan
- [x] `cd components/runners/ambient-runner && python -m pytest tests/
-k credential` — 29/29 pass
- [x] `cd components/ambient-control-plane && go build ./... && go vet
./...` — clean
- [x] `gofmt -l internal/reconciler/kube_reconciler.go` — no output
(clean)
- [x] `uv run ruff check .` — no errors
- [ ] Deploy to MPP cluster and verify `CREDENTIAL_IDS` injected into
pod env
- [ ] Verify `credential-token-reader-{provider}` RoleBindings created
per session
- [ ] Verify `GITLAB_TOKEN`/`GITHUB_TOKEN` set in running pod
🤖 Generated with [Claude Code](https://claude.ai/code)25 files changed
Lines changed: 463 additions & 304 deletions
File tree
- .claude/context
- components
- ambient-control-plane/internal/reconciler
- runners/ambient-runner
- ag_ui_claude_sdk
- ambient_runner
- bridges
- claude
- gemini_cli
- langgraph
- endpoints
- middleware
- platform
- tools
- tests
- docs/internal/design
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
102 | 118 | | |
103 | 119 | | |
104 | 120 | | |
105 | | - | |
| 121 | + | |
106 | 122 | | |
107 | 123 | | |
108 | 124 | | |
| |||
Lines changed: 83 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
204 | 216 | | |
205 | 217 | | |
206 | 218 | | |
207 | | - | |
208 | 219 | | |
209 | 220 | | |
210 | 221 | | |
| |||
361 | 372 | | |
362 | 373 | | |
363 | 374 | | |
364 | | - | |
| 375 | + | |
365 | 376 | | |
366 | 377 | | |
367 | 378 | | |
| |||
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
397 | | - | |
| 408 | + | |
398 | 409 | | |
399 | 410 | | |
400 | 411 | | |
| |||
536 | 547 | | |
537 | 548 | | |
538 | 549 | | |
539 | | - | |
| 550 | + | |
540 | 551 | | |
541 | 552 | | |
542 | 553 | | |
| |||
603 | 614 | | |
604 | 615 | | |
605 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
606 | 624 | | |
607 | 625 | | |
608 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
609 | 686 | | |
610 | 687 | | |
611 | 688 | | |
| |||
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
| 610 | + | |
610 | 611 | | |
611 | 612 | | |
612 | 613 | | |
| |||
633 | 634 | | |
634 | 635 | | |
635 | 636 | | |
| 637 | + | |
636 | 638 | | |
637 | 639 | | |
638 | 640 | | |
| |||
670 | 672 | | |
671 | 673 | | |
672 | 674 | | |
673 | | - | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
674 | 678 | | |
675 | 679 | | |
676 | 680 | | |
| |||
687 | 691 | | |
688 | 692 | | |
689 | 693 | | |
690 | | - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
691 | 697 | | |
692 | 698 | | |
693 | 699 | | |
| |||
1163 | 1169 | | |
1164 | 1170 | | |
1165 | 1171 | | |
1166 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
1167 | 1176 | | |
1168 | 1177 | | |
1169 | 1178 | | |
| |||
1364 | 1373 | | |
1365 | 1374 | | |
1366 | 1375 | | |
1367 | | - | |
| |||
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 154 | + | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
| |||
0 commit comments