Skip to content

Commit bc90990

Browse files
authored
Merge pull request #1502 from k8s-infra-cherrypick-robot/cherry-pick-1491-to-release-1.29
[release-1.29] test: enable cloudprovider_azure metrics print
2 parents f478b38 + a0b368e commit bc90990

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

.trivyignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
CVE-2023-39325
2+
CVE-2023-44487

hack/verify-examples.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ rollout_and_wait() {
3030

3131
APPNAME=$(kubectl apply -f $1 | grep -E "^(:?daemonset|deployment|statefulset|pod)" | awk '{printf $1}')
3232
if [[ -n $(expr "${APPNAME}" : "\(daemonset\|deployment\|statefulset\)" || true) ]]; then
33-
kubectl rollout status $APPNAME --watch --timeout=5m
33+
kubectl rollout status $APPNAME --watch --timeout=10m
3434
else
35-
kubectl wait "${APPNAME}" --for condition=ready --timeout=5m
35+
kubectl wait "${APPNAME}" --for condition=ready --timeout=10m
3636
fi
3737
}
3838

@@ -63,4 +63,4 @@ for EXAMPLE in "${EXAMPLES[@]}"; do
6363
rollout_and_wait $EXAMPLE
6464
done
6565

66-
echo "deployment examples running completed."
66+
echo "deployment examples running completed."

test/e2e/dynamic_provisioning_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,11 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
13221322

13231323
// print azure file driver logs before driver restart
13241324
azurefileLog := testCmd{
1325-
command: "bash",
1326-
args: []string{"test/utils/azurefile_log.sh"},
1327-
startLog: "===================azurefile log (before restart)===================",
1328-
endLog: "====================================================================",
1325+
command: "bash",
1326+
args: []string{"test/utils/azurefile_log.sh"},
1327+
startLog: "===================azurefile log (before restart)===================",
1328+
endLog: "====================================================================",
1329+
ignoreError: true,
13291330
}
13301331
execTestCmd([]testCmd{azurefileLog})
13311332

test/e2e/suite_test.go

+16-9
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ var (
6666
)
6767

6868
type testCmd struct {
69-
command string
70-
args []string
71-
startLog string
72-
endLog string
69+
command string
70+
args []string
71+
startLog string
72+
endLog string
73+
ignoreError bool
7374
}
7475

7576
var _ = ginkgo.BeforeSuite(func(ctx ginkgo.SpecContext) {
@@ -181,10 +182,11 @@ var _ = ginkgo.AfterSuite(func(ctx ginkgo.SpecContext) {
181182
execTestCmd([]testCmd{createExampleDeployment})
182183

183184
azurefileLog := testCmd{
184-
command: "bash",
185-
args: []string{"test/utils/azurefile_log.sh"},
186-
startLog: "===================azurefile log===================",
187-
endLog: "===================================================",
185+
command: "bash",
186+
args: []string{"test/utils/azurefile_log.sh"},
187+
startLog: "===================azurefile log===================",
188+
endLog: "===================================================",
189+
ignoreError: true,
188190
}
189191
e2eTeardown := testCmd{
190192
command: "make",
@@ -258,7 +260,12 @@ func execTestCmd(cmds []testCmd) {
258260
cmdSh.Stdout = os.Stdout
259261
cmdSh.Stderr = os.Stderr
260262
err = cmdSh.Run()
261-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
263+
if err != nil {
264+
log.Println(err)
265+
if !cmd.ignoreError {
266+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
267+
}
268+
}
262269
log.Println(cmd.endLog)
263270
}
264271
}

test/utils/azurefile_log.sh

+16-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ if [[ "$#" -gt 0 ]]; then
2323
DRIVER=$1
2424
fi
2525

26+
cleanup() {
27+
echo "hit unexpected error during log print, exit 0"
28+
exit 0
29+
}
30+
31+
trap cleanup ERR
32+
2633
echo "print out all nodes status ..."
2734
kubectl get nodes -o wide
2835
echo "======================================================================================"
@@ -63,7 +70,12 @@ kubectl get pods -n${NS} -l${LABEL} \
6370
| awk 'NR>1 {print $1}' \
6471
| xargs -I {} bash -c "echo 'dumping logs for ${NS}/{}/${DRIVER}' && kubectl logs {} -c${CONTAINER} -n${NS}"
6572

66-
#echo "print out cloudprovider_azure metrics ..."
67-
#echo "======================================================================================"
68-
#ip=`kubectl get svc csi-${DRIVER}-controller -n kube-system | awk '{print $4}'`
69-
#curl http://$ip:29614/metrics
73+
echo "======================================================================================"
74+
ip=`kubectl get svc csi-${DRIVER}-controller -n kube-system | awk '{print $4}'`
75+
if echo "$ip" | grep -q "\."; then
76+
echo "print out cloudprovider_azure metrics ..."
77+
curl http://$ip:29614/metrics
78+
else
79+
echo "csi-$DRIVER-controller service ip is empty"
80+
kubectl get svc csi-$DRIVER-controller -n kube-system
81+
fi

0 commit comments

Comments
 (0)