Skip to content

Conversation

@mortent
Copy link
Contributor

@mortent mortent commented Jun 13, 2021

This PR fixes a corner case that is not handled correctly. If the upstream package contains an unfetched subpackage, it will be fetched when the package is cloned (so similar to how sync works in old kpt). If this package is later deleted from upstream, it should only be deleted from local if there are no local changes. Currently this doesn't work correctly, since the package in origin will be unfetched and therefore running the diff will always show changes. With this change, the update logic will fetch the full package for origin before doing a diff.

Fixes: #2216

Must merge after #2217

func checkPackageTags(pkgPath, ref string, upstreamRepo *gitutil.GitUpstreamRepo) string {
// Check if we have a ref in the upstream that matches the package-specific
// reference. If we do, we use that reference.
ps := strings.Split(pkgPath, "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The package path provided in the Kptfile is OS agnostic, so we should not use the OS specific filepath package here.

// Check the diff. If there are local changes, we keep the subpackage.
// If the package has been deleted from upstream, we only want to delete
// it from local if it has no changes.
originUnfetched, err := pkg.IsPackageUnfetched(originPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we doing this check here ? Why can't we make sure that all the 3 sources are fetched when they are initially pulled on to local ?

@phanimarupaka
Copy link
Contributor

@mortent Is this still needed ? Can we close this and handle this when there are issues faced by customers with this behavior?

@liamfallon
Copy link
Contributor

@liamfallon to review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kpt pkg update doesn't handle deletion of unfetched remote packages correctly.

3 participants