diff --git a/cmd/appagent/app/run.go b/cmd/appagent/app/run.go index 7a8e981..52d8f06 100644 --- a/cmd/appagent/app/run.go +++ b/cmd/appagent/app/run.go @@ -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) } diff --git a/pkg/appagent/appagent.go b/pkg/appagent/appagent.go index 91a7116..ecba83f 100644 --- a/pkg/appagent/appagent.go +++ b/pkg/appagent/appagent.go @@ -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 {