kptdev/kpt

Porch: PackageVariantSet deletes and recreates PackageVariants instead of updating

johnbelamaric opened this issue · 1 comments

Expected behavior

When a change is made to a PackageVariantSet that implies changes to the fields of a PackageVariant, but that does not imply a change in the repo or package name, the expectation is that the PVS will update the existing, previously created PackageVariant.

Actual behavior

The PVS deletes the PV, and creates a new one, with a new name. This seems to be at least one cause of #3980, though I suspect not the only cause.

This also causes existing published versions to be flagged as DeletionProposed.

Information

When an update is made to a PV, it will create a new Draft, based on the existing, most recent published version of the package, and incorporate the changes to the PV in that new Draft. If we instead delete and recreate, we lose any changes the user may have made to the Draft that were later published. So, delete & recreate can be quite destructive.

Steps to reproduce the behavior

See #3980.

I suspect we just need a better way to calculate the name of the package variant from the PVS. I am thinking: <pvs-name>-<repo-name>-<package-name>-<uniquifier>. We need to add the uniquifier (we should use a 4-digit one like other places in K8s) in case the name is too long. When we match our updated "target list" to "existing targets", we should do it based on repo/package name, not PV name.