mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Treat first-seen, non-pending pods as updates
Kubelet doesn't perform checkpointing and loses all its internal states after restarts. It'd then mistaken pods from the api server as new pods and attempt to go through the admission process. This may result in pods being rejected even though they are running on the node (e.g., out of disk situation). This change adds a condition to check whether the pod was seen before and categorize such pods as updates. The change also removes freeze/unfreeze mechanism used to work around such cases, since it is no longer needed and it stopped working correctly ever since we switched to incremental updates.
This commit is contained in:
@@ -36,9 +36,6 @@ type diskSpaceManager interface {
|
||||
// Checks the available disk space
|
||||
IsRootDiskSpaceAvailable() (bool, error)
|
||||
IsDockerDiskSpaceAvailable() (bool, error)
|
||||
// Always returns sufficient space till Unfreeze() is called.
|
||||
// This is a signal from caller that its internal initialization is done.
|
||||
Unfreeze()
|
||||
}
|
||||
|
||||
type DiskSpacePolicy struct {
|
||||
@@ -58,9 +55,8 @@ type fsInfo struct {
|
||||
type realDiskSpaceManager struct {
|
||||
cadvisor cadvisor.Interface
|
||||
cachedInfo map[string]fsInfo // cache of filesystem info.
|
||||
lock sync.Mutex // protecting cachedInfo and frozen.
|
||||
lock sync.Mutex // protecting cachedInfo.
|
||||
policy DiskSpacePolicy // thresholds. Set at creation time.
|
||||
frozen bool // space checks always return ok when frozen is set. True on creation.
|
||||
}
|
||||
|
||||
func (dm *realDiskSpaceManager) getFsInfo(fsType string, f func() (cadvisorapi.FsInfo, error)) (fsInfo, error) {
|
||||
@@ -96,9 +92,6 @@ func (dm *realDiskSpaceManager) IsRootDiskSpaceAvailable() (bool, error) {
|
||||
}
|
||||
|
||||
func (dm *realDiskSpaceManager) isSpaceAvailable(fsType string, threshold int, f func() (cadvisorapi.FsInfo, error)) (bool, error) {
|
||||
if dm.frozen {
|
||||
return true, nil
|
||||
}
|
||||
fsInfo, err := dm.getFsInfo(fsType, f)
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("failed to get fs info for %q: %v", fsType, err)
|
||||
@@ -117,12 +110,6 @@ func (dm *realDiskSpaceManager) isSpaceAvailable(fsType string, threshold int, f
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (dm *realDiskSpaceManager) Unfreeze() {
|
||||
dm.lock.Lock()
|
||||
defer dm.lock.Unlock()
|
||||
dm.frozen = false
|
||||
}
|
||||
|
||||
func validatePolicy(policy DiskSpacePolicy) error {
|
||||
if policy.DockerFreeDiskMB < 0 {
|
||||
return fmt.Errorf("free disk space should be non-negative. Invalid value %d for docker disk space threshold.", policy.DockerFreeDiskMB)
|
||||
@@ -144,7 +131,6 @@ func newDiskSpaceManager(cadvisorInterface cadvisor.Interface, policy DiskSpaceP
|
||||
cadvisor: cadvisorInterface,
|
||||
policy: policy,
|
||||
cachedInfo: map[string]fsInfo{},
|
||||
frozen: true,
|
||||
}
|
||||
|
||||
return dm, nil
|
||||
|
||||
Reference in New Issue
Block a user