Skip to content

fix(v1alpha2): render migrated drafts after metadata edits - #1392

Open
efiacor wants to merge 2 commits into
kptdev:mainfrom
Nordix:drafts_migration_e2e
Open

efiacor wants to merge 2 commits into
kptdev:mainfrom
Nordix:drafts_migration_e2e

Conversation

@efiacor

@efiacor efiacor commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

fix(v1alpha2): render migrated drafts after metadata edits


Description

  • What changed:
    • PR controller: drafts with no source operation (e.g. migrated from v1alpha1) now get a render requested via the render-request annotation after a metadata sync.
    • e2e: new zero-data-loss suite for v1alpha1 Draft/Proposed migration.
    • e2e: draft migration specs moved to migration_drafts_test.go.
  • Why it's needed:
    • Metadata edits on migrated drafts reached the Kptfile but were never rendered. These drafts have no spec.source, status.creationSource or subpackage op, so the source trigger never fires for them. That left the pipeline un-run and no Rendered condition.
    • Draft migration had no content-level coverage. The existing specs only checked that the CRDs exist.
  • How it works:
    • triggerRenderIfNeeded sets the annotation when the package is already rendered, or when no source render is pending. New v1alpha2 packages are unchanged.
    • Every fixture is snapshotted via the v1alpha1 API before migration, then compared field by field after migration, repeat syncs, a v1alpha2 metadata edit, publish/approve via v1alpha2, and rollback.

Related Issue(s)

  • Closes/Fixes #

Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Tests
  • Other: ________

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

Testing Instructions (Optional)

  1. go test ./controllers/packagerevisions/pkg/...
  2. make run-in-kind-v1alpha2 (or make reload-controllers)
  3. E2E=1 go test -v ./test/e2e/crd -ginkgo.v -ginkgo.label-filter=drafts (expect 18 passed)

Additional Notes (Optional)

  • Known issues: v1alpha1 ownerReferences (e.g. PackageVariant) and user finalizers are not carried onto v1alpha2 CRDs. The v1alpha1 row keeps them, so rollback is fine. This is tracked as a pending spec.
  • Further improvements:
  • Review notes:
    • Fixtures: content, packageMetadata, readinessGates, conditions, object metadata, upstreamLock, deployment, clone, edit, nested path, DeletionProposed.
    • The invalid-workspace e2e was dropped. The v1alpha1 API rejects those names, so it could only skip. Unit tests still cover the filtering.

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:

  • Kiro helped write the fix, unit tests and e2e suite. The author has fully verified all code.

- PR controller: request render via annotation for drafts with no source
  operation (e.g. migrated from v1alpha1); the source trigger never fires
  for them, so metadata edits were synced to the Kptfile but never rendered
- e2e: add zero-data-loss suite for v1alpha1 Draft/Proposed migration
  (content, packageMetadata, readinessGates, conditions, object metadata,
  upstreamLock, deployment, clone/edit/nested/DeletionProposed fixtures,
  repeat syncs, publish/approve via v1alpha2, rollback)
- e2e: move draft migration specs to migration_drafts_test.go
- Pending spec documents that ownerReferences/finalizers are not carried
  onto v1alpha2 CRDs

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
@efiacor
efiacor requested review from a team and a balanced review from Copilot November 24, 2026 14:10
@netlify

netlify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit ba9d1d2
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6b05dbf378f0a68b29ba4bc1
😎 Deploy Preview https://deploy-preview-1392--kpt-porch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@efiacor efiacor self-assigned this Nov 24, 2026
@efiacor efiacor added bug Something isn't working rpkg CRD Feature or improvement to be considered for rpkg CRD impl labels Nov 24, 2026

Copilot AI 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.

🟡 Changes recommended

The sync helper patches an annotation instead of spec.sync.runOnceAt, allowing preservation checks to pass on stale Ready status without running or awaiting the requested syncs.

1 open issue
What changed in this PR

This PR fixes rendering after metadata edits on migrated v1alpha1 drafts, which lack the source operation normally used to trigger rendering in v1alpha2.

Changes:

  • Requests rendering through an annotation when no source render is pending.
  • Adds unit coverage for source-backed and source-less packages.
  • Moves draft migration tests into a dedicated file and adds content-preservation coverage across migration, metadata edits, lifecycle changes, and rollback.
File Description
test/​e2e/​crd/​migration_test.go Adds repository options and relocates draft migration specs.
test/​e2e/​crd/​migration_drafts_test.go Houses draft migration tests and adds data-preservation scenarios.
controllers/​packagerevisions/​pkg/​controllers/​packagerevision/​metadata.go Requests rendering for packages without a pending source operation.
controllers/​packagerevisions/​pkg/​controllers/​packagerevision/​metadata_test.go Tests render requests for migrated drafts and preserves source-trigger expectations.

Review effort: Balanced

Comment thread test/e2e/crd/migration_drafts_test.go Resolved
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

bug Something isn't working rpkg CRD Feature or improvement to be considered for rpkg CRD impl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants