Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/common/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func RemoveLabel(ctx context.Context, labelType, uid, key string) error {

err = kvstore.Put(labelKey, string(updatedLabelData))
if err != nil {
log.Error().Err(err).Msgf("")
log.Error().Err(err).Msg("")
return err
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/common/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func CreateNs(ctx context.Context, u *model.NsReq) (model.NsInfo, error) {

if check {
temp := model.NsInfo{}
err := fmt.Errorf("CreateNs(); The namespace " + u.Name + " already exists.")
err := fmt.Errorf("CreateNs(); The namespace %s already exists.", u.Name)
return temp, err
}

Expand Down
17 changes: 7 additions & 10 deletions src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ func CheckString(name string) error {
filtered := r.FindString(name)

if filtered != name {
err := fmt.Errorf(name + ": The name must follow these rules: " +
"1. The first character must be a letter (case-insensitive). " +
"2. All following characters can be a dash, letter (case-insensitive), digit, or +. " +
"3. The last character cannot be a dash.")
err := fmt.Errorf("%s: The name must follow these rules: 1. The first character must be a letter (case-insensitive). 2. All following characters can be a dash, letter (case-insensitive), digit, or +. 3. The last character cannot be a dash.", name)
return err
}

Expand Down Expand Up @@ -491,7 +488,7 @@ func GetConnConfig(ConnConfigName string) (model.ConnConfig, error) {
return model.ConnConfig{}, err
}
if !exists {
return model.ConnConfig{}, fmt.Errorf("Cannot find the model.ConnConfig " + key)
return model.ConnConfig{}, fmt.Errorf("Cannot find the model.ConnConfig %s", key)
}
err = json.Unmarshal([]byte(keyValue.Value), &connConfig)
if err != nil {
Expand Down Expand Up @@ -1420,7 +1417,7 @@ func RetrieveRegionListFromCsp() (model.RetrievedRegionList, error) {

switch {
case resp.StatusCode() >= 400 || resp.StatusCode() < 200:
err := fmt.Errorf(string(resp.Body()))
err := fmt.Errorf("%s", string(resp.Body()))
log.Error().Err(err).Msg("")
content := model.RetrievedRegionList{}
return content, err
Expand Down Expand Up @@ -1672,7 +1669,7 @@ func GetAvailableK8sVersion(providerName string, regionName string) (*[]model.K8
region = strings.ToLower(region)
if strings.EqualFold(region, regionName) {
if len(versionDetail.Available) == 0 {
availableVersion = &[]model.K8sClusterVersionDetailAvailable{{model.StrEmpty, model.StrEmpty}}
availableVersion = &[]model.K8sClusterVersionDetailAvailable{{Name: model.StrEmpty, Id: model.StrEmpty}}
} else {
availableVersion = &versionDetail.Available
}
Expand All @@ -1687,7 +1684,7 @@ func GetAvailableK8sVersion(providerName string, regionName string) (*[]model.K8
region = strings.ToLower(region)
if strings.EqualFold(region, model.StrCommon) {
if len(versionDetail.Available) == 0 {
availableVersion = &[]model.K8sClusterVersionDetailAvailable{{model.StrEmpty, model.StrEmpty}}
availableVersion = &[]model.K8sClusterVersionDetailAvailable{{Name: model.StrEmpty, Id: model.StrEmpty}}
} else {
availableVersion = &versionDetail.Available
}
Expand Down Expand Up @@ -1721,7 +1718,7 @@ func GetAvailableK8sNodeImage(providerName string, regionName string) (*[]model.
region = strings.ToLower(region)
if strings.EqualFold(region, regionName) {
if len(nodeImageDetail.Available) == 0 {
availableNodeImage = &[]model.K8sClusterNodeImageDetailAvailable{{model.StrEmpty, model.StrEmpty}}
availableNodeImage = &[]model.K8sClusterNodeImageDetailAvailable{{Name: model.StrEmpty, Id: model.StrEmpty}}
break
} else {
availableNodeImage = &nodeImageDetail.Available
Expand All @@ -1737,7 +1734,7 @@ func GetAvailableK8sNodeImage(providerName string, regionName string) (*[]model.
region = strings.ToLower(region)
if strings.EqualFold(region, model.StrCommon) {
if len(nodeImageDetail.Available) == 0 {
availableNodeImage = &[]model.K8sClusterNodeImageDetailAvailable{{model.StrEmpty, model.StrEmpty}}
availableNodeImage = &[]model.K8sClusterNodeImageDetailAvailable{{Name: model.StrEmpty, Id: model.StrEmpty}}
break
} else {
availableNodeImage = &nodeImageDetail.Available
Expand Down
30 changes: 17 additions & 13 deletions src/core/infra/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func CallMilkyway(wg *sync.WaitGroup, nodeList []string, nsId string, infraId st
// fmt.Println("HTTP Status code: " + strconv.Itoa(res.StatusCode))
switch {
case res.StatusCode >= 400 || res.StatusCode < 200:
err := fmt.Errorf(string(body))
err := fmt.Errorf("%s", string(body))
log.Error().Err(err).Msg("")
errStr = err.Error()
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func RunAllBenchmarks(nsId string, infraId string, host string) (*model.Benchmar

if !check {
temp := &model.BenchmarkInfoArray{}
err := fmt.Errorf("The infra " + infraId + " does not exist.")
err := fmt.Errorf("The infra %s does not exist.", infraId)
return temp, err
}

Expand Down Expand Up @@ -226,6 +226,10 @@ func RunAllBenchmarks(nsId string, infraId string, host string) (*model.Benchmar
}

file, err := os.OpenFile("benchmarking.csv", os.O_CREATE|os.O_WRONLY, 0777)
if err != nil {
log.Error().Err(err).Msg("Failed to open benchmarking.csv")
return &content, err
}
defer file.Close()
csvWriter := csv.NewWriter(file)
strsTmp := []string{}
Expand Down Expand Up @@ -340,15 +344,15 @@ func RunAllBenchmarks(nsId string, infraId string, host string) (*model.Benchmar
}

file2, err := os.OpenFile("cloudlatencymap.csv", os.O_CREATE|os.O_WRONLY, 0777)
if err != nil {
log.Error().Err(err).Msg("Failed to open cloudlatencymap.csv")
return nil, err
}
defer file2.Close()
csvWriter2 := csv.NewWriter(file2)
csvWriter2.WriteAll(mrttArray)
csvWriter2.Flush()

if err != nil {
return nil, fmt.Errorf("Benchmark Error")
}

return &content, nil
}

Expand All @@ -374,7 +378,7 @@ func RunLatencyBenchmark(nsId string, infraId string, host string) (*model.Bench

if !check {
temp := &model.BenchmarkInfoArray{}
err := fmt.Errorf("The infra " + infraId + " does not exist.")
err := fmt.Errorf("The infra %s does not exist.", infraId)
return temp, err
}

Expand Down Expand Up @@ -479,15 +483,15 @@ func RunLatencyBenchmark(nsId string, infraId string, host string) (*model.Bench
}

file2, err := os.OpenFile("cloudlatencymap.csv", os.O_CREATE|os.O_WRONLY, 0777)
if err != nil {
log.Error().Err(err).Msg("Failed to open cloudlatencymap.csv")
return nil, err
}
defer file2.Close()
csvWriter2 := csv.NewWriter(file2)
csvWriter2.WriteAll(mrttArray)
csvWriter2.Flush()

if err != nil {
return nil, fmt.Errorf("Benchmark Error")
}

return &content, nil
}

Expand All @@ -513,7 +517,7 @@ func CoreGetBenchmark(nsId string, infraId string, action string, host string) (

if !check {
temp := &model.BenchmarkInfoArray{}
err := fmt.Errorf("The infra " + infraId + " does not exist.")
err := fmt.Errorf("The infra %s does not exist.", infraId)
return temp, err
}

Expand All @@ -536,7 +540,7 @@ func CoreGetBenchmark(nsId string, infraId string, action string, host string) (
}

if err != nil {
return nil, fmt.Errorf("Benchmark Error")
return nil, fmt.Errorf("Benchmark Error: %w", err)
}

return &content, nil
Expand Down
10 changes: 5 additions & 5 deletions src/core/infra/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func HandleInfraAction(nsId string, infraId string, action string, force bool) (
check, _ := CheckInfra(nsId, infraId)

if !check {
err := fmt.Errorf("The infra " + infraId + " does not exist.")
err := fmt.Errorf("The infra %s does not exist.", infraId)
return err.Error(), err
}

Expand Down Expand Up @@ -232,7 +232,7 @@ func HandleInfraAction(nsId string, infraId string, action string, force bool) (
return "Refined the Infra", nil

} else {
return "", fmt.Errorf(action + " not supported")
return "", fmt.Errorf("%s not supported", action)
}
}

Expand All @@ -259,7 +259,7 @@ func HandleInfraNodeAction(nsId string, infraId string, nodeId string, action st
check, _ := CheckNode(nsId, infraId, nodeId)

if !check {
err := fmt.Errorf("The vm " + nodeId + " does not exist.")
err := fmt.Errorf("The vm %s does not exist.", nodeId)
return err.Error(), err
}

Expand Down Expand Up @@ -311,7 +311,7 @@ func HandleInfraNodeAction(nsId string, infraId string, nodeId string, action st
} else {
close(results)
wg.Done()
return "", fmt.Errorf("not supported action: " + action)
return "", fmt.Errorf("not supported action: %s", action)
}
checkErr := <-results
if checkErr.Error != nil {
Expand Down Expand Up @@ -974,7 +974,7 @@ func ControlNodeAsync(wg *sync.WaitGroup, nsId string, infraId string, nodeId st

// Prevent malformed cspResourceName
if cspResourceName == "" || common.CheckString(cspResourceName) != nil {
callResult.Error = fmt.Errorf("Not valid requested CSPNativeNodeId: [" + cspResourceName + "]")
callResult.Error = fmt.Errorf("Not valid requested CSPNativeNodeId: [%s]", cspResourceName)
// temp.Status = model.StatusFailed
temp.SystemMessage = callResult.Error.Error()
UpdateNodeInfo(nsId, infraId, temp)
Expand Down
Loading