Skip to content

Commit

Permalink
Merge pull request #42 from chez-shanpu/no-best-path-no-change
Browse files Browse the repository at this point in the history
When there is no best path, it sends nothing to control plane
  • Loading branch information
chez-shanpu committed Jul 28, 2021
2 parents 5c7f8da + b19c4a5 commit 477a1a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/appagent/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ var runCmd = &cobra.Command{
fmt.Printf("[ERROR] %v", err)
os.Exit(1)
}

err = appagent.SendSRInfoToControlPlane(list, tls, cpCertFilePath, cpAddr, appName, srcAddr, dstAddr)
if err != nil {
fmt.Printf("[ERROR] %v", err)
os.Exit(1)
//If there is the best path, it sends that path to control plane
if list != nil {
err = appagent.SendSRInfoToControlPlane(list, tls, cpCertFilePath, cpAddr, appName, srcAddr, dstAddr)
if err != nil {
fmt.Printf("[ERROR] %v", err)
os.Exit(1)
}
} else {
fmt.Println("[INFO] No list was sent.")
}
time.Sleep(time.Duration(interval) * time.Millisecond)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/appagent/appagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func MakeSIDList(graph *dijkstra.Graph, depSids []string, dstSid string) (*[]str
if err != nil {
return nil, fmt.Errorf("failed to searching shortest path: %v", err)
}
// if there is no best path, it returns nil
if best.Distance >= infCost {
fmt.Printf("[INFO] There is no best path. cost: %v \n", best.Distance)
return nil, nil
}

var sids []string
for _, verIndex := range best.Path {
Expand Down

0 comments on commit 477a1a0

Please sign in to comment.