Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#798 - PackageReivsion deletionProposed sometimes deletes the packageRevision #99

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
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
36 changes: 18 additions & 18 deletions pkg/cache/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,24 @@ func (r *cachedRepository) refreshAllCachedPackages(ctx context.Context) (map[re
}
}

// Send notification for packages that changed before the creation of PkgRev to avoid race conditions because of ownerReferences.
addSent := 0
modSent := 0
for kname, newPackage := range newPackageRevisionNames {
oldPackage := oldPackageRevisionNames[kname]
metaPackage, found := existingPkgRevCRsMap[newPackage.KubeObjectName()]
if !found {
klog.Warningf("no PackageRev CR found for PackageRevision %s", newPackage.KubeObjectName())
}
if oldPackage == nil {
addSent += r.objectNotifier.NotifyPackageRevisionChange(watch.Added, newPackage, metaPackage)
} else {
if oldPackage.ResourceVersion() != newPackage.ResourceVersion() {
modSent += r.objectNotifier.NotifyPackageRevisionChange(watch.Modified, newPackage, metaPackage)
}
}
}

// We go through all the PackageRevisions and make sure they have
// a corresponding PackageRev CR.
for pkgRevName, pkgRev := range newPackageRevisionNames {
Expand All @@ -490,24 +508,6 @@ func (r *cachedRepository) refreshAllCachedPackages(ctx context.Context) (map[re
}
}

// Send notification for packages that changed.
addSent := 0
modSent := 0
for kname, newPackage := range newPackageRevisionNames {
oldPackage := oldPackageRevisionNames[kname]
metaPackage, found := existingPkgRevCRsMap[newPackage.KubeObjectName()]
if !found {
klog.Warningf("no PackageRev CR found for PackageRevision %s", newPackage.KubeObjectName())
}
if oldPackage == nil {
addSent += r.objectNotifier.NotifyPackageRevisionChange(watch.Added, newPackage, metaPackage)
} else {
if oldPackage.ResourceVersion() != newPackage.ResourceVersion() {
modSent += r.objectNotifier.NotifyPackageRevisionChange(watch.Modified, newPackage, metaPackage)
}
}
}

delSent := 0
// Send notifications for packages that was deleted in the SoT
for kname, oldPackage := range oldPackageRevisionNames {
Expand Down
Loading