From 995b3c558fcc2109a623eec40306f68d94a44d48 Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Wed, 10 Dec 2025 21:05:27 +0100 Subject: [PATCH] Allow image pulls without references --- internal/controller/scheduler/imagepull.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/controller/scheduler/imagepull.go b/internal/controller/scheduler/imagepull.go index 323e7a8..779e708 100644 --- a/internal/controller/scheduler/imagepull.go +++ b/internal/controller/scheduler/imagepull.go @@ -147,15 +147,26 @@ func (scheduler *Scheduler) imagePullLoopIteration() error { // Garbage collect orphaned image pulls for _, imagePull := range imagePulls { - if lo.ContainsBy(imagePull.OwnerReferences, func(ownerReference v1.OwnerReference) bool { + // Is this image pull controlled by an image pull job? + imagePullJobOwnerReferences := lo.Filter(imagePull.OwnerReferences, func(ownerReference v1.OwnerReference, _ int) bool { + return ownerReference.Kind == v1.KindImagePullJob + }) + + if len(imagePullJobOwnerReferences) == 0 { + continue + } + + // Does this image pull has any invalid references? + hasOrphanedPullJobOwnerReferences := lo.ContainsBy(imagePullJobOwnerReferences, func(ownerReference v1.OwnerReference) bool { imagePullJob, ok := imagePullJobIndex[ownerReference.Name] if !ok { - return false + return true } - return ownerReference == imagePullJob.OwnerReference() - }) { - // This image pull is still controlled by an existing image pull job + return ownerReference != imagePullJob.OwnerReference() + }) + + if !hasOrphanedPullJobOwnerReferences { continue }