mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
tests: Validate node name for exec_host()
The current `exec_host()` accepts a given node name and creates a node debugger pod, even if the name is invalid. This could result in the creation of an unnecessary pending pod (since we are using nodeAffinity; if the given name does not match any actual node names, the pod won’t be scheduled), which wastes resources. This commit introduces validation for the node name to prevent this situation. Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
This commit is contained in:
parent
3a7f9595b6
commit
e8d1feb25f
@ -71,6 +71,10 @@ k8s_create_pod() {
|
|||||||
#
|
#
|
||||||
exec_host() {
|
exec_host() {
|
||||||
local node="$1"
|
local node="$1"
|
||||||
|
# Validate the node
|
||||||
|
if ! kubectl get node "${node}" > /dev/null 2>&1; then
|
||||||
|
die "A given node ${node} is not valid"
|
||||||
|
fi
|
||||||
# `kubectl debug` always returns 0, so we hack it to return the right exit code.
|
# `kubectl debug` always returns 0, so we hack it to return the right exit code.
|
||||||
local command="${@:2}"
|
local command="${@:2}"
|
||||||
# Make 7 character hash from the node name
|
# Make 7 character hash from the node name
|
||||||
|
Loading…
Reference in New Issue
Block a user