Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix shellcheck failures in test/e2e_node/conformance/run_test.sh #79500

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.shellcheck_failures
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@
./test/cmd/diff.sh
./test/cmd/discovery.sh
./test/cmd/legacy-script.sh
./test/e2e_node/conformance/run_test.sh
./test/images/image-util.sh
47 changes: 24 additions & 23 deletions test/e2e_node/conformance/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ KUBELET_BIN=${KUBELET_BIN:-"kubelet"}

# KUBELET is the kubelet binary path. If it is not specified, assume kubelet is
# in PATH.
KUBELET=${KUBELET:-"`which $KUBELET_BIN`"}
KUBELET=${KUBELET:-"$(which "$KUBELET_BIN")"}

# LOG_DIR is the absolute path of the directory where the test will collect all
# logs to. By default, use the current directory.
LOG_DIR=${LOG_DIR:-`pwd`}
mkdir -p $LOG_DIR
LOG_DIR=${LOG_DIR:-$(pwd)}
mkdir -p "$LOG_DIR"

# NETWORK_PLUGIN is the network plugin used by kubelet. Do not use network
# plugin by default.
Expand All @@ -92,7 +92,8 @@ KUBELET_KUBECONFIG=${KUBELET_KUBECONFIG:-"/var/lib/kubelet/kubeconfig"}
function create-kubelet-kubeconfig() {
local api_addr="${1}"
local dest="${2}"
local dest_dir="$(dirname "${dest}")"
local dest_dir
dest_dir="$(dirname "${dest}")"
mkdir -p "${dest_dir}" &>/dev/null || sudo mkdir -p "${dest_dir}"
sudo=$(test -w "${dest_dir}" || echo "sudo -E")
cat <<EOF | ${sudo} tee "${dest}" > /dev/null
Expand All @@ -114,10 +115,12 @@ EOF
kubelet_log=kubelet.log
start_kubelet() {
echo "Creating kubelet.kubeconfig"
create-kubelet-kubeconfig "http://localhost:8080" $KUBELET_KUBECONFIG
create-kubelet-kubeconfig "http://localhost:8080" "${KUBELET_KUBECONFIG}"
echo "Starting kubelet..."
sudo -b $KUBELET $@ &>$LOG_DIR/$kubelet_log
if [ $? -ne 0 ]; then
# we want to run this command as root but log the file to a normal user file
# (so disable SC2024)
# shellcheck disable=SC2024
if ! sudo -b "${KUBELET}" "$@" &>"${LOG_DIR}/${kubelet_log}"; then
echo "Failed to start kubelet"
exit 1
fi
Expand All @@ -130,8 +133,7 @@ wait_kubelet() {
local maxRetry=10
local cur=1
while [ $cur -le $maxRetry ]; do
curl -s $healthCheckURL > /dev/null
if [ $? -eq 0 ]; then
if curl -s $healthCheckURL > /dev/null; then
echo "Kubelet is ready"
break
fi
Expand All @@ -148,8 +150,7 @@ wait_kubelet() {
# kill_kubelet kills kubelet.
kill_kubelet() {
echo "Stopping kubelet..."
sudo pkill $KUBELET_BIN
if [ $? -ne 0 ]; then
if ! sudo pkill "${KUBELET_BIN}"; then
echo "Failed to stop kubelet."
exit 1
fi
Expand All @@ -158,13 +159,13 @@ kill_kubelet() {
# run_test runs the node test container.
run_test() {
env=""
if [ ! -z "$FOCUS" ]; then
if [ -n "$FOCUS" ]; then
env="$env -e FOCUS=\"$FOCUS\""
fi
if [ ! -z "$SKIP" ]; then
if [ -n "$SKIP" ]; then
env="$env -e SKIP=\"$SKIP\""
fi
if [ ! -z "$TEST_ARGS" ]; then
if [ -n "$TEST_ARGS" ]; then
env="$env -e TEST_ARGS=\"$TEST_ARGS\""
fi
# The test assumes that inside the container:
Expand All @@ -177,31 +178,31 @@ run_test() {

# Check whether kubelet is running. If kubelet is running, tell the user to stop
# it before running the test.
pid=`pidof $KUBELET_BIN`
if [ ! -z $pid ]; then
pid=$(pidof "${KUBELET_BIN}")
if [ -n "$pid" ]; then
echo "Kubelet is running (pid=$pid), please stop it before running the test."
exit 1
fi

volume_stats_agg_period=10s
serialize_image_pulls=false
config_dir=`mktemp -d`
config_dir=$(mktemp -d)
file_check_frequency=10s
pod_cidr=10.100.0.0/24
log_level=4
start_kubelet --kubeconfig ${KUBELET_KUBECONFIG} \
start_kubelet --kubeconfig "${KUBELET_KUBECONFIG}" \
--volume-stats-agg-period $volume_stats_agg_period \
--serialize-image-pulls=$serialize_image_pulls \
--pod-manifest-path $config_dir \
--pod-manifest-path "${config_dir}" \
--file-check-frequency $file_check_frequency \
--pod-cidr=$pod_cidr \
--runtime-cgroups=/docker-daemon \
--kubelet-cgroups=/kubelet \
--system-cgroups=/system \
--cgroup-root=/ \
--network-plugin=$NETWORK_PLUGIN \
--cni-conf-dir=$CNI_CONF_DIR \
--cni-bin-dir=$CNI_BIN_DIR \
"--network-plugin=${NETWORK_PLUGIN}" \
"--cni-conf-dir=${CNI_CONF_DIR}" \
"--cni-bin-dir=${CNI_BIN_DIR}" \
--v=$log_level \
--logtostderr

Expand All @@ -212,4 +213,4 @@ run_test
kill_kubelet

# Clean up the kubelet config directory
sudo rm -rf $config_dir
sudo rm -rf "${config_dir}"