Skip to content

Commit

Permalink
fix: use safe set in client daemon network_topology.go (#3276)
Browse files Browse the repository at this point in the history
Signed-off-by: XZ <834756128@qq.com>
  • Loading branch information
fcgxz2003 authored May 16, 2024
1 parent 6c44d25 commit 4aa9a7e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/daemon/networktopology/network_topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

"d7y.io/dragonfly/v2/client/config"
logger "d7y.io/dragonfly/v2/internal/dflog"
"d7y.io/dragonfly/v2/pkg/container/set"
"d7y.io/dragonfly/v2/pkg/net/ping"
schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
)
Expand Down Expand Up @@ -154,8 +155,8 @@ func (nt *networkTopology) syncProbes() error {
// we will send the probe result to the scheduler.
func (nt *networkTopology) pingHosts(destHosts []*v1.Host) ([]*schedulerv1.Probe, []*schedulerv1.FailedProbe) {
var (
probes []*schedulerv1.Probe
failedProbes []*schedulerv1.FailedProbe
probes = set.NewSafeSet[*schedulerv1.Probe]()
failedProbes = set.NewSafeSet[*schedulerv1.FailedProbe]()
)

wg := &sync.WaitGroup{}
Expand All @@ -166,7 +167,7 @@ func (nt *networkTopology) pingHosts(destHosts []*v1.Host) ([]*schedulerv1.Probe

stats, err := ping.Ping(destHost.Ip)
if err != nil {
failedProbes = append(failedProbes, &schedulerv1.FailedProbe{
failedProbes.Add(&schedulerv1.FailedProbe{
Host: &v1.Host{
Id: destHost.Id,
Ip: destHost.Ip,
Expand All @@ -182,7 +183,7 @@ func (nt *networkTopology) pingHosts(destHosts []*v1.Host) ([]*schedulerv1.Probe
return
}

probes = append(probes, &schedulerv1.Probe{
probes.Add(&schedulerv1.Probe{
Host: &v1.Host{
Id: destHost.Id,
Ip: destHost.Ip,
Expand All @@ -199,5 +200,5 @@ func (nt *networkTopology) pingHosts(destHosts []*v1.Host) ([]*schedulerv1.Probe
}

wg.Wait()
return probes, failedProbes
return probes.Values(), failedProbes.Values()
}

0 comments on commit 4aa9a7e

Please sign in to comment.