Manager REST api for fetching backup status
The following code changes include the REST api for manager to respond back to
UI when it requests for status of the list of backups maintained by an engine.
@@ -46,6 +46,7 @@ type Volume struct {
Replicas []Replica `json:"replicas"`
Controllers []Controller `json:"controllers"`
+ BackupStatus []BackupStatus `json:"backupStatus"`
}
type Snapshot struct {
@@ -199,6 +200,15 @@ type Tag struct {
TagType string `json:"tagType"`
}
+type BackupStatus struct {
+ client.Resource
+ Name string `json:"id"`
+ Snapshot string `json:"snapshot"`
+ Progress int `json:"progress"`
+ BackupURL string `json:"backupURL"`
+ BackupError string `json:"backupError"`
+}
+
func NewSchema() *client.Schemas {
schemas := &client.Schemas{}
@@ -210,6 +220,7 @@ func NewSchema() *client.Schemas {
schemas.AddType("snapshotInput", SnapshotInput{})
schemas.AddType("backup", Backup{})
schemas.AddType("backupInput", BackupInput{})
+ schemas.AddType("backupStatus", BackupStatus{})
schemas.AddType("recurringJob", types.RecurringJob{})
schemas.AddType("replicaRemoveInput", ReplicaRemoveInput{})
schemas.AddType("salvageInput", SalvageInput{})
@@ -506,6 +517,7 @@ func toSettingCollection(settings []*longhorn.Setting) *client.GenericCollection
func toVolumeResource(v *longhorn.Volume, ves []*longhorn.Engine, vrs []*longhorn.Replica, apiContext *api.ApiContext) *Volume {
var ve *longhorn.Engine
controllers := []Controller{}
+ backups := []BackupStatus{}
for _, e := range ves {
controllers = append(controllers, Controller{
Instance: Instance{
@@ -523,6 +535,19 @@ func toVolumeResource(v *longhorn.Volume, ves []*longhorn.Engine, vrs []*longhor
if e.Spec.NodeID == v.Spec.NodeID {
ve = e
}
+ backupStatus := e.Status.BackupStatus
+ if backupStatus != nil {
+ for id, status := range backupStatus {
+ backups = append(backups, BackupStatus{
+ Resource: client.Resource{},
+ Name: id,
+ Snapshot: status.SnapshotName,
+ Progress: status.Progress,
+ BackupURL: status.BackupURL,
+ BackupError: status.BackupError,
+ })
+ }
+ }
}
replicas := []Replica{}
@@ -580,6 +605,7 @@ func toVolumeResource(v *longhorn.Volume, ves []*longhorn.Engine, vrs []*longhor
Controllers: controllers,
Replicas: replicas,
+ BackupStatus: backups,
}
actions := map[string]struct{}{}
