mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 21:21:14 +00:00
Delete all pods based on condition transition time.
This commit is contained in:
@@ -75,8 +75,18 @@ const (
|
||||
initialNodeStatusUpdateFrequency = 100 * time.Millisecond
|
||||
nodeStatusUpdateFrequencyInc = 500 * time.Millisecond
|
||||
|
||||
// Node status update frequency and retry count. Note: be cautious when changing nodeStatusUpdateFrequency,
|
||||
// it must work with nodecontroller.nodeMonitorGracePeriod.
|
||||
// Node status update frequency and retry count.
|
||||
// Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod
|
||||
// in nodecontroller. There are several constraints:
|
||||
// 1. nodeMonitorGracePeriod must be N times more than nodeStatusUpdateFrequency, where
|
||||
// N means number of retries allowed for kubelet to post node status. It is pointless
|
||||
// to make nodeMonitorGracePeriod be less than nodeStatusUpdateFrequency, since there
|
||||
// will only be fresh values from Kubelet at an interval of nodeStatusUpdateFrequency.
|
||||
// 2. nodeMonitorGracePeriod can't be too large for user experience - larger value takes
|
||||
// longer for user to see up-to-date node status.
|
||||
// 3. nodeStatusUpdateFrequency needs to be large enough for Kubelet to generate node
|
||||
// status. Kubelet may fail to update node status reliablly if the value is too small,
|
||||
// as it takes time to gather all necessary node information.
|
||||
nodeStatusUpdateFrequency = 2 * time.Second
|
||||
nodeStatusUpdateRetry = 5
|
||||
)
|
||||
@@ -1837,20 +1847,23 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
||||
node.Spec.Capacity = CapacityFromMachineInfo(info)
|
||||
}
|
||||
|
||||
currentTime := util.Now()
|
||||
newCondition := api.NodeCondition{
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionFull,
|
||||
Reason: fmt.Sprintf("kubelet is posting ready status"),
|
||||
LastProbeTime: util.Now(),
|
||||
LastProbeTime: currentTime,
|
||||
}
|
||||
updated := false
|
||||
for i := range node.Status.Conditions {
|
||||
if node.Status.Conditions[i].Type == api.NodeReady {
|
||||
newCondition.LastTransitionTime = node.Status.Conditions[i].LastTransitionTime
|
||||
node.Status.Conditions[i] = newCondition
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
if !updated {
|
||||
newCondition.LastTransitionTime = currentTime
|
||||
node.Status.Conditions = append(node.Status.Conditions, newCondition)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user