Skip to content

Commit d6a5fa3

Browse files
authored
Merge pull request kubernetes#88520 from bertinatto/fix-csi-mock-test-for-conformance
Don't rely on contents of optional Condition fields in CSI mock test
2 parents 7937745 + 34206a6 commit d6a5fa3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

test/e2e/storage/csi_mock_volume.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"crypto/sha256"
2222
"encoding/json"
2323
"fmt"
24-
"regexp"
2524
"strconv"
2625
"strings"
2726
"time"
@@ -356,7 +355,6 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
356355
ginkgo.Context("CSI volume limit information using mock driver", func() {
357356
ginkgo.It("should report attach limit when limit is bigger than 0 [Slow]", func() {
358357
// define volume limit to be 2 for this test
359-
360358
var err error
361359
init(testParameters{attachLimit: 2})
362360
defer cleanup()
@@ -563,19 +561,15 @@ var _ = utils.SIGDescribe("CSI mock volume", func() {
563561
})
564562

565563
func waitForMaxVolumeCondition(pod *v1.Pod, cs clientset.Interface) error {
566-
reg, err := regexp.Compile(`max.+volume.+count`)
567-
if err != nil {
568-
return err
569-
}
570564
waitErr := wait.PollImmediate(10*time.Second, csiPodUnschedulableTimeout, func() (bool, error) {
571-
pod, err = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
565+
pod, err := cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
572566
if err != nil {
573567
return false, err
574568
}
575-
conditions := pod.Status.Conditions
576-
for _, condition := range conditions {
577-
matched := reg.MatchString(condition.Message)
578-
if condition.Reason == v1.PodReasonUnschedulable && matched {
569+
for _, c := range pod.Status.Conditions {
570+
// Conformance tests cannot rely on specific output of optional fields (e.g., Reason
571+
// and Message) because these fields are not suject to the deprecation policy.
572+
if c.Type == v1.PodScheduled && c.Status == v1.ConditionFalse && c.Reason != "" && c.Message != "" {
579573
return true, nil
580574
}
581575
}

0 commit comments

Comments
 (0)