Skip to content

Commit 6d7d257

Browse files
jmhbhEItanya
andauthored
feat: substrate support for BYO and python runtimes for SandboxAgent CR (kagent-dev#2043)
- Implements substrate support for BYO typed agents and the python runtime for declarative agents. - Fixes an existing issue where on config changes the previous golden snapshot was still being served. We now correctly serve the newest golden snapshot with the updated config. - Fixes an issue where golden snapshot building could use stale config. Substrate caches config values based on the `KAGENT_CONFIG_JSON` secret key ref name which is static. This can result in stale config being fetched. The secret key ref name now contains the config hash as a suffix so different configs now have a unique cache key. **Testing** - Tested locally in a kind cluster. Below is an example conversation with a declarative sandbox agent using the python runtime where I switch between model providers to test config rollout. <img width="1028" height="700" alt="Screenshot 2026-06-22 at 4 27 29 PM" src="https://github.com/user-attachments/assets/40b0c0f7-aff1-4752-b878-b9037f94c3a3" /> --------- Signed-off-by: JM Huibonhoa <jm.huibonhoa@solo.io> Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io>
1 parent 169ce1f commit 6d7d257

45 files changed

Lines changed: 1679 additions & 312 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ ACP_SANDBOX_OPENCLAW_IMAGE_NAME ?= acp-sandbox-openclaw
6363
CONTROLLER_IMAGE_TAG ?= $(VERSION)
6464
UI_IMAGE_TAG ?= $(VERSION)
6565
APP_IMAGE_TAG ?= $(VERSION)
66+
APP_FULL_IMAGE_TAG ?= $(VERSION)-full
6667
KAGENT_ADK_IMAGE_TAG ?= $(VERSION)
68+
KAGENT_ADK_FULL_IMAGE_TAG ?= $(VERSION)-full
6769
GOLANG_ADK_IMAGE_TAG ?= $(VERSION)
6870
GOLANG_ADK_FULL_IMAGE_TAG ?= $(VERSION)-full
6971
SKILLS_INIT_IMAGE_TAG ?= $(VERSION)
7072
ACP_SANDBOX_IMAGE_TAG ?= $(VERSION)
7173
CONTROLLER_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(CONTROLLER_IMAGE_NAME):$(CONTROLLER_IMAGE_TAG)
7274
UI_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(UI_IMAGE_NAME):$(UI_IMAGE_TAG)
7375
APP_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_IMAGE_NAME):$(APP_IMAGE_TAG)
76+
APP_FULL_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_IMAGE_NAME):$(APP_FULL_IMAGE_TAG)
7477
KAGENT_ADK_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(KAGENT_ADK_IMAGE_NAME):$(KAGENT_ADK_IMAGE_TAG)
78+
KAGENT_ADK_FULL_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(KAGENT_ADK_IMAGE_NAME):$(KAGENT_ADK_FULL_IMAGE_TAG)
7579
GOLANG_ADK_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(GOLANG_ADK_IMAGE_NAME):$(GOLANG_ADK_IMAGE_TAG)
7680
GOLANG_ADK_FULL_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(GOLANG_ADK_IMAGE_NAME):$(GOLANG_ADK_FULL_IMAGE_TAG)
7781
SKILLS_INIT_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(SKILLS_INIT_IMAGE_NAME):$(SKILLS_INIT_IMAGE_TAG)
@@ -208,12 +212,14 @@ build-all: buildx-create
208212

209213
.PHONY: build
210214
build: ## Build and push all component images
211-
build: buildx-create build-ui build-skills-init build-golang-adk build-golang-adk-full build-app build-controller
215+
build: buildx-create build-ui build-skills-init build-golang-adk build-golang-adk-full build-app build-app-full build-controller
212216
@echo "Build completed successfully."
213217
@echo "Controller Image: $(CONTROLLER_IMG)"
214218
@echo "UI Image: $(UI_IMG)"
215219
@echo "App Image: $(APP_IMG)"
220+
@echo "App Full Image: $(APP_FULL_IMG)"
216221
@echo "Kagent ADK Image: $(KAGENT_ADK_IMG)"
222+
@echo "Kagent ADK Full Image: $(KAGENT_ADK_FULL_IMG)"
217223
@echo "Golang ADK Image: $(GOLANG_ADK_IMG)"
218224
@echo "Golang ADK Full Image: $(GOLANG_ADK_FULL_IMG)"
219225
@echo "Skills Init Image: $(SKILLS_INIT_IMG)"
@@ -241,7 +247,9 @@ build-img-versions: ## Print the fully-qualified image tags for all components
241247
@echo controller=$(CONTROLLER_IMG)
242248
@echo ui=$(UI_IMG)
243249
@echo app=$(APP_IMG)
250+
@echo app-full=$(APP_FULL_IMG)
244251
@echo kagent-adk=$(KAGENT_ADK_IMG)
252+
@echo kagent-adk-full=$(KAGENT_ADK_FULL_IMG)
245253
@echo golang-adk=$(GOLANG_ADK_IMG)
246254
@echo golang-adk-full=$(GOLANG_ADK_FULL_IMG)
247255
@echo skills-init=$(SKILLS_INIT_IMG)
@@ -256,10 +264,11 @@ controller-manifests: ## Regenerate CRD manifests and copy them into the Helm ch
256264

257265
.PHONY: build-controller
258266
build-controller: ## Build and push the controller image (embeds agent runtime + acp-sandbox digests via scripts/controller-digest-ldflags.sh)
259-
build-controller: buildx-create controller-manifests build-app build-golang-adk build-golang-adk-full build-acp-sandbox-openclaw build-acp-sandbox-hermes
267+
build-controller: buildx-create controller-manifests build-app build-app-full build-golang-adk build-golang-adk-full build-acp-sandbox-openclaw build-acp-sandbox-hermes
260268
@set -e; \
261269
DIGEST_LDFLAGS=$$(CONTAINER_RUNTIME=$(CONTAINER_RUNTIME) \
262270
APP_IMG=$(APP_IMG) \
271+
APP_FULL_IMG=$(APP_FULL_IMG) \
263272
GOLANG_ADK_IMG=$(GOLANG_ADK_IMG) \
264273
GOLANG_ADK_FULL_IMG=$(GOLANG_ADK_FULL_IMG) \
265274
ACP_SANDBOX_OPENCLAW_IMG=$(ACP_SANDBOX_OPENCLAW_IMG) \
@@ -284,11 +293,23 @@ build-kagent-adk: buildx-create
284293
$(DOCKER_PUSH) $(KAGENT_ADK_IMG)
285294

286295
.PHONY: build-app
287-
build-app: ## Build and push the app image (depends on kagent-adk)
296+
build-app: ## Build and push the app image (distroless slim; depends on kagent-adk)
288297
build-app: buildx-create build-kagent-adk
289298
$(DOCKER_BUILDER) $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) --build-arg KAGENT_ADK_VERSION=$(KAGENT_ADK_IMAGE_TAG) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) -t $(APP_IMG) -f python/Dockerfile.app ./python
290299
$(DOCKER_PUSH) $(APP_IMG)
291300

301+
.PHONY: build-kagent-adk-full
302+
build-kagent-adk-full: ## Build and push the full Python kagent ADK image (includes sandbox runtime)
303+
build-kagent-adk-full: buildx-create
304+
$(DOCKER_BUILDER) $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) -t $(KAGENT_ADK_FULL_IMG) -f python/Dockerfile.full ./python
305+
$(DOCKER_PUSH) $(KAGENT_ADK_FULL_IMG)
306+
307+
.PHONY: build-app-full
308+
build-app-full: ## Build and push the full app image (sandbox runtime; depends on kagent-adk-full)
309+
build-app-full: buildx-create build-kagent-adk-full
310+
$(DOCKER_BUILDER) $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) --build-arg KAGENT_ADK_VERSION=$(KAGENT_ADK_FULL_IMAGE_TAG) --build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) -t $(APP_FULL_IMG) -f python/Dockerfile.app ./python
311+
$(DOCKER_PUSH) $(APP_FULL_IMG)
312+
292313
.PHONY: build-golang-adk
293314
build-golang-adk: ## Build and push the Go ADK image
294315
build-golang-adk: buildx-create
@@ -342,8 +363,8 @@ lint: ## Run linters for Go and Python
342363
make -C python lint
343364

344365
.PHONY: push-test-agent
345-
push-test-agent: buildx-create build-kagent-adk ## Build and push E2E test agent images to the local registry
346-
echo "Building FROM DOCKER_REGISTRY=$(DOCKER_REGISTRY)/$(DOCKER_REPO)/kagent-adk:$(VERSION)"
366+
push-test-agent: buildx-create build-kagent-adk build-kagent-adk-full ## Build and push E2E test agent images to the local registry
367+
echo "Building FROM DOCKER_REGISTRY=$(DOCKER_REGISTRY)/$(DOCKER_REPO)/kagent-adk:$(VERSION)-full"
347368
$(DOCKER_BUILDER) $(DOCKER_BUILD_ARGS) $(TOOLS_IMAGE_BUILD_ARGS) -t $(DOCKER_REGISTRY)/kebab:latest -f go/core/test/e2e/agents/kebab/Dockerfile ./go/core/test/e2e/agents/kebab
348369
$(DOCKER_PUSH) $(DOCKER_REGISTRY)/kebab:latest
349370
kubectl apply --namespace kagent --context kind-$(KIND_CLUSTER_NAME) -f go/core/test/e2e/agents/kebab/agent.yaml

go/api/config/crd/bases/kagent.dev_sandboxagents.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11334,8 +11334,6 @@ spec:
1133411334
x-kubernetes-validations:
1133511335
- message: spec.skills is not supported for sandbox agents
1133611336
rule: '!has(self.skills)'
11337-
- message: BYO agents are not supported for sandbox agents
11338-
rule: '!has(self.type) || self.type != ''BYO'''
1133911337
- message: type must be specified
1134011338
rule: has(self.type)
1134111339
- message: type must be either Declarative or BYO

go/api/v1alpha2/agent_runtime_test.go

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,36 @@ import (
66
"github.com/stretchr/testify/require"
77
)
88

9-
func TestEffectiveDeclarativeRuntimeForAgent(t *testing.T) {
10-
substrateSpec := AgentSpec{
11-
Type: AgentType_Declarative,
12-
Declarative: &DeclarativeAgentSpec{
13-
Runtime: DeclarativeRuntime_Python,
9+
func TestEffectiveDeclarativeRuntime(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
spec *AgentSpec
13+
want DeclarativeRuntime
14+
}{
15+
{
16+
name: "nil spec defaults to Python",
17+
spec: nil,
18+
want: DeclarativeRuntime_Python,
19+
},
20+
{
21+
name: "unset runtime defaults to Python",
22+
spec: &AgentSpec{Type: AgentType_Declarative, Declarative: &DeclarativeAgentSpec{}},
23+
want: DeclarativeRuntime_Python,
24+
},
25+
{
26+
name: "explicit Python runtime",
27+
spec: &AgentSpec{Type: AgentType_Declarative, Declarative: &DeclarativeAgentSpec{Runtime: DeclarativeRuntime_Python}},
28+
want: DeclarativeRuntime_Python,
29+
},
30+
{
31+
name: "explicit Go runtime is honored",
32+
spec: &AgentSpec{Type: AgentType_Declarative, Declarative: &DeclarativeAgentSpec{Runtime: DeclarativeRuntime_Go}},
33+
want: DeclarativeRuntime_Go,
1434
},
1535
}
16-
17-
t.Run("regular Agent keeps configured runtime", func(t *testing.T) {
18-
agent := &Agent{Spec: substrateSpec}
19-
require.Equal(t, DeclarativeRuntime_Python, EffectiveDeclarativeRuntimeForAgent(agent))
20-
})
21-
22-
t.Run("SandboxAgent uses Go", func(t *testing.T) {
23-
sa := &SandboxAgent{Spec: SandboxAgentSpec{AgentSpec: substrateSpec}}
24-
require.Equal(t, DeclarativeRuntime_Go, EffectiveDeclarativeRuntimeForAgent(sa))
25-
})
26-
27-
t.Run("regular Agent honors Go runtime", func(t *testing.T) {
28-
agent := &Agent{Spec: AgentSpec{
29-
Type: AgentType_Declarative,
30-
Declarative: &DeclarativeAgentSpec{
31-
Runtime: DeclarativeRuntime_Go,
32-
},
33-
}}
34-
require.Equal(t, DeclarativeRuntime_Go, EffectiveDeclarativeRuntimeForAgent(agent))
35-
})
36+
for _, tt := range tests {
37+
t.Run(tt.name, func(t *testing.T) {
38+
require.Equal(t, tt.want, EffectiveDeclarativeRuntime(tt.spec))
39+
})
40+
}
3641
}
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package v1alpha2
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"strings"
6+
)
47

58
const (
6-
substrateSandboxSkillsUnsupportedMsg = "spec.skills is not supported for sandbox agents"
7-
substrateSandboxPythonRuntimeUnsupportedMsg = "spec.declarative.runtime must be \"go\" for sandbox agents"
8-
substrateSandboxBYOUnsupportedMsg = "BYO agents are not supported for sandbox agents"
9+
substrateSandboxSkillsUnsupportedMsg = "spec.skills is not supported for sandbox agents"
10+
substrateSandboxBYOMissingCommandMsg = "BYO agents on substrate must set spec.byo.deployment.cmd (substrate does not fall back to the image entrypoint)"
911
)
1012

1113
// AgentSpecHasSkills reports whether the spec configures any skill sources.
@@ -18,23 +20,25 @@ func AgentSpecHasSkills(spec *AgentSpec) bool {
1820
}
1921

2022
// ValidateSubstrateSandboxAgentSpec rejects sandbox agent configurations that kagent
21-
// does not support on Agent Substrate (for example declarative skills or BYO agents).
23+
// does not support on Agent Substrate (for example declarative skills). Declarative
24+
// Python/Go and BYO (Go/Python) agents are supported; BYO agents must provide an explicit
25+
// command because substrate copies the container Command verbatim with no image-entrypoint
26+
// fallback.
2227
func ValidateSubstrateSandboxAgentSpec(agent *SandboxAgent) error {
2328
if agent == nil {
2429
return nil
2530
}
2631
spec := agent.GetAgentSpec()
27-
if spec.Type == AgentType_BYO {
28-
return fmt.Errorf("%s", substrateSandboxBYOUnsupportedMsg)
29-
}
3032
if AgentSpecHasSkills(spec) {
3133
return fmt.Errorf("%s", substrateSandboxSkillsUnsupportedMsg)
3234
}
33-
if spec.Type == AgentType_Declarative &&
34-
spec.Declarative != nil &&
35-
spec.Declarative.Runtime != "" &&
36-
spec.Declarative.Runtime != DeclarativeRuntime_Go {
37-
return fmt.Errorf("%s", substrateSandboxPythonRuntimeUnsupportedMsg)
35+
if spec.Type == AgentType_BYO {
36+
dep := spec.BYO
37+
// Trim so a whitespace-only cmd is rejected like an empty one (substrate would treat it
38+
// as no command, and the UI trims before validating — keep backend/UI aligned).
39+
if dep == nil || dep.Deployment == nil || dep.Deployment.Cmd == nil || strings.TrimSpace(*dep.Deployment.Cmd) == "" {
40+
return fmt.Errorf("%s", substrateSandboxBYOMissingCommandMsg)
41+
}
3842
}
3943
return nil
4044
}

go/api/v1alpha2/agent_spec_validation_test.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestValidateSubstrateSandboxAgentSpec(t *testing.T) {
2525
require.Contains(t, err.Error(), substrateSandboxSkillsUnsupportedMsg)
2626
})
2727

28-
t.Run("rejects python runtime", func(t *testing.T) {
28+
t.Run("allows python runtime", func(t *testing.T) {
2929
agent := &SandboxAgent{
3030
Spec: SandboxAgentSpec{
3131
AgentSpec: AgentSpec{
@@ -36,23 +36,49 @@ func TestValidateSubstrateSandboxAgentSpec(t *testing.T) {
3636
},
3737
},
3838
}
39+
require.NoError(t, ValidateSubstrateSandboxAgentSpec(agent))
40+
})
41+
42+
t.Run("rejects BYO agents without an explicit command", func(t *testing.T) {
43+
agent := &SandboxAgent{
44+
Spec: SandboxAgentSpec{
45+
AgentSpec: AgentSpec{
46+
Type: AgentType_BYO,
47+
BYO: &BYOAgentSpec{Deployment: &ByoDeploymentSpec{Image: "example/agent:latest"}},
48+
},
49+
},
50+
}
3951
err := ValidateSubstrateSandboxAgentSpec(agent)
4052
require.Error(t, err)
41-
require.Contains(t, err.Error(), substrateSandboxPythonRuntimeUnsupportedMsg)
53+
require.Contains(t, err.Error(), substrateSandboxBYOMissingCommandMsg)
4254
})
4355

44-
t.Run("rejects BYO agents", func(t *testing.T) {
56+
t.Run("rejects BYO agents with a whitespace-only command", func(t *testing.T) {
57+
cmd := " "
4558
agent := &SandboxAgent{
4659
Spec: SandboxAgentSpec{
4760
AgentSpec: AgentSpec{
4861
Type: AgentType_BYO,
49-
BYO: &BYOAgentSpec{},
62+
BYO: &BYOAgentSpec{Deployment: &ByoDeploymentSpec{Image: "example/agent:latest", Cmd: &cmd}},
5063
},
5164
},
5265
}
5366
err := ValidateSubstrateSandboxAgentSpec(agent)
5467
require.Error(t, err)
55-
require.Contains(t, err.Error(), substrateSandboxBYOUnsupportedMsg)
68+
require.Contains(t, err.Error(), substrateSandboxBYOMissingCommandMsg)
69+
})
70+
71+
t.Run("allows BYO agents with an explicit command", func(t *testing.T) {
72+
cmd := "/app"
73+
agent := &SandboxAgent{
74+
Spec: SandboxAgentSpec{
75+
AgentSpec: AgentSpec{
76+
Type: AgentType_BYO,
77+
BYO: &BYOAgentSpec{Deployment: &ByoDeploymentSpec{Image: "example/agent:latest", Cmd: &cmd}},
78+
},
79+
},
80+
}
81+
require.NoError(t, ValidateSubstrateSandboxAgentSpec(agent))
5682
})
5783

5884
t.Run("allows go runtime", func(t *testing.T) {

go/api/v1alpha2/agent_types.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ type SandboxConfig struct {
258258
}
259259

260260
// EffectiveDeclarativeRuntime returns the ADK runtime from spec fields (defaults to Python when not set).
261+
// All agents (including substrate SandboxAgents) honor spec.declarative.runtime.
261262
func EffectiveDeclarativeRuntime(spec *AgentSpec) DeclarativeRuntime {
262263
if spec == nil {
263264
return DeclarativeRuntime_Python
@@ -269,18 +270,6 @@ func EffectiveDeclarativeRuntime(spec *AgentSpec) DeclarativeRuntime {
269270
return runtime
270271
}
271272

272-
// EffectiveDeclarativeRuntimeForAgent returns the runtime for a reconciled agent object.
273-
// SandboxAgents always use Go; regular Agents honor spec.declarative.runtime.
274-
func EffectiveDeclarativeRuntimeForAgent(agent AgentObject) DeclarativeRuntime {
275-
spec := agent.GetAgentSpec()
276-
if agent.GetWorkloadMode() == WorkloadModeSandbox &&
277-
spec != nil &&
278-
spec.Type == AgentType_Declarative {
279-
return DeclarativeRuntime_Go
280-
}
281-
return EffectiveDeclarativeRuntime(spec)
282-
}
283-
284273
// NetworkConfig configures outbound network access for sandboxed execution paths.
285274
type NetworkConfig struct {
286275
// AllowedDomains lists the domains that sandboxed execution may contact.

go/api/v1alpha2/sandboxagent_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type SandboxAgent struct {
3838
}
3939

4040
// +kubebuilder:validation:XValidation:rule="!has(self.skills)",message="spec.skills is not supported for sandbox agents"
41-
// +kubebuilder:validation:XValidation:rule="!has(self.type) || self.type != 'BYO'",message="BYO agents are not supported for sandbox agents"
4241
type SandboxAgentSpec struct {
4342
AgentSpec `json:",inline"`
4443

go/core/internal/controller/sandboxagent_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (r *SandboxAgentController) Reconcile(ctx context.Context, req ctrl.Request
7979
return ctrl.Result{}, fmt.Errorf("get SandboxAgent: %w", err)
8080
}
8181

82-
if r.SubstrateLifecycle != nil {
82+
if r.substrateConfigured() {
8383
if res, err := r.reconcileSubstrateSandboxAgent(ctx, &sa); err != nil || !res.IsZero() {
8484
return res, err
8585
}
@@ -108,7 +108,7 @@ func (r *SandboxAgentController) SetupWithManager(mgr ctrl.Manager) error {
108108
if err != nil {
109109
return err
110110
}
111-
if r.SubstrateLifecycle != nil {
111+
if r.substrateConfigured() {
112112
build = build.Watches(
113113
&atev1alpha1.ActorTemplate{},
114114
handler.EnqueueRequestsFromMapFunc(r.enqueueSandboxAgentForSubstrateResource),

go/core/internal/controller/sandboxagent_substrate.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ import (
1616

1717
const sandboxAgentSubstrateFinalizer = "kagent.dev/sandbox-agent-substrate-cleanup"
1818

19+
// substrateConfigured reports whether the substrate backend is wired. The lifecycle and actor
20+
// backend are constructed together (only when an ate-api endpoint is set), so they are
21+
// all-or-nothing; gating once here lets the substrate reconcile path and its helpers assume both
22+
// are present rather than nil-checking each dependency at every call site.
23+
func (r *SandboxAgentController) substrateConfigured() bool {
24+
return r.SubstrateLifecycle != nil && r.SubstrateActorBackend != nil
25+
}
26+
27+
// reconcileSubstrateSandboxAgent is only reached when substrateConfigured() is true (see
28+
// Reconcile), so SubstrateLifecycle and SubstrateActorBackend are guaranteed non-nil here and in
29+
// the helpers it calls.
1930
func (r *SandboxAgentController) reconcileSubstrateSandboxAgent(ctx context.Context, sa *v1alpha2.SandboxAgent) (ctrl.Result, error) {
20-
if r.SubstrateLifecycle == nil {
21-
return ctrl.Result{}, fmt.Errorf("substrate sandbox backend is not configured")
22-
}
2331
if !sa.DeletionTimestamp.IsZero() {
2432
return r.reconcileSubstrateSandboxAgentDelete(ctx, sa)
2533
}
@@ -29,6 +37,7 @@ func (r *SandboxAgentController) reconcileSubstrateSandboxAgent(ctx context.Cont
2937
}
3038
return ctrl.Result{Requeue: true}, nil
3139
}
40+
3241
return ctrl.Result{}, nil
3342
}
3443

@@ -44,24 +53,16 @@ func (r *SandboxAgentController) reconcileSubstrateSandboxAgentDelete(ctx contex
4453
return r.removeSubstrateSandboxAgentFinalizer(ctx, sa)
4554
}
4655

47-
if r.SubstrateActorBackend != nil {
48-
done, err := r.SubstrateActorBackend.DeleteAllSandboxAgentActors(ctx, sa)
49-
if err != nil {
50-
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, err
51-
}
52-
if !done {
53-
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, nil
54-
}
56+
if done, err := r.SubstrateActorBackend.DeleteAllSandboxAgentActors(ctx, sa); err != nil {
57+
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, err
58+
} else if !done {
59+
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, nil
5560
}
5661

57-
if r.SubstrateLifecycle != nil {
58-
done, err := r.SubstrateLifecycle.CleanupSandboxAgentTemplate(ctx, sa)
59-
if err != nil {
60-
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, err
61-
}
62-
if !done {
63-
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, nil
64-
}
62+
if done, err := r.SubstrateLifecycle.CleanupSandboxAgentTemplate(ctx, sa); err != nil {
63+
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, err
64+
} else if !done {
65+
return ctrl.Result{RequeueAfter: agentHarnessNotReadyRequeue}, nil
6566
}
6667

6768
return r.removeSubstrateSandboxAgentFinalizer(ctx, sa)

0 commit comments

Comments
 (0)