ci: add action for shellcheck linter
we are adding new linter for shellcheck. As we are writing more shell scripts this will help maintain quality. Also, doing all the changes required in bash files to pass this shellcheck. Closes: https://github.com/rook/rook/issues/8431 Signed-off-by: subhamkrai <srai@redhat.com>
This commit is contained in:
1 parent
7af10af781
commit
ebe21c8f68
22 files changed
+207
-1319
No files matched your search
@@ -121,7 +121,7 @@ function build_rook() {
|
||||
tests/scripts/validate_modified_files.sh build
|
||||
docker images
|
||||
if [[ "$build_type" == "build" ]]; then
|
||||
docker tag $(docker images | awk '/build-/ {print $1}') rook/ceph:master
|
||||
docker tag "$(docker images | awk '/build-/ {print $1}')" rook/ceph:master
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -133,7 +133,10 @@ function validate_yaml() {
|
||||
cd cluster/examples/kubernetes/ceph
|
||||
kubectl create -f crds.yaml -f common.yaml
|
||||
# skipping folders and some yamls that are only for openshift.
|
||||
kubectl create $(ls -I scc.yaml -I "*-openshift.yaml" -I "*.sh" -I "*.py" -p | grep -v / | awk ' { print " -f " $1 } ') --dry-run
|
||||
manifests="$(find . -maxdepth 1 -type f -name '*.yaml' -and -not -name '*openshift*' -and -not -name 'scc*')"
|
||||
with_f_arg="$(echo "$manifests" | awk '{printf " -f %s",$1}')" # don't add newline
|
||||
# shellcheck disable=SC2086 # '-f manifest1.yaml -f manifest2.yaml etc.' should not be quoted
|
||||
kubectl create ${with_f_arg} --dry-run
|
||||
}
|
||||
|
||||
function create_cluster_prerequisites() {
|
||||
@@ -156,9 +159,18 @@ function deploy_cluster() {
|
||||
}
|
||||
|
||||
function wait_for_prepare_pod() {
|
||||
timeout 180 sh -c 'until kubectl -n rook-ceph logs -f job/$(kubectl -n rook-ceph get job -l app=rook-ceph-osd-prepare -o jsonpath='{.items[0].metadata.name}'); do sleep 5; done' || true
|
||||
timeout 60 sh -c 'until kubectl -n rook-ceph logs $(kubectl -n rook-ceph get pod -l app=rook-ceph-osd,ceph_daemon_id=0 -o jsonpath='{.items[*].metadata.name}') --all-containers; do echo "waiting for osd container" && sleep 1; done' || true
|
||||
kubectl -n rook-ceph describe job/$(kubectl -n rook-ceph get pod -l app=rook-ceph-osd-prepare -o jsonpath='{.items[*].metadata.name}') || true
|
||||
timeout 180 bash <<-'EOF'
|
||||
until kubectl -n rook-ceph logs --follow job/$(kubectl -n rook-ceph get job -l app=rook-ceph-osd-prepare -o jsonpath='.items[0].metadata.name}') || true; do
|
||||
sleep 5
|
||||
done
|
||||
EOF
|
||||
timeout 60 bash <<-'EOF'
|
||||
until kubectl -n rook-ceph logs $(kubectl -n rook-ceph get pod -l app=rook-ceph-osd,ceph_daemon_id=0 -o jsonpath='{.items[*].metadata.name}') --all-containers || true; do
|
||||
echo "waiting for osd container"
|
||||
sleep 1
|
||||
done
|
||||
EOF
|
||||
kubectl -n rook-ceph describe job/"$(kubectl -n rook-ceph get pod -l app=rook-ceph-osd-prepare -o jsonpath='{.items[*].metadata.name}')" || true
|
||||
kubectl -n rook-ceph describe deploy/rook-ceph-osd-0 || true
|
||||
}
|
||||
|
||||
@@ -166,7 +178,7 @@ function wait_for_ceph_to_be_ready() {
|
||||
DAEMONS=$1
|
||||
OSD_COUNT=$2
|
||||
mkdir test
|
||||
tests/scripts/validate_cluster.sh $DAEMONS $OSD_COUNT
|
||||
tests/scripts/validate_cluster.sh "$DAEMONS" "$OSD_COUNT"
|
||||
kubectl -n rook-ceph get pods
|
||||
}
|
||||
|
||||
@@ -195,12 +207,20 @@ function deploy_first_rook_cluster() {
|
||||
kubectl create -f crds.yaml -f common.yaml -f operator.yaml
|
||||
yq w -i -d1 cluster-test.yaml spec.dashboard.enabled false
|
||||
yq w -i -d1 cluster-test.yaml spec.storage.useAllDevices false
|
||||
yq w -i -d1 cluster-test.yaml spec.storage.deviceFilter ${BLOCK}1
|
||||
yq w -i -d1 cluster-test.yaml spec.storage.deviceFilter "${BLOCK}"1
|
||||
kubectl create -f cluster-test.yaml -f toolbox.yaml
|
||||
}
|
||||
|
||||
function wait_for_rgw_pods() {
|
||||
for i in {1..120}; do kubectl -n $1 get pod -l app=rook-ceph-rgw -o jsonpath='{.items[0].metadata.name}' && echo -e "\nrgw pods found" && break || echo -e "\nwaiting for rgw pods"; sleep 5; done
|
||||
for _ in {1..120}; do
|
||||
if kubectl -n "$1" get pod -l app=rook-ceph-rgw -o jsonpath='{.items[0].metadata.name}'; then
|
||||
echo "rgw pods found"
|
||||
break
|
||||
fi
|
||||
echo "waiting for rgw pods"
|
||||
sleep 5;
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function deploy_second_rook_cluster() {
|
||||
@@ -208,7 +228,7 @@ function deploy_second_rook_cluster() {
|
||||
cd cluster/examples/kubernetes/ceph/
|
||||
NAMESPACE=rook-ceph-secondary envsubst < common-second-cluster.yaml | kubectl create -f -
|
||||
sed -i 's/namespace: rook-ceph/namespace: rook-ceph-secondary/g' cluster-test.yaml
|
||||
yq w -i -d1 cluster-test.yaml spec.storage.deviceFilter ${BLOCK}2
|
||||
yq w -i -d1 cluster-test.yaml spec.storage.deviceFilter "${BLOCK}"2
|
||||
yq w -i -d1 cluster-test.yaml spec.dataDirHostPath "/var/lib/rook-external"
|
||||
yq w -i toolbox.yaml metadata.namespace rook-ceph-secondary
|
||||
kubectl create -f cluster-test.yaml -f toolbox.yaml
|
||||
@@ -224,28 +244,19 @@ function write_object_to_cluster1_read_from_cluster2() {
|
||||
CLUSTER_1_IP_ADDR=$(kubectl -n rook-ceph get svc rook-ceph-rgw-multisite-store -o jsonpath="{.spec.clusterIP}")
|
||||
BASE64_ACCESS_KEY=$(kubectl -n rook-ceph get secrets realm-a-keys -o jsonpath="{.data.access-key}")
|
||||
BASE64_SECRET_KEY=$(kubectl -n rook-ceph get secrets realm-a-keys -o jsonpath="{.data.secret-key}")
|
||||
ACCESS_KEY=$(echo "${BASE64_ACCESS_KEY}" | base64 --decode)
|
||||
SECRET_KEY=$(echo "${BASE64_SECRET_KEY}" | base64 --decode)
|
||||
s3cmd --config=s3cfg --access_key="${ACCESS_KEY}" --secret_key="${SECRET_KEY}" --host="${CLUSTER_1_IP_ADDR}" mb s3://bkt
|
||||
s3cmd --config=s3cfg --access_key="${ACCESS_KEY}" --secret_key="${SECRET_KEY}" --host="${CLUSTER_1_IP_ADDR}" put ./1M.dat s3://bkt
|
||||
ACCESS_KEY=$(echo ${BASE64_ACCESS_KEY} | base64 --decode)
|
||||
SECRET_KEY=$(echo ${BASE64_SECRET_KEY} | base64 --decode)
|
||||
s3cmd --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_1_IP_ADDR} mb s3://bkt
|
||||
s3cmd --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_1_IP_ADDR} put ./1M.dat s3://bkt
|
||||
CLUSTER_2_IP_ADDR=$(kubectl -n rook-ceph-secondary get svc rook-ceph-rgw-zone-b-multisite-store -o jsonpath="{.spec.clusterIP}")
|
||||
s3cmd --config=s3cfg --access_key="${ACCESS_KEY}" --secret_key="${SECRET_KEY}" --host="${CLUSTER_2_IP_ADDR}" get s3://bkt/1M.dat 1M-get.dat --force
|
||||
s3cmd --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_2_IP_ADDR} get s3://bkt/1M.dat 1M-get.dat --force
|
||||
diff 1M.dat 1M-get.dat
|
||||
}
|
||||
|
||||
selected_function="$1"
|
||||
if [ "$selected_function" = "generate_tls_config" ]; then
|
||||
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
bash "${scriptdir}"/generate-tls-config.sh "$2" "$3" "$4" "$5"
|
||||
elif [ "$selected_function" = "wait_for_ceph_to_be_ready" ]; then
|
||||
$selected_function "$2" "$3"
|
||||
elif [ "$selected_function" = "wait_for_rgw_pods" ]; then
|
||||
$selected_function "$2"
|
||||
else
|
||||
$selected_function
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Function call to '$selected_function' was not successful" >&2
|
||||
FUNCTION="$1"
|
||||
shift # remove function arg now that we've recorded it
|
||||
# call the function with the remainder of the user-provided args
|
||||
if ! $FUNCTION "$@"; then
|
||||
echo "Call to $FUNCTION was not successful" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user