-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(support-bundle): agent with taint toleration
Ref: 5614 Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
|
||
from kubernetes import client as k8sclient | ||
|
||
from common import get_self_host_id | ||
|
||
|
||
@pytest.fixture( | ||
params=[("foo/bar", "test", "NoSchedule"), | ||
("foo", "", "NoSchedule")] | ||
) | ||
def taint_nodes_exclude_self(request): | ||
taint = k8sclient.V1Taint( | ||
key=request.param[0], | ||
value=request.param[1], | ||
effect=request.param[2], | ||
) | ||
|
||
self_host_id = get_self_host_id() | ||
|
||
api = k8sclient.CoreV1Api() | ||
node_items = api.list_node().items | ||
saved_nodes = [] | ||
for node in node_items: | ||
if node.metadata.name == self_host_id: | ||
continue | ||
|
||
saved_nodes.append(node) | ||
|
||
if node.spec.taints is None: | ||
taints = [taint] | ||
else: | ||
taints = node.spec.taints + [taint] | ||
payload = { | ||
"spec": { | ||
"taints": taints | ||
} | ||
} | ||
api.patch_node(node.metadata.name, body=payload) | ||
|
||
yield saved_nodes | ||
|
||
for node in saved_nodes: | ||
if node.metadata.name == self_host_id: | ||
continue | ||
|
||
if node.spec.taints is None: | ||
taints = [] | ||
else: | ||
taints = node.spec.taints | ||
payload = { | ||
"spec": { | ||
"taints": taints | ||
} | ||
} | ||
api.patch_node(node.metadata.name, body=payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters