Skip to content

Preserve source labels/annotations on v1alpha2 CRDs during migration#1072

Open
efiacor wants to merge 1 commit into
kptdev:mainfrom
Nordix:preserve_v1alpha1_labels_annos_migration
Open

Preserve source labels/annotations on v1alpha2 CRDs during migration#1072
efiacor wants to merge 1 commit into
kptdev:mainfrom
Nordix:preserve_v1alpha1_labels_annos_migration

Conversation

@efiacor

@efiacor efiacor commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Title

Preserve source labels/annotations on v1alpha2 CRDs during migration


Description

  • What changed: The repo controller's applySeedFields now carries over labels and annotations from the source PackageRevision's Kubernetes metadata when creating v1alpha2 CRDs. System-managed labels (porch.kpt.dev/repository, porch.kpt.dev/latest-revision, kpt.dev/latest-revision) are excluded.
  • Why it's needed: When users set metadata.labels or metadata.annotations on v1alpha1 PackageRevisions (for RBAC, automation, or organizational purposes), that metadata was silently lost when the repo was migrated to v1alpha2 CRDs. Fixes Migration must preserve user labels and annotations from v1alpha1 PackageRevisions #1071.
  • How it works: The seed SSA apply (which already runs on initial CRD creation for lifecycle, readinessGates, etc.) now includes source labels/annotations in its ObjectMeta. Uses the seed field manager without ForceOwnership so users and controllers can freely overwrite after migration.

Related Issue(s)


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. make reload-controllers
  2. E2E=1 go test ./test/e2e/crd/ -v --ginkgo.focus="Migration Metadata Preservation" -timeout 5m
  3. Unit tests: go test ./controllers/repositories/pkg/controllers/repository/ -run "TestSourceMetadata|TestApplySeedFieldsWithSourceMetadata" -v

Additional Notes (Optional)

  • Known issues: None
  • Further improvements: Could also filter annotations with known system prefixes (e.g. kubectl.kubernetes.io/) but keeping it minimal for now
  • Review notes: The seed apply is a single SSA Patch (no additional API call added). The sourceMetadata function is a pure helper with full unit coverage.

AI Disclosure

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

If so, please describe how:

  • Kiro to implement the fix, write unit tests, and write the e2e test.
  • The author has fully verified all code.

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
@efiacor efiacor self-assigned this Jun 24, 2026
@efiacor efiacor requested review from a team June 24, 2026 13:24
@efiacor efiacor added enhancement New feature or request go Pull requests that update go code rpkg CRD Feature or improvement to be considered for rpkg CRD impl labels Jun 24, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 24, 2026
@efiacor efiacor added bug Something isn't working and removed enhancement New feature or request rpkg CRD Feature or improvement to be considered for rpkg CRD impl labels Jun 24, 2026
@efiacor efiacor requested a review from Copilot June 24, 2026 13:25
@netlify

netlify Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit 4df8d79
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6a3bda92418f3d00082d32f1
😎 Deploy Preview https://deploy-preview-1072--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.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@sonarqubecloud

Copy link
Copy Markdown

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment thread controllers/repositories/pkg/controllers/repository/pkgrevsync.go
@dosubot dosubot Bot added the lgtm #ededed label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code lgtm #ededed size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration must preserve user labels and annotations from v1alpha1 PackageRevisions

3 participants