Skip to content

Fix: register oam/v1alpha1 types on manager scheme for workflowRef#231

Merged
briankane merged 1 commit into
kubevela:mainfrom
vishal210893:fix/register-oam-workflow-scheme
Jun 24, 2026
Merged

Fix: register oam/v1alpha1 types on manager scheme for workflowRef#231
briankane merged 1 commit into
kubevela:mainfrom
vishal210893:fix/register-oam-workflow-scheme

Conversation

@vishal210893

@vishal210893 vishal210893 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #230

WorkflowRuns that use spec.workflowRef are rejected by the validating webhook with:

field "spec.workflowRef": Invalid value error encountered, failed to get workflow ref:
no kind is registered for the type v1alpha1.Workflow in scheme "pkg/runtime/scheme.go:100"

Problem. The standalone Workflow type was moved to github.com/kubevela/pkg/apis/oam/v1alpha1 (pkg bump to v1.10.0). pkg/generator/generator.go and pkg/webhook/v1alpha1/workflowrun/validation.go resolve workflowRef via oamv1alpha1.Workflow, but oamv1alpha1.AddToScheme was never wired into the manager scheme in cmd/main.go (only clientgoscheme, the local v1alpha1, and conditionally kube-trigger are registered). The moved package registers itself into the global k8sscheme.Scheme, but the manager builds its own runtime.NewScheme(), so the type stays unknown — and client.Get(&oamv1alpha1.Workflow{}) fails in scheme.ObjectKinds. This affects both the webhook and the reconcile path, since both call generator.GenerateWorkflowInstance.

Solution. Register the moved package on the manager scheme:

utilruntime.Must(oamv1alpha1.AddToScheme(scheme))

oamv1alpha1 shares the GroupVersion core.oam.dev/v1alpha1 with the local package and registers complementary kinds (Definition, Workflow, WorkflowList) with no overlap against the local WorkflowRun, so co-registration is safe.

Key files

  • cmd/main.go — register oamv1alpha1 on the manager scheme.
  • e2e/ — register oamv1alpha1 in the suite scheme; new e2e spec covering workflowRef; two test-data manifests (a Workflow template + a WorkflowRun referencing it).

Breaking changes: none.

How has this code been tested

  • New e2e spec "Test the workflow run that references a Workflow template via workflowRef" creates a Workflow template and a WorkflowRun that references it, asserting the run reaches succeeded. Full suite passes locally against a k3d cluster (go test -v ./e2e -run TestE2e → 3/3 specs).
  • Existing unit/integration tests pass; go vet ./... and gofmt clean.
  • Manually verified on a local cluster: applying a WorkflowRun with workflowRef is now admitted and runs to completion.

Special notes for your reviewer

The reason this regression slipped past CI: existing webhook tests only exercise the inline workflowSpec branch of ValidateWorkflow, so the workflowRef Get path had no coverage. The added e2e spec closes that gap by running against the real manager scheme.


Summary by cubic

Fixes webhook and reconcile failures when a WorkflowRun uses spec.workflowRef by registering github.com/kubevela/pkg/apis/oam/v1alpha1 types on the manager scheme. WorkflowRefs are now admitted and run to completion (fixes #230).

  • Bug Fixes
    • Register oamv1alpha1.AddToScheme in cmd/main.go and the e2e suite.
    • Add an e2e test with sample manifests to validate workflowRef resolution.
    • No breaking changes.

Written for commit 84d7e1f. Summary will update on new commits.

Review in cubic

The standalone Workflow type was moved to
github.com/kubevela/pkg/apis/oam/v1alpha1, but oamv1alpha1.AddToScheme
was never wired into the manager scheme. Resolving a WorkflowRun's
spec.workflowRef -- both the validating webhook and the reconcile path
call generator.GenerateWorkflowInstance -- failed with "no kind is
registered for the type v1alpha1.Workflow".

Register oamv1alpha1 on the manager scheme in cmd/main.go, and add an
e2e case that creates a Workflow template and a WorkflowRun referencing
it via workflowRef so this path is covered.

Signed-off-by: vishal210893 <vishal210893@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 5 files

Re-trigger cubic

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.77%. Comparing base (d7db9c4) to head (84d7e1f).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #231      +/-   ##
==========================================
+ Coverage   62.49%   67.77%   +5.28%     
==========================================
  Files          62       65       +3     
  Lines        4415     5409     +994     
==========================================
+ Hits         2759     3666     +907     
- Misses       1324     1355      +31     
- Partials      332      388      +56     
Flag Coverage Δ
e2etests 21.52% <ø> (?)
unit-test 61.61% <100.00%> (-0.88%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@briankane briankane merged commit cf19c9f into kubevela:main Jun 24, 2026
20 checks passed
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.

WorkflowRun with spec.workflowRef rejected since v0.6.3: "no kind is registered for the type v1alpha1.Workflow in scheme"

2 participants