Skip to content

Commit

Permalink
Reconciliation process with many images is slow #177
Browse files Browse the repository at this point in the history
  • Loading branch information
senthilrch committed Mar 11, 2023
1 parent 7f678b4 commit 84222ce
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions cmd/controller/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,17 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
glog.V(4).Infof("No. of nodes in %+v is %d", i.NodeSelector, len(nodes))

for _, n := range nodes {
for m := range i.Images {
ipr := images.ImageWorkRequest{
Image: i.Images[m],
Node: n,
ContainerRuntimeVersion: n.Status.NodeInfo.ContainerRuntimeVersion,
WorkType: wqKey.WorkType,
Imagecache: imageCache,
if wqKey.WorkType == images.ImageCacheCreate || wqKey.WorkType == images.ImageCacheRefresh || wqKey.WorkType == images.ImageCachePurge {
for m := range i.Images {
ipr := images.ImageWorkRequest{
Image: i.Images[m],
Node: n,
ContainerRuntimeVersion: n.Status.NodeInfo.ContainerRuntimeVersion,
WorkType: wqKey.WorkType,
Imagecache: imageCache,
}
c.imageworkqueue.AddRateLimited(ipr)
}
c.imageworkqueue.AddRateLimited(ipr)
}
if wqKey.WorkType == images.ImageCacheUpdate {
for _, oldimage := range wqKey.OldImageCache.Spec.CacheSpec[k].Images {
Expand All @@ -555,6 +557,25 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
c.imageworkqueue.AddRateLimited(ipr)
}
}
for _, newimage := range i.Images {
matched := false
for _, oldimage := range wqKey.OldImageCache.Spec.CacheSpec[k].Images {
if oldimage == newimage {
matched = true
break
}
}
if !matched {
ipr := images.ImageWorkRequest{
Image: newimage,
Node: n,
ContainerRuntimeVersion: n.Status.NodeInfo.ContainerRuntimeVersion,
WorkType: images.ImageCacheUpdate,
Imagecache: imageCache,
}
c.imageworkqueue.AddRateLimited(ipr)
}
}
}
}
}
Expand Down

0 comments on commit 84222ce

Please sign in to comment.