Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance error handling for list disks #1295

Merged
merged 1 commit into from
Feb 21, 2023
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
12 changes: 7 additions & 5 deletions src/core/mcir/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,9 +1013,11 @@ func ListResource(nsId string, resourceType string, filterKey string, filterVal
newObj, err := GetResource(nsId, common.StrDataDisk, tempObj.Id)
if err != nil {
common.CBLog.Error(err)
return nil, err
tempObj.Status = "Failed"
tempObj.SystemMessage = err.Error()
} else {
tempObj = newObj.(TbDataDiskInfo)
}
tempObj = newObj.(TbDataDiskInfo)

// Check the JSON body inclues both filterKey and filterVal strings. (assume key and value)
if filterKey != "" {
Expand Down Expand Up @@ -1387,7 +1389,7 @@ func GetResource(nsId string, resourceType string, resourceId string) (interface
err = json.Unmarshal([]byte(keyValue.Value), &res)
if err != nil {
common.CBLog.Error(err)
return nil, err
return res, err
}

// Update TB DataDisk object's 'status' field
Expand All @@ -1409,7 +1411,7 @@ func GetResource(nsId string, resourceType string, resourceId string) (interface
resp, err := req.Get(url)
if err != nil {
common.CBLog.Error(err)
return nil, err
return res, err
}

fmt.Printf("HTTP Status code: %d \n", resp.StatusCode())
Expand All @@ -1418,7 +1420,7 @@ func GetResource(nsId string, resourceType string, resourceId string) (interface
err := fmt.Errorf(string(resp.Body()))
fmt.Println("body: ", string(resp.Body()))
common.CBLog.Error(err)
return nil, err
return res, err
}

updatedSpiderDisk := resp.Result().(*SpiderDiskInfo)
Expand Down
6 changes: 5 additions & 1 deletion src/core/mcir/datadisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ type TbDataDiskInfo struct {
CreatedTime time.Time `json:"createdTime,omitempty" example:"2022-10-12T05:09:51.05Z"`
KeyValueList []common.KeyValue `json:"keyValueList,omitempty"`
Description string `json:"description,omitempty" example:"Available"`
IsAutoGenerated bool `json:"isAutoGenerated,omitempty"`

// Latest system message such as error message
SystemMessage string `json:"systemMessage" example:"Failed because ..." default:""` // systeam-given string message

IsAutoGenerated bool `json:"isAutoGenerated,omitempty"`

// SystemLabel is for describing the MCIR in a keyword (any string can be used) for special System purpose
SystemLabel string `json:"systemLabel,omitempty" example:"Managed by CB-Tumblebug" default:""`
Expand Down