Skip to content

Commit a890d6f

Browse files
committed
support exposing eris for unmatched instance
Signed-off-by: linhaiwei.lhw <[email protected]>
1 parent 7715461 commit a890d6f

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

deploy/helm/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ agent:
2525
tag: "latest"
2626
preferDriver: ""
2727
allocateAllDevices: false
28-
# format: <instance_id> <eri-0>/<eri-1>/...
28+
# format:
29+
# expose specific eris for matched node: - <instance_id> <eri-0>/<eri-1>/...
30+
# expose specific eris for unmatched node: - i-* <eri-0>/<eri-1>/...
31+
# expose all eris for unmatched node: - i-* erdma_*
2932
exposedLocalERIs:
30-
- i-xxx erdma_0/erdma_1
33+
- i-XXX erdma_0/erdma_1
3134
imagePullSecrets: []
3235
nameOverride: ""
3336
fullnameOverride: ""

internal/drivers/utils_linux.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,38 @@ import (
2222
)
2323

2424
func checkExpose(instanceID string, exposedLocalERIs []string, rdmaDevice string) (bool, error) {
25+
var unMatchExposeERIs []string
26+
isMatched := false
2527
if len(exposedLocalERIs) == 1 && exposedLocalERIs[0] == "" {
2628
return true, nil
2729
}
28-
pattern := `^i-\w+\s+(\w+(?:/\w+)*)$`
30+
pattern := `^(i-(?:\w+|\*))\s+((?:(?:\w+)(?:\/\w+)*))$`
2931
re := regexp.MustCompile(pattern)
3032
for _, exposeInfo := range exposedLocalERIs {
3133
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)
3335
}
3436
id := strings.SplitN(exposeInfo, " ", 2)[0]
3537
if instanceID == id {
38+
isMatched = true
3639
exposeERIs := strings.Split(strings.TrimSpace(strings.SplitN(exposeInfo, " ", 2)[1]), "/")
3740
for _, dev := range exposeERIs {
3841
if dev == rdmaDevice {
3942
return true, nil
4043
}
4144
}
4245
}
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+
}
4357
}
4458
return false, nil
4559
}

internal/types/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ type Config struct {
1212
SMCInitImage string `json:"smcInitImage"`
1313
EnableInitContainerInject *bool `json:"enableInitContainerInject"`
1414
NodeSelector map[string]string `json:"nodeSelector"`
15-
LocalERIDiscovery bool `json:"localERIDiscovery"`
1615
}
1716

1817
type Sensitive string

0 commit comments

Comments
 (0)