Merge pull request #131579 from ndbaker1/automated-cherry-pick-of-#131251-origin-release-1.31

Automated cherry pick of #131251: fix(kubelet): acquire imageRecordsLock when removing image
This commit is contained in:
Kubernetes Prow Robot 2025-07-21 10:40:26 -07:00 committed by GitHub
commit e561c4c2a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -494,7 +494,10 @@ func (im *realImageGCManager) freeImage(ctx context.Context, image evictionInfo,
if isRuntimeClassInImageCriAPIEnabled {
imageKey = getImageTuple(image.id, image.runtimeHandlerUsedToPullImage)
}
im.imageRecordsLock.Lock()
delete(im.imageRecords, imageKey)
im.imageRecordsLock.Unlock()
metrics.ImageGarbageCollectedTotal.WithLabelValues(reason).Inc()
return err