Skip to content

Add PrrSizeBytes to v1alpha2 PackageRevision status#977

Open
efiacor wants to merge 7 commits into
kptdev:mainfrom
Nordix:prr_size_v1alpha2
Open

Add PrrSizeBytes to v1alpha2 PackageRevision status#977
efiacor wants to merge 7 commits into
kptdev:mainfrom
Nordix:prr_size_v1alpha2

Conversation

@efiacor
Copy link
Copy Markdown
Collaborator

@efiacor efiacor commented May 8, 2026

Description

  • What changed: PR controller and repo controller now calculate and set status.prrSizeBytes on v1alpha2 CRDs
  • Why: Users need to see package resource size without fetching content — enables client-side filtering for oversized packages
  • How: Both controllers calculate size from the in-memory resource map (already loaded) and include it in their SSA status patches

Related Issue(s)

Type of Change

  • New feature
  • Tests

Checklist

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

Testing Instructions

  1. Deploy porch with this change
  2. Create a v1alpha2 package (init, clone, or push)
  3. kubectl get packagerevision <name> -o yaml — verify status.prrSizeBytes > 0
  4. Push new content — verify size increases

Additional Notes

AI Disclosure

[x] I have used AI in the creation of this PR.

  • Kiro to implement the feature, write unit tests, and extend E2E tests
  • The author has fully verified all code

Both PR controller and repo controller now calculate and set
status.prrSizeBytes on v1alpha2 CRDs from the in-memory resource map.

Covers init, clone, push/render, and repo discovery paths.
E2E tests use relative assertions (> 0, > initial) for resilience.

Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 8, 2026

Deploy Preview for porch ready!

Name Link
🔨 Latest commit 0595e5a
🔍 Latest deploy log https://app.netlify.com/projects/porch/deploys/6a03070d5bc1440008b7319e
😎 Deploy Preview https://deploy-preview-977--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 May 8, 2026
@efiacor efiacor added the enhancement New feature or request label May 8, 2026
@efiacor efiacor requested a review from JamesMcDermott May 8, 2026 16:02
@sonarqubecloud
Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings May 13, 2026 05:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new status.prrSizeBytes field to the porch.kpt.dev/v1alpha2 PackageRevision API so clients can see total package resource content size without fetching PRR contents, and wires both the package revision controller and repository sync controller to populate it.

Changes:

  • Added PrrSizeBytes to the v1alpha2 PackageRevisionStatus type and CRD schema.
  • Populated status.prrSizeBytes from package resources in the package revision controller and repository controller sync.
  • Added unit tests and extended E2E coverage to assert PrrSizeBytes is populated and updates after content changes.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/e2e/crd/repository_test.go Asserts discovered v1alpha2 package revisions have status.prrSizeBytes populated.
test/e2e/crd/push_test.go Records initial size and asserts PrrSizeBytes increases after pushing content.
test/e2e/crd/init_test.go Asserts PrrSizeBytes is populated after init.
test/e2e/crd/clone_test.go Asserts PrrSizeBytes is populated after clone.
pkg/repository/util.go Introduces CalculateResourcesSize helper to sum resource content sizes.
pkg/repository/util_test.go Adds unit tests for CalculateResourcesSize.
controllers/repositories/pkg/controllers/repository/pkgrevsync.go Computes and syncs PrrSizeBytes on repo-discovered v1alpha2 PackageRevisions.
controllers/repositories/pkg/controllers/repository/pkgrevsync_test.go Adds tests validating size calculation and up-to-date checks include PrrSizeBytes.
controllers/packagerevisions/pkg/controllers/packagerevision/status.go Computes PrrSizeBytes during PR controller status updates.
controllers/packagerevisions/pkg/controllers/packagerevision/status_test.go Extends status unit tests to assert PrrSizeBytes is set.
controllers/packagerevisions/pkg/controllers/packagerevision/packagerevision_controller_test.go Updates mock defaults to provide resource contents for new status calculation.
api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml Adds CRD schema for status.prrSizeBytes.
api/porch/v1alpha2/packagerevision_types.go Adds PrrSizeBytes field to PackageRevisionStatus.

Comment thread controllers/repositories/pkg/controllers/repository/pkgrevsync.go
Copilot AI review requested due to automatic review settings May 15, 2026 13:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 13 out of 13 changed files in this pull request and generated no new comments.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spike: Record pkg (PRR) size on CRD

3 participants