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:
Yu-Ju Hong
2015-12-10 15:42:56 -08:00
parent bd9d980243
commit 712612c2dc
7 changed files with 43 additions and 58 deletions

View File

@@ -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