e2e/storage: speed up kubectl commands

Speed up stopping by not waiting for Node not ready, `systemctl` will ensure
kubelet process stopped before return. This should save 40s per case.

Since stop command does not wait for not ready, start command needs to wait for
the next heartbeat to ensure we are checking status from new process.

implement restart by stop then start, to get heartbeat time when kubelet is
down. And we do not need to sleep 30s now. The sleep is moved to callers, since
they still need them to ensure the volume does not disappear.

Dropped support for non-systemd system.
This commit is contained in:
胡玮文
2024-03-22 16:57:06 +08:00
parent 95a6f2e4dc
commit f3f44f70bf
4 changed files with 73 additions and 67 deletions

View File

@@ -495,6 +495,16 @@ func hasNonblockingTaint(node *v1.Node, nonblockingTaints string) bool {
return false
}
// GetNodeHeartbeatTime returns the timestamp of the last status update of the node.
func GetNodeHeartbeatTime(node *v1.Node) metav1.Time {
for _, condition := range node.Status.Conditions {
if condition.Type == v1.NodeReady {
return condition.LastHeartbeatTime
}
}
return metav1.Time{}
}
// PodNodePairs return podNode pairs for all pods in a namespace
func PodNodePairs(ctx context.Context, c clientset.Interface, ns string) ([]PodNode, error) {
var result []PodNode