Skip to content

Commit

Permalink
fix a case when customer does not provide -p option
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyufan2 committed Apr 12, 2024
1 parent aa89292 commit 820a8ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ const (
// envVarEnableCNIConflistGeneration enables cni conflist generation if set (value doesn't matter)
envVarEnableCNIConflistGeneration = "CNS_ENABLE_CNI_CONFLIST_GENERATION"

cnsReqTimeout = 15 * time.Second
defaultAPIServerIP = "localhost"
cnsReqTimeout = 15 * time.Second
defaultLocalServerIP = "localhost"
defaultLocalServerPort = "10090"
)

type cniConflistScenario string
Expand Down Expand Up @@ -890,11 +891,17 @@ func main() {
if config.Server.EnableLocalServer {
logger.Printf("[Azure CNS] Start HTTP local server")

var localServerURL string
if config.Server.Port != "" {
localServerURL = fmt.Sprintf(defaultLocalServerIP + ":" + config.Server.Port)
} else {
localServerURL = fmt.Sprintf(defaultLocalServerIP + ":" + defaultLocalServerPort)
}

httpLocalRestService := restserverv2.New(httpRemoteRestService)
if httpLocalRestService != nil {
defaultAPIServerURL := fmt.Sprintf(defaultAPIServerIP + ":" + config.Server.Port)
go func() {
err = httpLocalRestService.Start(rootCtx, defaultAPIServerURL)
err = httpLocalRestService.Start(rootCtx, localServerURL)
if err != nil {
logger.Errorf("Failed to start local echo server, err:%v.\n", err)
return
Expand Down

0 comments on commit 820a8ca

Please sign in to comment.