mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Merge pull request #9676 from marekbiskup/skipNotReadyNodesInNetworkTest
skip not ready nodes in networking test
This commit is contained in:
commit
ef60540446
@ -116,6 +116,14 @@ var _ = Describe("Networking", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Failf("Failed to list nodes: %v", err)
|
Failf("Failed to list nodes: %v", err)
|
||||||
}
|
}
|
||||||
|
// previous tests may have cause failures of some nodes. Let's skip
|
||||||
|
// 'Not Ready' nodes, just in case (there is no need to fail the test).
|
||||||
|
filterNodes(nodes, func(node api.Node) bool {
|
||||||
|
return isNodeReadySetAsExpected(&node, true)
|
||||||
|
})
|
||||||
|
if len(nodes.Items) < 2 {
|
||||||
|
Failf("Less than two nodes were found Ready.")
|
||||||
|
}
|
||||||
|
|
||||||
podNames := LaunchNetTestPodPerNode(f, nodes, svcname, "1.4")
|
podNames := LaunchNetTestPodPerNode(f, nodes, svcname, "1.4")
|
||||||
|
|
||||||
|
@ -1145,6 +1145,21 @@ func waitForNodeToBeNotReady(c *client.Client, name string, timeout time.Duratio
|
|||||||
return waitForNodeToBe(c, name, false, timeout)
|
return waitForNodeToBe(c, name, false, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNodeReadySetAsExpected(node *api.Node, wantReady bool) bool {
|
||||||
|
// Check the node readiness condition (logging all).
|
||||||
|
for i, cond := range node.Status.Conditions {
|
||||||
|
Logf("Node %s condition %d/%d: type: %v, status: %v",
|
||||||
|
node.Name, i+1, len(node.Status.Conditions), cond.Type, cond.Status)
|
||||||
|
// Ensure that the condition type is readiness and the status
|
||||||
|
// matches as desired.
|
||||||
|
if cond.Type == api.NodeReady && (cond.Status == api.ConditionTrue) == wantReady {
|
||||||
|
Logf("Successfully found node %s readiness to be %t", node.Name, wantReady)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// waitForNodeToBe returns whether node name's readiness state matches wantReady
|
// waitForNodeToBe returns whether node name's readiness state matches wantReady
|
||||||
// within timeout. If wantReady is true, it will ensure the node is ready; if
|
// within timeout. If wantReady is true, it will ensure the node is ready; if
|
||||||
// it's false, it ensures the node is in any state other than ready (e.g. not
|
// it's false, it ensures the node is in any state other than ready (e.g. not
|
||||||
@ -1158,22 +1173,28 @@ func waitForNodeToBe(c *client.Client, name string, wantReady bool, timeout time
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the node readiness condition (logging all).
|
if isNodeReadySetAsExpected(node, wantReady) {
|
||||||
for i, cond := range node.Status.Conditions {
|
return true
|
||||||
Logf("Node %s condition %d/%d: type: %v, status: %v",
|
|
||||||
name, i+1, len(node.Status.Conditions), cond.Type, cond.Status)
|
|
||||||
// Ensure that the condition type is readiness and the status
|
|
||||||
// matches as desired.
|
|
||||||
if cond.Type == api.NodeReady && (cond.Status == api.ConditionTrue) == wantReady {
|
|
||||||
Logf("Successfully found node %s readiness to be %t", name, wantReady)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logf("Node %s didn't reach desired readiness (%t) within %v", name, wantReady, timeout)
|
Logf("Node %s didn't reach desired readiness (%t) within %v", name, wantReady, timeout)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filters nodes in NodeList in place, removing nodes that do not
|
||||||
|
// satisfy the given condition
|
||||||
|
// TODO: consider merging with pkg/client/cache.NodeLister
|
||||||
|
func filterNodes(nodeList *api.NodeList, fn func(node api.Node) bool) {
|
||||||
|
var l []api.Node
|
||||||
|
|
||||||
|
for _, node := range nodeList.Items {
|
||||||
|
if fn(node) {
|
||||||
|
l = append(l, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodeList.Items = l
|
||||||
|
}
|
||||||
|
|
||||||
// LatencyMetrics stores data about request latency at a given quantile
|
// LatencyMetrics stores data about request latency at a given quantile
|
||||||
// broken down by verb (e.g. GET, PUT, LIST) and resource (e.g. pods, services).
|
// broken down by verb (e.g. GET, PUT, LIST) and resource (e.g. pods, services).
|
||||||
type LatencyMetric struct {
|
type LatencyMetric struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user