konveyor / konveyor/agentic-controller

:bug: AgentWorkflowRun status patch races with child AgentRun phase initialization

Open
#239 0 comments 0 reactions 0 assignees View on GitHub
bug kind/bug stream/controller
Dominant language
Go
Stars
2
Forks
12
Avg merge
2d 5h
Merged PRs (30d)
41

Description

## Summary

`AgentWorkflowRunReconciler` can observe a newly created child `AgentRun` before the `AgentRun` controller initializes `status.phase`. The workflow-run controller mirrors that empty phase into `AgentWorkflowRun.status.stages[].phase`, and the API server rejects the status update because the CRD phase field only permits `Pending`, `Running`, `Succeeded`, or `Failed`.

## Reproduction

```sh
KUBEBUILDER_ASSETS="$(pwd)/$(./bin/setup-envtest use 1.36 -p path --bin-dir ./bin)" \
GOCACHE=/tmp/agentic-controller-gocache \
go test ./internal/controller
```

## Observed error

```
status.stages[0].phase: Unsupported value: "":
supported values: "Pending", "Running", "Succeeded", "Failed"
```

The failure is transient and occurs during reconciliation after the child `AgentRun` is created. It can cause the workflow-run status patch to fail and delay or disrupt status propagation.

## Root cause

The workflow-run reconciler unconditionally copied:

``
go
stageStatus.Phase = agentRun.Status.Phase
```

When the child `AgentRun` had not yet initialized its phase, this wrote an invalid empty value to the parent status.

## Proposed fix

Only mirror the child phase when it is non-empty, preserving the stage's existing `Pending` value during the initialization window:

``
go
if agentRun.Status.Phase != "" {
stageStatus.Phase = agentRun.Status.Phase
}
```

Add or retain an envtest regression covering the newly-created-child timing window. A local candidate guard and snapshot-related regression test are currently being developed alongside this issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in the AgentWorkflowRunReconciler under internal/controller and run the provided envtest command to reproduce the newly-created-child timing window. Inspect the existing status propagation coverage and add or update the regression so status updates remain valid while the child phase is uninitialized; done means the test passes without an unsupported empty phase.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.