feat: add serviceAccountName to CRD & fix bundled skill preservation with agentFiles#23
feat: add serviceAccountName to CRD & fix bundled skill preservation with agentFiles#23IsaiahStapleton wants to merge 2 commits into
Conversation
…and fix plugin tests When deploying with agentFiles (git repo or ConfigMap), the agentFiles openclaw.json completely replaced the operator seed, discarding the 57 disabled bundled skill entries. Users relying on the broken upstream allowBundled mechanism (OpenClaw bugs #21709, #10236) got all bundled skills enabled despite their whitelist. Fix merge.js to deep-merge the agentFiles config on top of the operator seed instead of replacing it. Operator defaults (disabled skills) are preserved as the base; agentFiles config layers on top, so explicitly enabled skills in the agentFiles config still take precedence. Also update two plugin tests that were broken by ec8176f (init-plugins mount changed from per-subPath to whole-home /home/node). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: IsaiahStapleton <istaplet@redhat.com>
Allow users to set a custom ServiceAccount on the gateway pod via spec.serviceAccountName. When set, the operator also enables automountServiceAccountToken so the SA token is mounted. When omitted, the default SA is used with no token mounted (existing behavior). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: IsaiahStapleton <istaplet@redhat.com>
📝 WalkthroughWalkthroughAdds an optional ChangesServiceAccountName Feature
Config Seeding and Plugin Mount Fixups
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/controller/claw_deployment_test.go (1)
2602-2661: ⚡ Quick winConsider adding test coverage for the error path.
The tests cover the happy paths well, but don't verify the error case when the gateway Deployment is not found in the manifests. Consider adding a subtest that verifies the function returns an error when called with an empty objects slice or objects that don't contain the expected Deployment.
📝 Suggested test case
+ + t.Run("returns error when deployment not found", func(t *testing.T) { + instance := &clawv1alpha1.Claw{} + instance.Name = testInstanceName + instance.Spec.ServiceAccountName = "my-reader" + + err := configureClawDeploymentServiceAccount([]*unstructured.Unstructured{}, instance) + assert.Error(t, err) + assert.Contains(t, err.Error(), "claw deployment not found in manifests") + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/controller/claw_deployment_test.go` around lines 2602 - 2661, The TestConfigureClawDeploymentServiceAccount function currently only tests successful execution paths but lacks coverage for error scenarios. Add a new t.Run subtest (e.g., "returns error when Deployment not found") that verifies configureClawDeploymentServiceAccount returns an error when called with an empty objects slice or with objects that don't contain the expected Deployment (identified by the ClawGatewayContainerName or deployment kind). Test both the empty slice case and the case where objects exist but don't match the expected structure to ensure the function properly validates its input and fails gracefully when the required Deployment is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/controller/claw_deployment_test.go`:
- Around line 2602-2661: The TestConfigureClawDeploymentServiceAccount function
currently only tests successful execution paths but lacks coverage for error
scenarios. Add a new t.Run subtest (e.g., "returns error when Deployment not
found") that verifies configureClawDeploymentServiceAccount returns an error
when called with an empty objects slice or with objects that don't contain the
expected Deployment (identified by the ClawGatewayContainerName or deployment
kind). Test both the empty slice case and the case where objects exist but don't
match the expected structure to ensure the function properly validates its input
and fails gracefully when the required Deployment is missing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: c3bb7743-f1d0-44b6-99fd-012488a9f8aa
📒 Files selected for processing (7)
api/v1alpha1/claw_types.goconfig/crd/bases/claw.sandbox.redhat.com_claws.yamlinternal/assets/manifests/claw/configmap.yamlinternal/controller/claw_deployment.gointernal/controller/claw_deployment_test.gointernal/controller/claw_plugins_test.gointernal/controller/claw_resource_controller.go
Summary
spec.serviceAccountNamefield to the Claw CRD so users can mount a custom ServiceAccount on the gateway pod. When set,automountServiceAccountTokenis automatically enabled so the SA token is mounted. When omitted, existing behavior is preserved (default SA, no token).openclaw.jsoncompletely replaced the operator seed, discarding all 57 disabled bundled skill entries. Users relying on the broken upstreamallowBundledmechanism (OpenClaw bugs #21709, #10236) got all bundled skills enabled despite their whitelist.merge.jsnow deep-merges agentFiles config on top of the operator seed so disabled-by-default skills stay disabled.Motivation
The operator hardcodes
automountServiceAccountToken: falseand defaultsserviceAccountNameto"default". There was no way for users to mount a read-only SA token for in-cluster API access (e.g., listing pods, reading events). Direct deployment patches were reverted by the operator'sCreateOrUpdatereconciliation.Summary by CodeRabbit