Repository navigation
(v1alpha1) Validate source/target upstream package names on PackageRevision upgrade - #1343
Conversation
✅ Deploy Preview for kpt-porch canceled.Built without sensitive environment variables
|
There was a problem hiding this comment.
🟡 Changes recommended
Upgrade validation still permits unrelated packages or incorrect merge bases through wildcard and incomplete origin checks, and rejects valid edited revisions when source history is missing despite a surviving upstream lock.
3 open issues
PackageKey.Matchestreats an empty path as a wildcard, so an origin ofrepo.base.v1accepts… · New Discarding the repository and ref leaves subpackage validation checking only the package pathname.… · New An edited revision whose source was deleted now fails upgrade validation even when it retains a… · New
What changed in this PR
Adds server-side upstream validation to v1alpha1 PackageRevision upgrades, addressing the raw API validation gap described in #1308. The v1alpha2 counterpart remains out of scope.
Changes:
- Validates whole-package upgrade references against the local revision’s origin.
- Adds subpackage validation using Kptfile upstream metadata.
- Extends unit and end-to-end coverage for mismatched references and valid upgrades.
| File | Description |
|---|---|
test/e2e/api/rpkg_clone_test.go |
Tests rejection of mismatched upstream packages and acceptance of a valid upgrade. |
pkg/task/upgrade.go |
Adds origin resolution and upstream validation before merging. |
pkg/task/upgrade_test.go |
Adds mismatch and nested-subpackage tests; updates fixtures. |
pkg/task/generictaskhandler_test.go |
Adds upstream metadata to successful subpackage-upgrade fixtures. |
Review effort: Balanced
|
You'll need to raise a separate PR for the API change. There's a choreography to go through:
This will avoid checking in a If there's an API change on v1alpha2 for a force flag it might be best to include that in the same API PR and do the API changes for v1alpha1 and v1alpha2 in one go. |
- flag to skip upgrade package name validation introduced in kptdev#1343 Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
OK - have done. It's up at #1366 and ready for review now - once we've got that in, I'll rebase this one and push again to de-check-in the |
* Add `ForceUpgrade` flag to `PackageUpgradeTaskSpec` - flag to skip upgrade package name validation introduced in #1343 Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com> * Regenerate further API files to include `forceUpgrade` Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com> --------- Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
Commented out the |
Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
- fix duplicate import that set off linter - change package upstream comparison to key identity rather than (looser) Matches() method - add fallback route via UpstreamLock to resolve upstream of package revision with edit origin - resolve subpackage upstream more comprehensively by comparing all Git details from upstream in Kptfile Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
…evision-based edit origin matching Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
…de validation - due to API change, uncomment go.mod replace directive - fix generate-api-reference-md.sh path in docs Makefile Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
- resolve merge conflict Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
ff4f44a to
0a8ffe6
Compare
Signed-off-by: James McDermott <james.j.mcdermott@ericsson.com>
|





Description
oldUpstream/newUpstreamreferences supplied in an upgrade request are now checked against the package the local revision was actually derived fromvalidateUpstreamPackagesresolves the local revision's real upstream and validates that:validateSubpackageUpstreamPackagesreads the subpackage's Kptfileupstreamto determine its origin package and applies the equivalent current/target consistency checks.--forceflag toporchctl rpkg upgradeto skip validation and force upgradeporchctlcomputes and validates the upstream refs on the user's behalf, but a raw API call can supply mismatched or incorrectoldUpstream/newUpstreamreferences. Without server-side validation, an upgrade could be applied against the wrong upstream package, producing an incorrect merge. This adds the guard so the server does not trust client-supplied refs.upgradePackageMutation.apply, before performing the merge, the mutation resolves the relevant package-revision keys and compares the request's upstream references to the local revision's genuine origin, returning a descriptive error if they are inconsistent--forceis present orforceUpgradeis set totrue, the validation short-circuits and allows the upgradeRelated Issue(s)
Type of Change
Checklist
Testing Instructions (Optional)
make test— covers the new upgrade validation cases inupgrade_test.goandgenerictaskhandler_test.go.make setup-dev-env run-in-kind-db-cache test-e2e(see additions intest/e2e/api/rpkg_clone_test.go).oldUpstream/newUpstreamrefer to a different package than the local revision's originAdditional Notes (Optional)
AI Disclosure
If so, please describe how: