Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicente-Cheng committed Oct 7, 2024
1 parent 6571402 commit 90f01bc
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 34 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/basic-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ jobs:
- name: "Deploy NDM"
run: |
pushd ndm-new-vagrant-k3s
cp ../ci/scripts/deploy_ndm.sh ./deploy_ndm.sh
cp ../ci/scripts/deploy_ndm_current.sh ./deploy_ndm_current.sh
cp ../ci/charts/ndm-override.yaml ./ndm-override.yaml
./deploy_ndm.sh
./deploy_ndm_current.sh
popd
- name: "Add disk"
run: |
Expand Down Expand Up @@ -123,8 +123,8 @@ jobs:
echo "VM_DEPLOYED=true" >> "$GITHUB_ENV"
yq e -i ".longhorn_version = \"1.7.1\"" settings.yaml
./scripts/deploy_longhorn.sh
cp ../ci/scripts/deploy_ndm.sh ./deploy_ndm.sh
./deploy_ndm.sh
cp ../ci/scripts/deploy_ndm_chart.sh ./deploy_ndm_chart.sh
./deploy_ndm_chart.sh
popd
- name: "Add disk"
run: |
Expand All @@ -143,31 +143,31 @@ jobs:
cp ../ci/scripts/upgrade_ndm.sh ./upgrade_ndm.sh
./upgrade_ndm.sh
popd
- name: "Run Basic Test"
id: basic-test
run: |
pushd ndm-upgrade-vagrant-k3s
vagrant ssh-config node1 > ../ssh-config
cp kubeconfig ../kubeconfig
popd
echo Running integration tests
NDM_HOME=`pwd` go test -v ./tests/...
- name: "Get NDM logs"
if: always()
run: |
if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then
echo "VM is not deployed, skip getting logs"
exit 0
fi
./ci/scripts/get-debug-info.sh
- name: "Tear Down / Cleanup"
if: always()
run: |
if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then
echo "VM is not deployed, skip VM destroy"
exit 0
fi
rm -rf /tmp/hotplug_disks/ndm-upgrade-vagrant-k3s
pushd ndm-upgrade-vagrant-k3s
vagrant destroy -f --parallel
popd
#- name: "Run Basic Test"
# id: basic-test
# run: |
# pushd ndm-upgrade-vagrant-k3s
# vagrant ssh-config node1 > ../ssh-config
# cp kubeconfig ../kubeconfig
# popd
# echo Running integration tests
# NDM_HOME=`pwd` go test -v ./tests/...
#- name: "Get NDM logs"
# if: always()
# run: |
# if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then
# echo "VM is not deployed, skip getting logs"
# exit 0
# fi
# ./ci/scripts/get-debug-info.sh
#- name: "Tear Down / Cleanup"
# if: always()
# run: |
# if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then
# echo "VM is not deployed, skip VM destroy"
# exit 0
# fi
# rm -rf /tmp/hotplug_disks/ndm-upgrade-vagrant-k3s
# pushd ndm-upgrade-vagrant-k3s
# vagrant destroy -f --parallel
# popd
6 changes: 6 additions & 0 deletions ci/charts/ndm-override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: ""

webhook:
repository: rancher/harvester-node-disk-manager
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

autoProvisionFilter: [/dev/sd*]
debug: true

Expand Down
File renamed without changes.
91 changes: 91 additions & 0 deletions ci/scripts/deploy_ndm_current.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash -e

TOP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" &> /dev/null && pwd )"

ensure_command() {
local cmd=$1
if ! which $cmd &> /dev/null; then
echo 1
return
fi
echo 0
}

wait_ndm_ready() {
while [ true ]; do
running_num=$(kubectl get ds harvester-node-disk-manager -n harvester-system -o 'jsonpath={.status.numberReady}')
if [[ $running_num -eq ${cluster_nodes} ]]; then
echo "harvester-node-disk-manager pods are ready!"
break
fi
echo "harvester-node-disk-manager pods are not ready, sleep 10 seconds."
sleep 10
done
}

ensure_longhorn_ready() {
# ensure longhorn-manager first
while [ true ]; do
running_num=$(kubectl get ds longhorn-manager -n longhorn-system -o 'jsonpath={.status.numberReady}')
if [[ $running_num -eq ${cluster_nodes} ]]; then
echo "longhorn-manager pods are ready!"
break
fi
echo "check longhorn-manager failure, please deploy longhorn first."
exit 1
done

# ensure instance-manager-e ready
while [ true ]; do
running_num=$(kubectl get pods -n longhorn-system |grep ^instance-manager |grep Running |awk '{print $3}' |wc -l)
if [[ $running_num -eq ${cluster_nodes} ]]; then
echo "instance-manager pods are ready!"
break
fi
echo "check instance-manager failure, please deploy longhorn first."
exit 1
done
}

if [ ! -f $TOP_DIR/kubeconfig ]; then
echo "kubeconfig does not exist. Please create cluster first."
echo "Maybe try new_cluster.sh"
exit 1
fi
echo $TOP_DIR/kubeconfig
export KUBECONFIG=$TOP_DIR/kubeconfig

if [[ $(ensure_command helm) -eq 1 ]]; then
echo "no helm, try to curl..."
curl -O https://get.helm.sh/helm-v3.9.4-linux-amd64.tar.gz
tar -zxvf helm-v3.9.4-linux-amd64.tar.gz
HELM=$TOP_DIR/linux-amd64/helm
$HELM version
else
echo "Get helm, version info as below"
HELM=$(which helm)
$HELM version
fi

cluster_nodes=$(yq -e e '.cluster_size' $TOP_DIR/settings.yaml)
echo "cluster nodes: $cluster_nodes"
ensure_longhorn_ready

pushd $TOP_DIR
cat >> ndm-override.yaml.default << 'EOF'
autoProvisionFilter: [/dev/sd*]
EOF

if [ ! -f ndm-override.yaml ]; then
mv ndm-override.yaml.default ndm-override.yaml
fi

cp -r ../deploy/charts/harvester-node-disk-manager harvester-node-disk-manager

target_img=$(yq -e .image.repository ndm-override.yaml)
echo "install target image: ${target_img}"
$HELM install -f $TOP_DIR/ndm-override.yaml harvester-node-disk-manager ./harvester-node-disk-manager --create-namespace -n harvester-system

wait_ndm_ready
echo "harvester-node-disk-manager is ready"
popd
2 changes: 1 addition & 1 deletion ci/scripts/get-debug-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TARGETNODE="node1"

export KUBECONFIG=kubeconfig

NDMPOD=$(kubectl get pods -n harvester-system --field-selector spec.nodeName=$TARGETNODE |grep ^harvester-node-disk-manager |awk '{print $1}')
NDMPOD=$(kubectl get pods -n harvester-system --field-selector spec.nodeName=$TARGETNODE | grep ^harvester-node-disk-manager |grep -v webhook |awk '{print $1}')

# filter out the redundant Skip log
kubectl logs $NDMPOD -n harvester-system |grep -v Skip
Expand Down
5 changes: 4 additions & 1 deletion ci/scripts/patch-ttl-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

COMMIT=$(git rev-parse --short HEAD)
IMAGE=ttl.sh/node-disk-manager-${COMMIT}
IMAGE_WEBHOOK=ttl.sh/node-disk-manager-webhook-${COMMIT}

yq e -i ".image.repository = \"${IMAGE}\"" ci/charts/ndm-override.yaml
yq e -i ".image.tag = \"1h\"" ci/charts/ndm-override.yaml
yq e -i ".image.tag = \"1h\"" ci/charts/ndm-override.yaml
yq e -i ".webhook.repository = \"${IMAGE_WEBHOOK}\"" ci/charts/ndm-override.yaml
yq e -i ".webhook.tag = \"1h\"" ci/charts/ndm-override.yaml

0 comments on commit 90f01bc

Please sign in to comment.