mirror of https://github.com/k3s-io/k3s
Changed how lastHeartBeatTime works in the etcd condition
Signed-off-by: Vitor Savian <vitor.savian@suse.com>pull/9404/head
parent
f3b4effb32
commit
25c7208b7e
|
@ -68,6 +68,7 @@ const (
|
||||||
// other defaults from k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
|
// other defaults from k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
|
||||||
defaultKeepAliveTime = 30 * time.Second
|
defaultKeepAliveTime = 30 * time.Second
|
||||||
defaultKeepAliveTimeout = 10 * time.Second
|
defaultKeepAliveTimeout = 10 * time.Second
|
||||||
|
heartbeatInterval = 5 * time.Minute
|
||||||
|
|
||||||
maxBackupRetention = 5
|
maxBackupRetention = 5
|
||||||
|
|
||||||
|
@ -1248,8 +1249,17 @@ func (e *ETCD) setEtcdStatusCondition(node *v1.Node, client kubernetes.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
if find, condition := nodeUtil.GetNodeCondition(&node.Status, etcdStatusType); find >= 0 {
|
if find, condition := nodeUtil.GetNodeCondition(&node.Status, etcdStatusType); find >= 0 {
|
||||||
if condition.Status == newCondition.Status && memberStatus != StatusUnjoined {
|
|
||||||
|
// if the condition is not changing, we only want to update the last heartbeat time
|
||||||
|
if condition.Status == newCondition.Status && condition.Reason == newCondition.Reason && condition.Message == newCondition.Message {
|
||||||
logrus.Debugf("Node %s is not changing etcd status condition", memberName)
|
logrus.Debugf("Node %s is not changing etcd status condition", memberName)
|
||||||
|
|
||||||
|
// If the condition status is not changing, we only want to update the last heartbeat time if the
|
||||||
|
// LastHeartbeatTime is older than the heartbeatTimeout.
|
||||||
|
if metav1.Now().Sub(condition.LastHeartbeatTime.Time) < heartbeatInterval {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
condition.LastHeartbeatTime = metav1.Now()
|
condition.LastHeartbeatTime = metav1.Now()
|
||||||
return nodeHelper.SetNodeCondition(client, types.NodeName(node.Name), *condition)
|
return nodeHelper.SetNodeCondition(client, types.NodeName(node.Name), *condition)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue