Skip to content

Introduce agent sandboxing in to agent manager#1281

Open
vish-mv wants to merge 43 commits into
wso2:mainfrom
vish-mv:sandboxing-agt
Open

Introduce agent sandboxing in to agent manager#1281
vish-mv wants to merge 43 commits into
wso2:mainfrom
vish-mv:sandboxing-agt

Conversation

@vish-mv

@vish-mv vish-mv commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

Agents execute arbitrary, often LLM-generated code, and today every agent pod shares the host kernel via the default container runtime. A compromised or misbehaving agent therefore has a larger blast radius than necessary, and platform operators have no way to place higher-risk agents under stronger isolation without leaving the platform.

This PR introduces per-environment isolation tiers so operators can choose how strongly agent workloads are sandboxed, per environment:

  • Sandboxing T1 — runc (default): Hardened sandboxed pod, shared host kernel
  • Sandboxing T2 — gVisor (runsc): Userspace kernel intercepting syscalls
  • Sandboxing T3 — Kata Containers (kata-qemu): Per-agent micro-VM with its own guest kernel

Resolves: - #1082

Goals

  • Let an operator pick an isolation tier at environment creation time; every agent deployed or promoted to that environment automatically runs under that tier.
  • Keep the default experience unchanged: runc environments behave exactly as before, and the feature is a no-op for all-runc installations.
  • Make stronger tiers safe to adopt on a live cluster: gVisor/Kata run on dedicated, tainted nodes so installing a runtime never touches nodes serving existing workloads.

Approach

  • Control Plane

    • Added support for selecting and storing an isolation tier when creating an environment.
    • Ensures deployments and promotions automatically use the runtime associated with the selected tier.
  • Data Plane

    • Added support for gVisor and Kata runtime classes and the required scheduling configuration.
    • Updated platform components so logging, metrics, warm pools, and agent instrumentation continue to work across all isolation tiers.
  • Node Setup

    • Added setup scripts and documentation for provisioning dedicated gVisor and Kata nodes.
    • Integrated sandbox setup into the existing installation and quick-start workflows.
  • Console

    • Added an Isolation Tier selector during environment creation.
    • Added visual indicators (shield icons and tooltips) to display the configured isolation tier throughout the UI.

User stories

  • As a platform engineer, I can choose an isolation tier for an environment so agents run with the required level of sandboxing.
  • As an agent developer, I can deploy and promote agents without changing my application, regardless of the selected isolation tier.
  • As a Console user, I can easily identify the isolation tier configured for each environment.

Release note

Agent Manager now supports per-environment isolation tiers for agent workloads.

In addition to the default sandboxed runc runtime (Sandboxing T1), environments can now be created with:

  • Sandboxing T2 — gVisor
  • Sandboxing T3 — Kata Containers

Agents automatically run under the environment's configured runtime during deployment and promotion, without requiring any application changes.

Documentation

New Pages

  • gVisor Isolation Tier Guide: agent-manager/docs/administration/isolation-tiers/gvisor
  • Kata Containers Isolation Tier Guide: agent-manager/docs/administration/isolation-tiers/kata

Updated Pages

  • Environment Management: agent-manager/docs/administration/environment-management
  • Quick Start: agent-manager/docs/getting-started/quick-start
  • Install on a VM: agent-manager/docs/getting-started/on-a-vm
  • Install on k3d: agent-manager/docs/getting-started/on-k3d

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

N/A.

Marketing

N/A.

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Summary by CodeRabbit

  • New Features
    • Added per-environment isolation tiers (runc, gvisor, Kata Containers) with Console selection and new badge/chip indicators.
    • Added Agent Sandbox installation support, including new setup options (sandbox/gVisor/Kata) and automated environment isolation tier propagation.
  • Bug Fixes
    • Deployment details now omit lastDeployed when unavailable to prevent confusing timestamps.
  • Documentation
    • Updated environment management, isolation-tier (gVisor/Kata) guides, quick-start install flow, and troubleshooting for runtime/build prerequisites.

vish-mv added 24 commits July 1, 2026 21:46
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds gVisor, Kata Containers, and Agent Sandbox support across deployment APIs, release-binding reconciliation, console environment management, Kubernetes setup scripts, Helm resources, observability configuration, Make targets, and operational documentation.

Changes

Backend API and Console Isolation Tiers

Layer / File(s) Summary
Client contracts and environment data shapes
agent-manager-service/clients/openchoreosvc/client/*, agent-manager-service/models/*, agent-manager-service/spec/*
Client operations accept component-type configuration maps, runtime-class reconciliation is exposed, environment requests include isolation-tier data, and deployment timestamps become optional.
Agent and environment service wiring
agent-manager-service/services/*, agent-manager-service/controllers/*, agent-manager-service/clients/openchoreosvc/client/deployments.go
Isolation tiers propagate through environment flows and runtime-class overrides are applied during deploy, promote, settings updates, and deployment reads.
Resource configuration validation
agent-manager-service/clients/openchoreosvc/client/components.go, agent-manager-service/services/agent_manager.go, agent-manager-service/utils/*
Partial resource overrides are merged with existing values, effective defaults are populated, and requested CPU/memory values are validated against active limits.
Shared isolation-tier UI contract and display
console/workspaces/libs/shared-component/*, console/workspaces/libs/types/src/api/deployments.ts, console/workspaces/pages/deploy/*
Adds tier metadata, badges, chips, exports, frontend environment data, and deployment-card indicators.
Console isolation-tier configuration
console/workspaces/pages/deployment-pipelines/*
Adds tier selection, validation, generated script parameters, setup warnings, environment table indicators, and promotion-chain display.
Mocks and status handling
agent-manager-service/clients/clientmocks/*, agent-manager-service/tests/*, cli/pkg/cmd/agent/status.go
Mocks and promotion tests support expanded client signatures and absent deployment timestamps are handled in CLI status output.

Sandbox Runtime Infrastructure and Documentation

Layer / File(s) Summary
Sandbox installation and setup entry points
Makefile, deployments/quick-start/*, deployments/scripts/setup-sandbox.sh, deployments/setup/env.sh, deployments/k8s/*runtimeclass.yaml, deployments/scripts/add-environment.sh
Adds setup targets, installs and verifies Agent Sandbox, defines runtime-class manifests, extends local setup configuration, and supports isolation-tier environment creation.
gVisor node provisioning
deployments/setup/install-gvisor.sh, deployments/setup/setup-gvisor-node.sh
Installs runsc, configures containerd, provisions a gVisor node, applies scheduling metadata, patches logging tolerations, and validates networking.
Kata node provisioning
deployments/setup/install-kata.sh, deployments/setup/setup-kata-node.sh
Checks KVM support, installs Kata, joins or configures nodes, wires containerd, applies runtime scheduling, and patches logging tolerations.
Sandbox workload and observability resources
deployments/helm-charts/..., deployments/setup/setup-openchoreo.sh, deployments/values/*
Retargets instrumentation to SandboxTemplate resources, adds runtime-class and warm-pool resources, configures build user namespaces, and updates metrics and Fluent Bit behavior.
Isolation-tier and installation documentation
documentation/docs/administration/*, documentation/docs/getting-started/*, documentation/sidebars.ts
Documents isolation-tier operation, setup, verification, troubleshooting, installation ordering, prerequisites, and navigation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Suggested reviewers: menakaj, raveensr, anoshanj, hanzjk

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the core sections, but several required template sections are missing or left blank, including Samples, Related PRs, Migrations, Test environment, and Learning. Add the missing template sections and fill in blank items like Training, Automation tests, and Security checks with concrete details or N/A explanations.
Docstring Coverage ⚠️ Warning Docstring coverage is 48.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is related to the main change and clearly signals agent sandboxing in Agent Manager.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vish-mv vish-mv requested a review from menakaj July 8, 2026 12:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
agent-manager-service/models/environment.go (1)

43-53: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Add a validate tag to IsolationTier for consistency with sibling fields.

Every other field on CreateEnvironmentRequest (Name, DisplayName, DNSPrefix, DataplaneRef) carries a validate tag, but IsolationTier has none. Combined with the missing OpenAPI enum (see api_v1_openapi.yaml comment), an invalid tier string can pass through both layers silently.

🛠️ Proposed fix
-	IsolationTier    string       `json:"isolationTier,omitempty"`
+	IsolationTier    string       `json:"isolationTier,omitempty" validate:"omitempty,oneof=runc gvisor kata"`
🤖 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 `@agent-manager-service/models/environment.go` around lines 43 - 53, Add a
validate tag to the IsolationTier field in CreateEnvironmentRequest, enforcing
the supported isolation-tier values and allowing omission when the field is
empty. Use the project’s existing isolation-tier validation convention or enum
symbols rather than accepting arbitrary strings.
🧹 Nitpick comments (6)
console/workspaces/libs/types/src/api/deployments.ts (1)

134-134: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider sharing a single isolation-tier union type instead of a loose string.

environmentSchema.ts defines its own isolationTiers/IsolationTier literal union locally. Typing Environment.isolationTier as plain string here means the two can silently drift (e.g. a new tier added in one place but not the other) with no compiler check.

♻️ Hoist the tier union into this shared package
+export const isolationTiers = ["runc", "gvisor", "kata"] as const;
+export type IsolationTier = (typeof isolationTiers)[number];
+
 export interface Environment {
   ...
-  isolationTier?: string;
+  isolationTier?: IsolationTier;
 }

Then import isolationTiers/IsolationTier from this package in environmentSchema.ts instead of redefining them.

🤖 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 `@console/workspaces/libs/types/src/api/deployments.ts` at line 134, Replace
the loose string type on Environment.isolationTier with a shared exported
IsolationTier union, and expose its isolationTiers values from this API types
package. Update environmentSchema.ts to import and reuse these shared symbols
instead of defining a local union, ensuring both schemas remain synchronized.
agent-manager-service/tests/promote_agent_test.go (1)

88-90: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Signature updates are correct; consider asserting componentTypeConfigs forwarding.

All three subtests correctly update PromoteComponentFunc to the new signature, but none assert on the new componentTypeConfigs argument (only envOverrides/fileOverrides are captured/checked). Since this parameter is new plumbing through the promote flow, a regression here (e.g., always passing nil or the wrong map) wouldn't be caught by these tests.

✅ Example assertion to add
 		require.Equal(t, http.StatusAccepted, rr.Code)
 		require.Len(t, ocClient.PromoteComponentCalls(), 1)
 		call := ocClient.PromoteComponentCalls()[0]
 		require.Equal(t, "development", call.SourceEnvironment)
 		require.Equal(t, "production", call.TargetEnvironment)
+		// e.g. assert expected component type configs were forwarded
+		// require.Equal(t, expectedConfigs, call.ComponentTypeConfigs)

Also applies to: 120-124, 155-158

🤖 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 `@agent-manager-service/tests/promote_agent_test.go` around lines 88 - 90,
Extend the PromoteComponentFunc stubs in all three promote-agent subtests to
capture the componentTypeConfigs argument and assert that each invocation
forwards the expected map. Keep the existing envOverrides and fileOverrides
assertions, and ensure the checks distinguish the expected component-type
configuration from nil or an incorrect map.
deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml (1)

118-120: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider constraining runtimeClassName to known values.

No enum restricts this field to the actual RuntimeClasses (gvisor, kata-qemu) plus empty. A typo would only surface as a pod scheduling failure rather than a schema validation error.

♻️ Proposed enum constraint
         runtimeClassName:
           type: string
           default: ""
+          enum:
+            - ""
+            - gvisor
+            - kata-qemu

Also applies to: 143-143

🤖 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
`@deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml`
around lines 118 - 120, Constrain the runtimeClassName schema fields in the
agent API component definitions to the supported values: empty, gvisor, and
kata-qemu. Add the same enum restriction to both occurrences of
runtimeClassName, while preserving the existing default empty string.
deployments/scripts/setup-sandbox.sh (1)

28-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate chart reference/version constants across install paths.

The same agent-sandbox chart ref and version variables are independently hardcoded here and in install-helpers.sh, risking version drift between the quick-start and standalone setup flows.

♻️ Suggested consolidation

Move AGENT_SANDBOX_CHART_REF, AGENT_SANDBOX_MODULE_VERSION, and AGENT_SANDBOX_UPSTREAM_VERSION (with their defaults) into deployments/setup/env.sh as the single source of truth, and have install-helpers.sh reference them instead of redefining.

🤖 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 `@deployments/scripts/setup-sandbox.sh` around lines 28 - 38, Consolidate
AGENT_SANDBOX_CHART_REF, AGENT_SANDBOX_MODULE_VERSION, and
AGENT_SANDBOX_UPSTREAM_VERSION, including defaults, in deployments/setup/env.sh.
Update setup-sandbox.sh and install-helpers.sh to source and reuse these shared
variables, removing their independent definitions and chart reference so both
installation paths use the same values.
deployments/setup/setup-gvisor-node.sh (1)

106-117: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Same missing checksum verification as install-gvisor.sh.

For consistency with gVisor's documented install flow (which always verifies the .sha512 sidecar files), consider adding the same sha512sum -c step here before docker cp'ing the binaries into the node container.

🤖 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 `@deployments/setup/setup-gvisor-node.sh` around lines 106 - 117, Add checksum
verification to the gVisor download flow before the docker cp commands, fetching
each binary’s .sha512 sidecar from BASE and running sha512sum -c against the
downloaded files. Keep installation proceeding only after both checks pass, then
retain the existing chmod and container-copy behavior.
deployments/scripts/add-environment.sh (1)

210-221: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Validate ISOLATION_TIER against the allowed set, like IS_PRODUCTION/IDP_SKIP_TLS_VERIFY.

Unlike those two flags, ISOLATION_TIER has no allow-list check and is embedded into the JSON body unescaped — a stray " breaks the request, and typos only surface as an opaque API error.

🛡️ Proposed fix
 ISOLATION_TIER="${ISOLATION_TIER:-}"
+case "$ISOLATION_TIER" in
+    ""|gvisor|kata) ;;
+    *)
+        echo "❌ ISOLATION_TIER must be 'gvisor' or 'kata' (got '${ISOLATION_TIER}')"
+        exit 1
+        ;;
+esac
 ISOLATION_TIER_FIELD=""
 if [ -n "${ISOLATION_TIER}" ]; then
     ISOLATION_TIER_FIELD="\"isolationTier\": \"${ISOLATION_TIER}\","
     echo "   Isolation tier: ${ISOLATION_TIER}"
 fi
🤖 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 `@deployments/scripts/add-environment.sh` around lines 210 - 221, Validate
ISOLATION_TIER before constructing ISOLATION_TIER_FIELD, accepting only the
supported values "gvisor" and "kata" (or the empty default); reject any other
value with the same clear validation/error handling used for IS_PRODUCTION and
IDP_SKIP_TLS_VERIFY. Keep the field omitted when empty and prevent unvalidated
input from being embedded in the JSON payload.
🤖 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.

Inline comments:
In `@agent-manager-service/clients/openchoreosvc/client/deployments.go`:
- Around line 364-368: Update the write paths in buildComponentTypeEnvConfigs
handling so an empty target-tier configuration removes any existing
runtimeClassName from ComponentTypeEnvironmentConfigs. Ensure this cleanup
occurs for in-place merges, empty desired values, and cases where the component
configuration map would otherwise be skipped, while preserving normal non-empty
configuration merging.
- Around line 383-416: The pre-retry current-value check in
EnsureReleaseBindingRuntimeClass is stale and allows concurrent callers to both
update and bump restartedAt. Move the desired-runtime-class comparison into the
retryReleaseBindingUpdate mutation closure, using the freshly fetched rb state
to skip mutation when runtimeClassName already matches; preserve initialization
and restartedAt updates only when correction is still required.

In `@agent-manager-service/docs/api_v1_openapi.yaml`:
- Around line 12474-12477: Add an enum constraint containing the supported
isolationTier values, "gvisor" and "kata", to the isolationTier property in both
environment schemas. Keep the existing type, description, example, and default
behavior unchanged while preventing arbitrary values from being accepted.

In `@agent-manager-service/services/agent_manager.go`:
- Around line 4139-4186: Update reconcileIsolationRuntimeClass and its caller to
run only for API agents, using the existing component/agent-type lookup or an
isAPIAgent value passed from GetAgentDeployments; skip reconciliation entirely
for non-API agents so their bindings are not modified. Also avoid performing
ListEnvironments and per-deployment EnsureReleaseBindingRuntimeClass calls on
every status read by adding the appropriate environment-list caching or
reconciliation rate limit, while preserving best-effort behavior.

In `@agent-manager-service/services/environment_service.go`:
- Around line 73-79: Validate req.IsolationTier before constructing or
submitting the environment through the OpenChoreo flow, accepting only "",
"gvisor", and "kata"; reject unsupported values instead of persisting them.
Implement this in the environment creation path surrounding the request mapping,
or add equivalent schema validation that prevents invalid isolation tiers from
being stored.

In
`@deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml`:
- Around line 199-206: Update the gateway namespace egress rule in the agent
telemetry NetworkPolicy to include a ports restriction covering only the actual
gateway telemetry port(s) and required protocol(s). Keep the existing
namespaceSelector label match unchanged and do not allow unrestricted traffic to
other ports.

In `@deployments/scripts/add-environment.sh`:
- Around line 249-261: Update the kubectl annotate command in the isolation-tier
handling block to target the OpenChoreo control-plane namespace from
OPEN_CHOREO_DEFAULT_NAMESPACE instead of ORG_NAME. Use that same namespace in
the manual fallback command, while preserving the existing annotation and
overwrite behavior.

In `@deployments/setup/install-gvisor.sh`:
- Around line 74-82: Update the gVisor download block around BASE to use unique
temporary paths from mktemp rather than fixed /tmp/runsc and
/tmp/containerd-shim-runsc-v1 paths. Download the matching .sha512 files, verify
each binary with sha512sum -c before making it executable or moving it into
/usr/local/bin, and clean up temporary files after installation while preserving
the existing architecture-specific URLs.

---

Outside diff comments:
In `@agent-manager-service/models/environment.go`:
- Around line 43-53: Add a validate tag to the IsolationTier field in
CreateEnvironmentRequest, enforcing the supported isolation-tier values and
allowing omission when the field is empty. Use the project’s existing
isolation-tier validation convention or enum symbols rather than accepting
arbitrary strings.

---

Nitpick comments:
In `@agent-manager-service/tests/promote_agent_test.go`:
- Around line 88-90: Extend the PromoteComponentFunc stubs in all three
promote-agent subtests to capture the componentTypeConfigs argument and assert
that each invocation forwards the expected map. Keep the existing envOverrides
and fileOverrides assertions, and ensure the checks distinguish the expected
component-type configuration from nil or an incorrect map.

In `@console/workspaces/libs/types/src/api/deployments.ts`:
- Line 134: Replace the loose string type on Environment.isolationTier with a
shared exported IsolationTier union, and expose its isolationTiers values from
this API types package. Update environmentSchema.ts to import and reuse these
shared symbols instead of defining a local union, ensuring both schemas remain
synchronized.

In
`@deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml`:
- Around line 118-120: Constrain the runtimeClassName schema fields in the agent
API component definitions to the supported values: empty, gvisor, and kata-qemu.
Add the same enum restriction to both occurrences of runtimeClassName, while
preserving the existing default empty string.

In `@deployments/scripts/add-environment.sh`:
- Around line 210-221: Validate ISOLATION_TIER before constructing
ISOLATION_TIER_FIELD, accepting only the supported values "gvisor" and "kata"
(or the empty default); reject any other value with the same clear
validation/error handling used for IS_PRODUCTION and IDP_SKIP_TLS_VERIFY. Keep
the field omitted when empty and prevent unvalidated input from being embedded
in the JSON payload.

In `@deployments/scripts/setup-sandbox.sh`:
- Around line 28-38: Consolidate AGENT_SANDBOX_CHART_REF,
AGENT_SANDBOX_MODULE_VERSION, and AGENT_SANDBOX_UPSTREAM_VERSION, including
defaults, in deployments/setup/env.sh. Update setup-sandbox.sh and
install-helpers.sh to source and reuse these shared variables, removing their
independent definitions and chart reference so both installation paths use the
same values.

In `@deployments/setup/setup-gvisor-node.sh`:
- Around line 106-117: Add checksum verification to the gVisor download flow
before the docker cp commands, fetching each binary’s .sha512 sidecar from BASE
and running sha512sum -c against the downloaded files. Keep installation
proceeding only after both checks pass, then retain the existing chmod and
container-copy behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 024596c0-35c5-4b8b-a08f-f6bfc2d8b162

📥 Commits

Reviewing files that changed from the base of the PR and between 34c01d6 and 6d5c9af.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (61)
  • Makefile
  • agent-manager-service/clients/clientmocks/openchoreo_client_fake.go
  • agent-manager-service/clients/openchoreosvc/client/client.go
  • agent-manager-service/clients/openchoreosvc/client/constants.go
  • agent-manager-service/clients/openchoreosvc/client/deployments.go
  • agent-manager-service/clients/openchoreosvc/client/infrastructure.go
  • agent-manager-service/clients/openchoreosvc/client/types.go
  • agent-manager-service/controllers/environment_controller.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/build_deployment.go
  • agent-manager-service/models/environment.go
  • agent-manager-service/models/infra_resources.go
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/services/environment_service.go
  • agent-manager-service/spec/model_create_environment_request.go
  • agent-manager-service/spec/model_deployment_details_response.go
  • agent-manager-service/spec/model_gateway_environment_response.go
  • agent-manager-service/tests/apitestutils/mock_clients.go
  • agent-manager-service/tests/promote_agent_test.go
  • cli/pkg/cmd/agent/status.go
  • console/workspaces/libs/shared-component/src/components/EnvironmentCard/EnvironmentCard.tsx
  • console/workspaces/libs/shared-component/src/components/IsolationTierIndicator/IsolationTierIndicator.tsx
  • console/workspaces/libs/shared-component/src/components/IsolationTierIndicator/index.ts
  • console/workspaces/libs/shared-component/src/components/index.ts
  • console/workspaces/libs/types/src/api/deployments.ts
  • console/workspaces/pages/deploy/src/subComponent/DeployCard.tsx
  • console/workspaces/pages/deployment-pipelines/src/form/environmentSchema.ts
  • console/workspaces/pages/deployment-pipelines/src/subComponents/CreateEnvironmentDrawer.tsx
  • console/workspaces/pages/deployment-pipelines/src/subComponents/DeploymentPipelineTable.tsx
  • console/workspaces/pages/deployment-pipelines/src/subComponents/EnvironmentTable.tsx
  • console/workspaces/pages/deployment-pipelines/src/subComponents/PipelineChainEditor.tsx
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/cluster-workflow-templates/ballerina-buildpack-build.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/cluster-workflow-templates/dockefile-build.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/cluster-workflow-templates/gcp-buildpack-build.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-traits/bal-otel-instrumentation-trait.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-traits/instrumentation-trait-env-injection.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-traits/python-otel-instrumentation-trait.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/values.yaml
  • deployments/k8s/gvisor-runtimeclass.yaml
  • deployments/k8s/kata-runtimeclass.yaml
  • deployments/quick-start/install-helpers.sh
  • deployments/quick-start/install.sh
  • deployments/scripts/add-environment.sh
  • deployments/scripts/setup-sandbox.sh
  • deployments/setup/env.sh
  • deployments/setup/install-gvisor.sh
  • deployments/setup/install-kata.sh
  • deployments/setup/setup-gvisor-node.sh
  • deployments/setup/setup-kata-node.sh
  • deployments/setup/setup-openchoreo.sh
  • deployments/values/observability-metrics-prometheus.yaml
  • documentation/docs/administration/environment-management.mdx
  • documentation/docs/administration/isolation-tiers/gvisor.mdx
  • documentation/docs/administration/isolation-tiers/kata.mdx
  • documentation/docs/getting-started/_partials/_amp-installation.mdx
  • documentation/docs/getting-started/on-a-vm.mdx
  • documentation/docs/getting-started/on-k3d.mdx
  • documentation/docs/getting-started/on-your-environment.mdx
  • documentation/docs/getting-started/quick-start.mdx
  • documentation/sidebars.ts

Comment thread agent-manager-service/clients/openchoreosvc/client/deployments.go
Comment thread agent-manager-service/clients/openchoreosvc/client/deployments.go
Comment thread agent-manager-service/docs/api_v1_openapi.yaml
Comment thread agent-manager-service/services/agent_manager.go
Comment thread agent-manager-service/services/environment_service.go
Comment thread deployments/scripts/add-environment.sh
Comment thread deployments/setup/install-gvisor.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
deployments/scripts/add-environment.sh (1)

227-232: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Validate ISOLATION_TIER against allowed values.

The value is interpolated directly into the JSON body (line 230) without escaping or validation, unlike DISPLAY_NAME which is escaped at line 201. An invalid value (e.g. typo or special characters) would either produce invalid JSON or a confusing API error. Adding a simple allowlist check improves error clarity and prevents malformed JSON.

♻️ Proposed validation for ISOLATION_TIER
 ISOLATION_TIER="${ISOLATION_TIER:-}"
+case "$ISOLATION_TIER" in
+    ""|runc|gvisor|kata) ;;
+    *)
+        echo "❌ ISOLATION_TIER must be 'runc', 'gvisor', or 'kata' (got '${ISOLATION_TIER}')"
+        exit 1
+        ;;
+esac
 ISOLATION_TIER_FIELD=""
 if [ -n "${ISOLATION_TIER}" ]; then
🤖 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 `@deployments/scripts/add-environment.sh` around lines 227 - 232, Validate
ISOLATION_TIER against the supported isolation-tier values before constructing
ISOLATION_TIER_FIELD, rejecting empty or unrecognized values with a clear error
and nonzero exit. Only interpolate the validated value into the JSON payload,
preserving the existing optional-field behavior when ISOLATION_TIER is unset.
agent-manager-service/services/environment_service.go (1)

466-469: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wrap the ResolveNamespace error for consistency.

Other error returns in this function wrap with contextual messages (e.g., "list environments for org %s: %w"), but the ResolveNamespace error is returned bare. Wrapping it preserves the call-site context for debugging.

♻️ Proposed fix
 	orgNamespace, err := ResolveNamespace(ctx, s.ocClient)
 	if err != nil {
-		return nil, err
+		return nil, fmt.Errorf("resolve org namespace for org %s: %w", ouID, err)
 	}
🤖 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 `@agent-manager-service/services/environment_service.go` around lines 466 -
469, Update the ResolveNamespace error path in the surrounding function to wrap
the returned error with contextual information, using the function’s existing
error-wrapping style and preserving the original error via %w.
🤖 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 `@agent-manager-service/services/environment_service.go`:
- Around line 466-469: Update the ResolveNamespace error path in the surrounding
function to wrap the returned error with contextual information, using the
function’s existing error-wrapping style and preserving the original error via
%w.

In `@deployments/scripts/add-environment.sh`:
- Around line 227-232: Validate ISOLATION_TIER against the supported
isolation-tier values before constructing ISOLATION_TIER_FIELD, rejecting empty
or unrecognized values with a clear error and nonzero exit. Only interpolate the
validated value into the JSON payload, preserving the existing optional-field
behavior when ISOLATION_TIER is unset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9b56ef4-afcb-4d9e-8bdd-54d8bb98837c

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5c9af and b0e9b9b.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (23)
  • Makefile
  • agent-manager-service/clients/openchoreosvc/client/deployments.go
  • agent-manager-service/clients/openchoreosvc/client/types.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/models/build_deployment.go
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/services/environment_service.go
  • agent-manager-service/spec/model_create_environment_request.go
  • agent-manager-service/spec/model_gateway_environment_response.go
  • agent-manager-service/tests/apitestutils/mock_clients.go
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-traits/instrumentation-trait-env-injection.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml
  • deployments/helm-charts/wso2-amp-platform-resources-extension/values.yaml
  • deployments/quick-start/install-helpers.sh
  • deployments/quick-start/install.sh
  • deployments/scripts/add-environment.sh
  • deployments/setup/install-gvisor.sh
  • deployments/setup/setup-openchoreo.sh
  • documentation/docs/getting-started/_partials/_amp-installation.mdx
  • documentation/docs/getting-started/on-a-vm.mdx
  • documentation/docs/getting-started/on-k3d.mdx
  • documentation/docs/getting-started/on-your-environment.mdx
  • documentation/docs/getting-started/quick-start.mdx
💤 Files with no reviewable changes (1)
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (19)
  • deployments/quick-start/install-helpers.sh
  • deployments/helm-charts/wso2-amp-platform-resources-extension/values.yaml
  • agent-manager-service/models/build_deployment.go
  • agent-manager-service/spec/model_create_environment_request.go
  • documentation/docs/getting-started/on-a-vm.mdx
  • agent-manager-service/tests/apitestutils/mock_clients.go
  • deployments/quick-start/install.sh
  • documentation/docs/getting-started/on-k3d.mdx
  • agent-manager-service/clients/openchoreosvc/client/types.go
  • deployments/setup/install-gvisor.sh
  • documentation/docs/getting-started/_partials/_amp-installation.mdx
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-traits/instrumentation-trait-env-injection.yaml
  • deployments/setup/setup-openchoreo.sh
  • agent-manager-service/spec/model_gateway_environment_response.go
  • documentation/docs/getting-started/on-your-environment.mdx
  • deployments/helm-charts/wso2-amp-platform-resources-extension/templates/component-types/agent-api.yaml
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/clients/openchoreosvc/client/deployments.go
  • agent-manager-service/docs/api_v1_openapi.yaml


const (
ComponentTypeInternalAgentAPI ComponentType = "deployment/agent-api"
ComponentTypeInternalAgentAPI ComponentType = "proxy/agent-api"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we have to chnage the component type ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR moves platform-hosted agents from Deployments to OpenChoreo Sandboxes. After this change, the default deployment is a Sandbox managed by the Sandbox Controller instead of the Deployment Controller. Since agent-api now uses workloadType: proxy rather than deployment, the component changes from deployment/agent-api to proxy/agent-api. Because we need to render the SandboxTemplate instead of Deployment. ( This change has been discussed with OpenChoreo team and their suggestion was this)

// runtimeClassName the agent-api ComponentType should request. Empty means "omit" (default runc).
func runtimeClassForIsolationTier(tier string) string {
switch tier {
case "gvisor":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we define constants for these types ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in: 06647e2

# subPath file mounts are not supported under Kata Containers (virtiofs
# exposes them as directories), so the mount must stay subPath-free to
# work across all isolation tiers (runc/gVisor/Kata).
default: "/amp-instrumentation"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we specifically change this to /amp-instrumentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is intentional. Previously we mounted only am-instrumentation.toml into /workspace using a single-file subPath mount, but Kata doesn't support this with virtiofs. Instead, we now mount the config volume to /amp-instrumentation and reference the file using its absolute path in BAL_CONFIG_FILES. This works the same on runc, gVisor, and Kata while keeping /workspace unchanged. Tested live on a GCP VM and a harvester cluster across all three isolation tiers.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@agent-manager-service/services/agent_manager.go`:
- Around line 1778-1790: Re-run ValidateResourceRequestsWithinLimits against the
freshly fetched resource configuration immediately before each
UpdateEnvResourceConfigs attempt, including retries after a newer
resourceVersion. Ensure concurrent requests-only and limits-only updates cannot
persist an invalid combined binding, either by validating the binding being
written or serializing updates per component/environment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2b5af93e-ea07-4261-8059-184a483d34c4

📥 Commits

Reviewing files that changed from the base of the PR and between 06647e2 and b7686da.

📒 Files selected for processing (6)
  • agent-manager-service/clients/openchoreosvc/client/components.go
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/utils/utils.go
  • agent-manager-service/utils/validation_test.go
  • console/workspaces/libs/shared-component/src/components/IsolationTierIndicator/IsolationTierIndicator.tsx
  • console/workspaces/pages/deployment-pipelines/src/subComponents/CreateEnvironmentDrawer.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • console/workspaces/libs/shared-component/src/components/IsolationTierIndicator/IsolationTierIndicator.tsx
  • console/workspaces/pages/deployment-pipelines/src/subComponents/CreateEnvironmentDrawer.tsx

Comment thread agent-manager-service/services/agent_manager.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
agent-manager-service/clients/openchoreosvc/client/components.go (1)

680-697: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Merging overrides may prevent removing existing resource overrides.

By changing this to a merge operation to allow partial updates, it might now be impossible for a user to remove an existing override to restore the component default.

If the fields in req.Resources (e.g., CPU string) use omitempty, explicitly setting a field to "" to clear it will cause it to be dropped during structToMap. Consequently, mergeResourceOverrides will not see the key in the incoming map and will inadvertently preserve the old value from existingResources.

Ensure the struct uses pointer types for these fields (so explicit "" can be differentiated from an omitted field during marshaling), or provide an explicit mechanism to unset overrides.

🤖 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 `@agent-manager-service/clients/openchoreosvc/client/components.go` around
lines 680 - 697, Update the resource override request fields consumed by
structToMap and mergeResourceOverrides to preserve whether each field was
omitted or explicitly cleared. Prefer pointer types for fields such as CPU and
memory so an explicit empty string is serialized and removes the corresponding
existing override, while nil continues to preserve omitted fields; ensure the
merge behavior and validation handle the resulting unset values.
🧹 Nitpick comments (1)
agent-manager-service/tests/promote_agent_test.go (1)

89-103: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid bypassing the repository layer in tests.

As per coding guidelines, each layer must depend on the interface of the layer below, injected through constructors. Directly calling db.DB(context.Background()) relies on a global database accessor and bypasses the repository layer.

Consider injecting the required repository or database connection into the test setup to decouple it from global state and comply with the layer dependency guidelines.

🤖 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 `@agent-manager-service/tests/promote_agent_test.go` around lines 89 - 103,
Update seedReadyAgentIdentityRow to create the AgentThunderClient through the
existing repository interface instead of calling the global db.DB accessor
directly. Inject or reuse the repository in the test setup via its constructor,
then persist the binding through that repository while preserving the current
test data.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@agent-manager-service/clients/openchoreosvc/client/components.go`:
- Around line 680-697: Update the resource override request fields consumed by
structToMap and mergeResourceOverrides to preserve whether each field was
omitted or explicitly cleared. Prefer pointer types for fields such as CPU and
memory so an explicit empty string is serialized and removes the corresponding
existing override, while nil continues to preserve omitted fields; ensure the
merge behavior and validation handle the resulting unset values.

---

Nitpick comments:
In `@agent-manager-service/tests/promote_agent_test.go`:
- Around line 89-103: Update seedReadyAgentIdentityRow to create the
AgentThunderClient through the existing repository interface instead of calling
the global db.DB accessor directly. Inject or reuse the repository in the test
setup via its constructor, then persist the binding through that repository
while preserving the current test data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ce407677-c177-43fc-b47c-7fe6ca237b33

📥 Commits

Reviewing files that changed from the base of the PR and between b7686da and 8995168.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (12)
  • agent-manager-service/clients/openchoreosvc/client/components.go
  • agent-manager-service/clients/openchoreosvc/client/constants.go
  • agent-manager-service/clients/openchoreosvc/client/types.go
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/services/agent_manager.go
  • agent-manager-service/tests/promote_agent_test.go
  • agent-manager-service/utils/utils.go
  • console/workspaces/libs/shared-component/src/components/EnvironmentCard/EnvironmentCard.tsx
  • console/workspaces/libs/shared-component/src/components/index.ts
  • deployments/setup/setup-openchoreo.sh
  • documentation/docs/getting-started/on-a-vm.mdx
  • documentation/docs/getting-started/on-your-environment.mdx
🚧 Files skipped from review as they are similar to previous changes (9)
  • console/workspaces/libs/shared-component/src/components/index.ts
  • console/workspaces/libs/shared-component/src/components/EnvironmentCard/EnvironmentCard.tsx
  • documentation/docs/getting-started/on-a-vm.mdx
  • agent-manager-service/clients/openchoreosvc/client/types.go
  • deployments/setup/setup-openchoreo.sh
  • agent-manager-service/docs/api_v1_openapi.yaml
  • agent-manager-service/utils/utils.go
  • agent-manager-service/services/agent_manager.go
  • documentation/docs/getting-started/on-your-environment.mdx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants