mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 14:53:44 +00:00
fix kubelet image gc
Signed-off-by: lixd <xueduan.li@gmail.com>
This commit is contained in:
parent
f9f00da6bc
commit
bad0593a68
@ -100,9 +100,6 @@ type realImageGCManager struct {
|
|||||||
// Reference to this node.
|
// Reference to this node.
|
||||||
nodeRef *v1.ObjectReference
|
nodeRef *v1.ObjectReference
|
||||||
|
|
||||||
// Track initialization
|
|
||||||
initialized bool
|
|
||||||
|
|
||||||
// imageCache is the cache of latest image list.
|
// imageCache is the cache of latest image list.
|
||||||
imageCache imageCache
|
imageCache imageCache
|
||||||
|
|
||||||
@ -176,7 +173,6 @@ func NewImageGCManager(runtime container.Runtime, statsProvider StatsProvider, r
|
|||||||
statsProvider: statsProvider,
|
statsProvider: statsProvider,
|
||||||
recorder: recorder,
|
recorder: recorder,
|
||||||
nodeRef: nodeRef,
|
nodeRef: nodeRef,
|
||||||
initialized: false,
|
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,16 +182,9 @@ func NewImageGCManager(runtime container.Runtime, statsProvider StatsProvider, r
|
|||||||
func (im *realImageGCManager) Start() {
|
func (im *realImageGCManager) Start() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
go wait.Until(func() {
|
go wait.Until(func() {
|
||||||
// Initial detection make detected time "unknown" in the past.
|
_, err := im.detectImages(ctx, time.Now())
|
||||||
var ts time.Time
|
|
||||||
if im.initialized {
|
|
||||||
ts = time.Now()
|
|
||||||
}
|
|
||||||
_, err := im.detectImages(ctx, ts)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.InfoS("Failed to monitor images", "err", err)
|
klog.InfoS("Failed to monitor images", "err", err)
|
||||||
} else {
|
|
||||||
im.initialized = true
|
|
||||||
}
|
}
|
||||||
}, 5*time.Minute, wait.NeverStop)
|
}, 5*time.Minute, wait.NeverStop)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user