Skip to content

Commit cdcea4c

Browse files
authored
Using jq to parse the default CNI for improved script robustness (#5183) (#5186)
* Using jq to parse the default CNI for improved script robustness (#5183) Signed-off-by: Cyclinder Kuo <[email protected]> * e2e: fix kubevirt vm can't running (#5178) --------- Signed-off-by: Cyclinder Kuo <[email protected]>
1 parent 2f83ecf commit cdcea4c

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ e2e_test:
343343

344344
.PHONY: e2e_test_spiderpool
345345
e2e_test_spiderpool:
346-
$(QUIET) make e2e_test -e INSTALL_OVERLAY_CNI=false -e E2E_SPIDERPOOL_ENABLE_SUBNET=true
346+
$(QUIET) make e2e_test -e INSTALL_OVERLAY_CNI=false -e E2E_SPIDERPOOL_ENABLE_SUBNET=true
347347

348348
.PHONY: e2e_test_calico
349349
e2e_test_calico:

charts/spiderpool/templates/configmap.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ data:
172172
cat /host/etc/cni/net.d/${DEFAULT_CNI_FILEPATH}
173173
174174
echo ""
175-
DEFAULT_CNI_NAME=$(grep '"name":' ${CNI_CONF_DIR}/${DEFAULT_CNI_FILEPATH} | awk '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d ',' | tr -d '"')
175+
176+
DEFAULT_CNI_NAME=$(jq -r '.name' ${CNI_CONF_DIR}/${DEFAULT_CNI_FILEPATH})
176177
if [ -z "$DEFAULT_CNI_NAME" ] ; then
177178
error "The name fleid shouldn't be empty, please check the default cni: ${DEFAULT_CNI_FILEPATH}" && exit 1
178179
fi
179180
180181
log "Updating the clusterNetwork of the multus-cni config to $DEFAULT_CNI_NAME"
181-
sed -i "s?\"clusterNetwork\": \"\"?\"clusterNetwork\": \"${DEFAULT_CNI_NAME}\"?g" /tmp/00-multus.conf
182+
jq ".clusterNetwork=\"${DEFAULT_CNI_NAME}\"" /tmp/00-multus.conf > /tmp/00-multus.conf.tmp && mv /tmp/00-multus.conf.tmp /tmp/00-multus.conf
182183
else
183184
log "User set multus ClusterNetwork: $MULTUS_CLUSTER_NETWORK"
184185
fi

images/spiderpool-agent/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Copyright 2022 Authors of spidernet-io
22
# SPDX-License-Identifier: Apache-2.0
33

4-
ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:163aca9e9d927363fa80aca7d9721b379671a790
5-
ARG GOLANG_IMAGE=docker.io/library/golang:1.24.2
4+
ARG BASE_IMAGE=ghcr.io/spidernet-io/spiderpool/spiderpool-base:e5de792a4214e67a4d10a6faf476fef3d9f043ca
5+
ARG GOLANG_IMAGE=docker.io/library/golang:1.24.5@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088
66

77
#======= build bin ==========
88
FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} AS builder

images/spiderpool-base/install-others.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ packages=(
1414
libmnl0
1515
bash-completion
1616
iptables
17+
jq
1718
)
1819

1920

test/scripts/debugEnv.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ elif [ "$TYPE"x == "detail"x ] ; then
203203
echo "--------- kubectl get configmaps -n kube-system spiderpool-conf -ojson"
204204
kubectl get configmaps -n kube-system spiderpool-conf -ojson --kubeconfig ${E2E_KUBECONFIG}
205205

206+
echo ""
207+
echo "--------- kubectl get virtualmachineinstance -A -o json"
208+
kubectl get virtualmachineinstance -A -o json --kubeconfig ${E2E_KUBECONFIG}
209+
210+
echo ""
211+
echo "--------- kubectl get virtualmachine -A -o json"
212+
kubectl get virtualmachine -A -o json --kubeconfig ${E2E_KUBECONFIG}
213+
206214
echo ""
207215
echo "=============== IPAM log ============== "
208216
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-"spider"}

test/scripts/install-kubevirt.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ kubectl wait --for=condition=ready -l app.kubernetes.io/component=kubevirt -n ku
6464
# If the kind cluster runs on a virtual machine consider enabling nested virtualization.
6565
# Enable the network Passt and LiveMigration feature.
6666
# We need to wait for all kubevirt component pods ready(webhook ready) to submit the patch action.
67-
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true,"featureGates": ["Passt"]}}}}' --kubeconfig ${E2E_KUBECONFIG}
67+
# NOTE: set "disableSerialConsoleLog" to avoid the log of serial console issue, it leads to the kubevirt vm pod can't running
68+
# see: https://github.com/kubevirt/kubevirt/issues/15355, https://github.com/spidernet-io/spiderpool/issues/5177
69+
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true},"virtualMachineOptions": {"disableSerialConsoleLog": {},"featureGates": ["Passt"]}}}}' --kubeconfig ${E2E_KUBECONFIG}
6870

6971
sleep 1
7072

0 commit comments

Comments
 (0)