Skip to content

Commit

Permalink
Fix recommend by latency error
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored Jun 15, 2024
2 parents 98f6dd7 + a2f9942 commit e9bc559
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion conf/setup.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export LOGFILE_MAXSIZE=10
export LOGFILE_MAXBACKUPS=3
export LOGFILE_MAXAGE=30
export LOGFILE_COMPRESS=false
# Set log level, such as trace, debug info, warn, error, fatal, and panic
# Set log level, such as trace, debug, info, warn, error, fatal, and panic
export LOGLEVEL=debug
# Set log writer, such as file, stdout, or both
export LOGWRITER=both
Expand Down
2 changes: 1 addition & 1 deletion src/api/rest/server/middlewares/custom-middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func RequestIdAndDetailsIssuer(next echo.HandlerFunc) echo.HandlerFunc {
// Set Request on the context
c.Set("RequestID", reqID)

log.Trace().Msgf("(Request ID middleware) Request ID: %s", reqID)
//log.Trace().Msgf("(Request ID middleware) Request ID: %s", reqID)
if _, ok := common.RequestMap.Load(reqID); ok {
return fmt.Errorf("the X-Request-Id is already in use")
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func RunServer(port string) {
fmt.Println(" Default CredentialHolder: " + common.DefaultCredentialHolder + "\n")

if enableAuth {
fmt.Println(" Access to API dashboard" + " (username: " + apiUser + " / password: " + apiPass + ")")
fmt.Println(" Access to API dashboard" + " (username: $API_USERNAME / password: $API_PASSWORD)")
}

fmt.Printf(noticeColor, apidashboard)
Expand Down
5 changes: 3 additions & 2 deletions src/core/mcis/recommendation.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func RecommendVmLatency(nsId string, specList *[]mcir.TbSpecInfo, param *[]Param
for i, k := range *specList {
sumLatancy := 0.0
for _, region := range v.Val {
l, _ := GetLatency(region, k.RegionName)
l, _ := GetLatency(region, k.ProviderName+"-"+k.RegionName)
sumLatancy += l
}

Expand Down Expand Up @@ -555,10 +555,11 @@ func getDistance(latitude float64, longitude float64, providerName string, regio

// GetLatency func get latency between given two regions
func GetLatency(src string, dest string) (float64, error) {

latencyString := common.RuntimeLatancyMap[common.RuntimeLatancyMapIndex[src]][common.RuntimeLatancyMapIndex[dest]]
latency, err := strconv.ParseFloat(strings.ReplaceAll(latencyString, " ", ""), 32)
if err != nil {
log.Error().Err(err).Msg("")
log.Info().Err(err).Msgf("Cannot get GetLatency between src: %v, dest: %v (check assets)", src, dest)
return 999999, err
}
return latency, nil
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func setConfig() {
log.Error().Err(err).Msg("")
panic(err)
}
common.PrintCredentialInfo(common.RuntimeCredential)
// common.PrintCredentialInfo(common.RuntimeCredential)
}

// err = common.RegisterAllCloudInfo()
Expand Down

0 comments on commit e9bc559

Please sign in to comment.