Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions api/porch/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,22 @@ type PackageRevisionStatus struct {
// UpstreamLock identifies the upstream data for this package.
UpstreamLock *Locator `json:"upstreamLock,omitempty"`

// SelfLock identifies the location of the current package's data
// SelfLock identifies the location of the current package's data.
SelfLock *Locator `json:"selfLock,omitempty"`

// PublishedBy is the identity of the user who approved the packagerevision.
// PublishedBy is the identity of the user who approved the package revision.
PublishedBy string `json:"publishedBy,omitempty"`

// PublishedAt is the time when the packagerevision were approved.
// PublishedAt is the time when the package revision was approved.
PublishedAt metav1.Time `json:"publishTimestamp,omitempty"`

// Deployment is true if this is a deployment package (in a deployment repository).
Deployment bool `json:"deployment,omitempty"`

Conditions []Condition `json:"conditions,omitempty"`

// ResourcesSizeBytes is the total file size, in bytes, of the package revision's resources.
ResourcesSizeBytes int64 `json:"resourcesSizeBytes,omitempty"`
}

type TaskType string
Expand Down
9 changes: 6 additions & 3 deletions api/porch/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,22 @@ type PackageRevisionStatus struct {
// UpstreamLock identifies the upstream data for this package.
UpstreamLock *Locator `json:"upstreamLock,omitempty"`

// SelfLock identifies the location of the current package's data
// SelfLock identifies the location of the current package's data.
SelfLock *Locator `json:"selfLock,omitempty"`

// PublishedBy is the identity of the user who approved the packagerevision.
// PublishedBy is the identity of the user who approved the package revision.
PublishedBy string `json:"publishedBy,omitempty"`

// PublishedAt is the time when the packagerevision were approved.
// PublishedAt is the time when the package revision was approved.
PublishedAt metav1.Time `json:"publishTimestamp,omitempty"`

// Deployment is true if this is a deployment package (in a deployment repository).
Deployment bool `json:"deployment,omitempty"`

Conditions []Condition `json:"conditions,omitempty"`

// ResourcesSizeBytes is the total file size, in bytes, of the package revision's resources.
ResourcesSizeBytes int64 `json:"resourcesSizeBytes,omitempty"`
}

type TaskType string
Expand Down
2 changes: 2 additions & 0 deletions api/porch/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions api/porch/v1alpha2/packagerevision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ type PackageRevisionStatus struct {
// SelfLock identifies the location of the current package's data
SelfLock *Locator `json:"selfLock,omitempty"`

// PublishedBy is the identity of the user who approved the packagerevision.
// PublishedBy is the identity of the user who approved the package revision.
PublishedBy string `json:"publishedBy,omitempty"`

// PublishedAt is the time when the packagerevision were approved.
// PublishedAt is the time when the package revision was approved.
// +optional
PublishedAt *metav1.Time `json:"publishedAt,omitempty"`

Expand Down Expand Up @@ -200,6 +200,9 @@ type PackageRevisionStatus struct {
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ResourcesSizeBytes is the total file size, in bytes, of the package revision's resources.
ResourcesSizeBytes int64 `json:"resourcesSizeBytes,omitempty"`
}

// PackageSource specifies how a package was created.
Expand Down
9 changes: 7 additions & 2 deletions api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,24 @@ spec:
type: object
type: array
publishedAt:
description: PublishedAt is the time when the packagerevision were
description: PublishedAt is the time when the package revision was
approved.
format: date-time
type: string
publishedBy:
description: PublishedBy is the identity of the user who approved
the packagerevision.
the package revision.
type: string
renderingPrrResourceVersion:
description: |-
RenderingPrrResourceVersion tracks the PRR resourceVersion currently being rendered.
Prevents concurrent renders.
type: string
resourcesSizeBytes:
description: ResourcesSizeBytes is the total file size, in bytes,
of the package revision's resources.
format: int64
type: integer
revision:
description: |-
Revision identifies the version of the package.
Expand Down
18 changes: 18 additions & 0 deletions api/sql/porch-db-1.5.10-1.5.9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2026 The kpt Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

ALTER TABLE package_revisions
DROP COLUMN IF EXISTS resources_size;
37 changes: 37 additions & 0 deletions api/sql/porch-db-1.5.9-1.5.10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2026 The kpt Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

-- Add the resources_size column - stores the total size of a package revision's
-- resource files in bytes so it can be found without having to retrieve the full
-- resources.
ALTER TABLE package_revisions
ADD COLUMN IF NOT EXISTS resources_size BIGINT NOT NULL DEFAULT 0;

-- In the event of an upgrade with repositories already synced, Porch's sync
-- routines (manual or background) will not detect the need to backfill
-- resource sizes for existing package revisions.
-- Go through them once, calculating their resource sizes, and backfill the
-- resources_size column.
UPDATE package_revisions pr
SET resources_size = r.total_size
FROM (
SELECT k8s_name_space, k8s_name, revision, SUM(OCTET_LENGTH(resource_value)) AS total_size
FROM resources
GROUP BY k8s_name_space, k8s_name, revision
) r
Comment thread
JamesMcDermott marked this conversation as resolved.
WHERE pr.k8s_name_space = r.k8s_name_space
AND pr.k8s_name = r.k8s_name
AND pr.revision = r.revision;
37 changes: 37 additions & 0 deletions api/sql/porch-db-1.5.9-1.6.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2026 The kpt Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

-- Add the resources_size column - stores the total size of a package revision's
-- resource files in bytes so it can be found without having to retrieve the full
-- resources.
ALTER TABLE package_revisions
ADD COLUMN IF NOT EXISTS resources_size BIGINT NOT NULL DEFAULT 0;

-- In the event of an upgrade with repositories already synced, Porch's sync
-- routines (manual or background) will not detect the need to backfill
-- resource sizes for existing package revisions.
-- Go through them once, calculating their resource sizes, and backfill the
-- resources_size column.
UPDATE package_revisions pr
SET resources_size = r.total_size
FROM (
SELECT k8s_name_space, k8s_name, revision, SUM(OCTET_LENGTH(resource_value)) AS total_size
FROM resources
GROUP BY k8s_name_space, k8s_name, revision
) r
Comment thread
JamesMcDermott marked this conversation as resolved.
WHERE pr.k8s_name_space = r.k8s_name_space
AND pr.k8s_name = r.k8s_name
AND pr.revision = r.revision;
Comment thread
JamesMcDermott marked this conversation as resolved.
18 changes: 18 additions & 0 deletions api/sql/porch-db-1.6.0-1.5.9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2026 The kpt Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

ALTER TABLE package_revisions
DROP COLUMN IF EXISTS resources_size;
3 changes: 2 additions & 1 deletion api/sql/porch-db.sql
Comment thread
efiacor marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2024-2025 The kpt Authors
Copyright 2024-2026 The kpt Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS package_revisions (
latest BOOLEAN NOT NULL DEFAULT FALSE,
tasks TEXT NOT NULL,
kptfile_status TEXT NOT NULL DEFAULT '{}',
resources_size BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (k8s_name_space, k8s_name),
CONSTRAINT fk_package
FOREIGN KEY (k8s_name_space, package_k8s_name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 The kpt Authors
// Copyright 2025 The kpt Authors
Comment thread
JamesMcDermott marked this conversation as resolved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions deployments/porch/3-porch-postgres-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ data:
latest BOOLEAN NOT NULL DEFAULT FALSE,
tasks TEXT NOT NULL,
kptfile_status TEXT NOT NULL DEFAULT '{}',
resources_size BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (k8s_name_space, k8s_name),
CONSTRAINT fk_package
FOREIGN KEY (k8s_name_space, package_k8s_name)
Expand Down
10 changes: 5 additions & 5 deletions docs/content/en/docs/2_concepts/package-revisions.md
Comment thread
efiacor marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ spec:
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: catalog-v4-0-0
namespace: default
name: catalog-v4-0-0
namespace: default
spec:
content: Package
deployment: false
Expand All @@ -138,14 +138,14 @@ spec:
apiVersion: config.porch.kpt.dev/v1alpha1
kind: Repository
metadata:
name: catalog-v3-0-0
namespace: default
name: catalog-v3-0-0
namespace: default
spec:
content: Package
deployment: false
type: git
git:
branch: v3.0.0
branch: v3
Comment thread
JamesMcDermott marked this conversation as resolved.
directory: /
repo: https://github.com/nephio-project/catalog.git
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PostgreSQL Database
**Database Storage:**
- Repository connections and metadata
- Package metadata (names, paths)
- Package revision metadata (lifecycle, tasks, upstream locks)
- Package revision metadata (lifecycle, tasks, upstream locks, package resources size)
- Package resources (full KRM resource content)
- Timestamps and user tracking for all entities

Expand Down Expand Up @@ -242,7 +242,9 @@ The DB Cache has a **database-first approach** to draft packages by default, but
- Draft packages stored entirely in PostgreSQL
- All draft modifications update database, not Git
- UpdatePackageRevision operations modify database records
- ClosePackageRevisionDraft saves to database without Git interaction
- ClosePackageRevisionDraft:
- sums up package file size based on state of resources at this point
- saves to database without Git interaction

**Default Git interaction pattern:**
- **Draft creation**: No Git interaction (database only)
Expand Down
9 changes: 4 additions & 5 deletions docs/content/en/docs/7_cli_api/api-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `upstreamLock` _[Locator](#locator)_ | UpstreamLock identifies the upstream data for this package. | | |
| `selfLock` _[Locator](#locator)_ | SelfLock identifies the location of the current package's data | | |
| `publishedBy` _string_ | PublishedBy is the identity of the user who approved the packagerevision. | | |
| `publishTimestamp` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#time-v1-meta)_ | PublishedAt is the time when the packagerevision were approved. | | |
| `selfLock` _[Locator](#locator)_ | SelfLock identifies the location of the current package's data. | | |
| `publishedBy` _string_ | PublishedBy is the identity of the user who approved the package revision. | | |
| `publishTimestamp` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#time-v1-meta)_ | PublishedAt is the time when the package revision was approved. | | |
| `deployment` _boolean_ | Deployment is true if this is a deployment package (in a deployment repository). | | |
| `conditions` _[Condition](#condition) array_ | | | |
| `resourcesSizeBytes` _integer_ | ResourcesSizeBytes is the total file size, in bytes, of the package revision's resources. | | |


#### PackageSpec
Expand Down Expand Up @@ -635,5 +636,3 @@ _Appears in:_
| `type` _[RepositoryType](#repositorytype)_ | Type of the repository (i.e. git). If empty, `upstreamRef` will be used. | | |
| `git` _[GitPackage](#gitpackage)_ | Git upstream package specification. Required if `type` is `git`. Must be unspecified if `type` is not `git`. | | |
| `upstreamRef` _[PackageRevisionRef](#packagerevisionref)_ | UpstreamRef is the reference to the package from a registered repository rather than external package. | | |


Loading
Loading