@@ -22,24 +22,38 @@ import (
22
22
)
23
23
24
24
func checkExpose (instanceID string , exposedLocalERIs []string , rdmaDevice string ) (bool , error ) {
25
+ var unMatchExposeERIs []string
26
+ isMatched := false
25
27
if len (exposedLocalERIs ) == 1 && exposedLocalERIs [0 ] == "" {
26
28
return true , nil
27
29
}
28
- pattern := `^i- \w+\ s+(\w+(?:/\w+)*)$`
30
+ pattern := `^(i-(?: \w+|\*))\ s+((?:(?: \w+) (?:\ /\w+)*) )$`
29
31
re := regexp .MustCompile (pattern )
30
32
for _ , exposeInfo := range exposedLocalERIs {
31
33
if ! re .MatchString (exposeInfo ) {
32
- return false , fmt .Errorf ("invalid format %s. Expected format: \" instanceID: interface1 interface2 ... \" " , exposeInfo )
34
+ return false , fmt .Errorf ("invalid format %s" , exposeInfo )
33
35
}
34
36
id := strings .SplitN (exposeInfo , " " , 2 )[0 ]
35
37
if instanceID == id {
38
+ isMatched = true
36
39
exposeERIs := strings .Split (strings .TrimSpace (strings .SplitN (exposeInfo , " " , 2 )[1 ]), "/" )
37
40
for _ , dev := range exposeERIs {
38
41
if dev == rdmaDevice {
39
42
return true , nil
40
43
}
41
44
}
42
45
}
46
+ if id == "i-*" {
47
+ unMatchExposeERIs = strings .Split (strings .TrimSpace (strings .SplitN (exposeInfo , " " , 2 )[1 ]), "/" )
48
+ }
49
+ }
50
+ if ! isMatched {
51
+ driverLog .Info ("no matched instanceID found, using unMatchExposeERIs" , "instanceID" , instanceID )
52
+ for _ , dev := range unMatchExposeERIs {
53
+ if dev == "erdma_*" || dev == rdmaDevice {
54
+ return true , nil
55
+ }
56
+ }
43
57
}
44
58
return false , nil
45
59
}
0 commit comments