Skip to content

Commit 8f7ccbd

Browse files
shivamerlaSneha Rai
andauthored
Fix to perform discovery on all discoveryIPs returned by CSP (#105) (#106)
Signed-off-by: Sneha Rai <[email protected]> Co-authored-by: Sneha Rai <[email protected]>
1 parent d7ff47f commit 8f7ccbd

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

linux/iscsi.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {
649649

650650
var isDiscoveryIpReachable bool
651651
var out string
652+
var outList []string
652653
for _, discoveryIP := range discoveryIPs {
653654
// find the first discovery ip which is reachable
654655
isDiscoveryIpReachable, err = isReachable("", discoveryIP)
@@ -662,7 +663,7 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {
662663
log.Error(err.Error())
663664
continue
664665
}
665-
break
666+
outList = append(outList, out)
666667
}
667668
}
668669

@@ -674,24 +675,26 @@ func PerformDiscovery(discoveryIPs []string) (a model.IscsiTargets, err error) {
674675
return nil, err
675676
}
676677

677-
log.Trace(out)
678+
log.Trace(outList)
678679

679680
var iscsiTargets model.IscsiTargets
680681
// parse the lines into output
681682
r := regexp.MustCompile(getIscsiadmPattern())
682683

683-
listOut := r.FindAllString(out, -1)
684-
685-
for _, line := range listOut {
686-
result := util.FindStringSubmatchMap(line, r)
687-
target := &model.IscsiTarget{
688-
Name: result["target"],
689-
Address: result["address"],
690-
Port: result["port"],
684+
for _, outItem := range outList {
685+
listOut := r.FindAllString(outItem, -1)
686+
for _, line := range listOut {
687+
result := util.FindStringSubmatchMap(line, r)
688+
target := &model.IscsiTarget{
689+
Name: result["target"],
690+
Address: result["address"],
691+
Port: result["port"],
692+
}
693+
log.Tracef("Name %s Address %s Port %s", target.Name, target.Address, target.Port)
694+
iscsiTargets = append(iscsiTargets, target)
691695
}
692-
log.Tracef("Name %s Address %s Port %s", target.Name, target.Address, target.Port)
693-
iscsiTargets = append(iscsiTargets, target)
694696
}
697+
695698
uniqueIscsiTargets := removeDuplicateTargets(iscsiTargets)
696699

697700
return uniqueIscsiTargets, err
@@ -982,3 +985,4 @@ func bindIface(network model.NetworkInterface) error {
982985
}
983986
return nil
984987
}
988+

0 commit comments

Comments
 (0)