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
23 changes: 23 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,29 @@ func CloudBackupStatusTypeToSdkCloudBackupStatusType(
}
}

func SdkCloudBackupStatusTypeToCloudBackupStatusString(
t SdkCloudBackupStatusType,
) string {
switch t {
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeNotStarted:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a problem with the SDK types. This fixes the issue with the status for the REST API but the SDK status strings still are "SdkCloudBackupStatusTypeDone". Why do users care about what interface was being used in the status string? And the status is already stored in the Backup Status field, so it doesn't need to have redundant information. The status string should just be "Done"

@lpabon lpabon Mar 20, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings cannot be stored or described in gRPC proto file, only enums that is why it is called SdkCloudBackupStatusTypeDone.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That just means the variable names need to be fixed. Please don't merge PRs when changes are requested on them

@disrani-px disrani-px Mar 20, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can look at the CloudMigrate status and stage strings on how to do this correctly: https://github.com/libopenstorage/openstorage/blob/master/api/api.pb.go#L992

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this needs to be fixed for all the other SDK strings too

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@disrani-px the method you have above works well. Please write an issue so that we can fix all the values in the SDK to use that model. In the mean time, release-6.0 needs to have the current model.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'll create it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #962

return string(CloudBackupStatusNotStarted)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeDone:
return string(CloudBackupStatusDone)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeAborted:
return string(CloudBackupStatusAborted)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypePaused:
return string(CloudBackupStatusPaused)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeStopped:
return string(CloudBackupStatusStopped)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeActive:
return string(CloudBackupStatusActive)
case SdkCloudBackupStatusType_SdkCloudBackupStatusTypeFailed:
return string(CloudBackupStatusFailed)
default:
return string(CloudBackupStatusFailed)
}
}

func StringToSdkCloudBackupStatusType(s string) SdkCloudBackupStatusType {
return CloudBackupStatusTypeToSdkCloudBackupStatusType(CloudBackupStatusType(s))
}
Expand Down
2 changes: 1 addition & 1 deletion api/server/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (vd *volAPI) cloudBackupEnumerate(w http.ResponseWriter, r *http.Request) {
SrcVolumeName: v.SrcVolumeName,
Timestamp: prototime.TimestampToTime(v.Timestamp),
Metadata: v.Metadata,
Status: v.Status.String(),
Status: api.SdkCloudBackupStatusTypeToCloudBackupStatusString(v.Status),
}
enumerateResp.Backups = append(enumerateResp.Backups, item)
}
Expand Down
1 change: 0 additions & 1 deletion api/server/sdk/cloud_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (s *CloudBackupServer) EnumerateWithFilters(
if err != nil {
return nil, err
}
return nil, status.Error(codes.InvalidArgument, "Must provide credential uuid")
} else {
if err := s.checkAccessToCredential(ctx, req.GetCredentialId()); err != nil {
return nil, err
Expand Down