storagenode/gracefulexit: fix exit-status command output
When exit succeeded, cli should display `Y` in Successful column and `100%` in PercentComplete. Change-Id: I6093eca207ecd618bb332af12e5e455bc8224dde
This commit is contained in:
parent
6dc948da46
commit
07c2824d94
@ -133,13 +133,14 @@ func (e *Endpoint) GetExitProgress(ctx context.Context, req *pb.GetExitProgressR
|
|||||||
}
|
}
|
||||||
|
|
||||||
var percentCompleted float32
|
var percentCompleted float32
|
||||||
var hasCompleted bool
|
var exitSucceeded bool
|
||||||
|
|
||||||
if progress.StartingDiskUsage != 0 {
|
if progress.StartingDiskUsage != 0 {
|
||||||
percentCompleted = (float32(progress.BytesDeleted) / float32(progress.StartingDiskUsage)) * 100
|
percentCompleted = (float32(progress.BytesDeleted) / float32(progress.StartingDiskUsage)) * 100
|
||||||
}
|
}
|
||||||
if progress.CompletionReceipt != nil {
|
if progress.Status == satellites.ExitSucceeded {
|
||||||
hasCompleted = true
|
exitSucceeded = true
|
||||||
|
percentCompleted = float32(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Progress = append(resp.Progress,
|
resp.Progress = append(resp.Progress,
|
||||||
@ -147,7 +148,7 @@ func (e *Endpoint) GetExitProgress(ctx context.Context, req *pb.GetExitProgressR
|
|||||||
DomainName: domain,
|
DomainName: domain,
|
||||||
NodeId: progress.SatelliteID,
|
NodeId: progress.SatelliteID,
|
||||||
PercentComplete: percentCompleted,
|
PercentComplete: percentCompleted,
|
||||||
Successful: hasCompleted,
|
Successful: exitSucceeded,
|
||||||
CompletionReceipt: progress.CompletionReceipt,
|
CompletionReceipt: progress.CompletionReceipt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -34,6 +34,7 @@ type ExitProgress struct {
|
|||||||
StartingDiskUsage int64
|
StartingDiskUsage int64
|
||||||
BytesDeleted int64
|
BytesDeleted int64
|
||||||
CompletionReceipt []byte
|
CompletionReceipt []byte
|
||||||
|
Status int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Satellite contains the satellite and status
|
// Satellite contains the satellite and status
|
||||||
|
@ -94,7 +94,7 @@ func (db *satellitesDB) CompleteGracefulExit(ctx context.Context, satelliteID st
|
|||||||
func (db *satellitesDB) ListGracefulExits(ctx context.Context) (exitList []satellites.ExitProgress, err error) {
|
func (db *satellitesDB) ListGracefulExits(ctx context.Context) (exitList []satellites.ExitProgress, err error) {
|
||||||
defer mon.Task()(&ctx)(&err)
|
defer mon.Task()(&ctx)(&err)
|
||||||
|
|
||||||
query := `SELECT satellite_id, initiated_at, finished_at, starting_disk_usage, bytes_deleted, completion_receipt FROM satellite_exit_progress`
|
query := `SELECT satellite_id, initiated_at, finished_at, starting_disk_usage, bytes_deleted, completion_receipt, status FROM satellite_exit_progress INNER JOIN satellites ON satellite_exit_progress.satellite_id = satellites.node_id`
|
||||||
rows, err := db.QueryContext(ctx, query)
|
rows, err := db.QueryContext(ctx, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrSatellitesDB.Wrap(err)
|
return nil, ErrSatellitesDB.Wrap(err)
|
||||||
@ -105,7 +105,7 @@ func (db *satellitesDB) ListGracefulExits(ctx context.Context) (exitList []satel
|
|||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var exit satellites.ExitProgress
|
var exit satellites.ExitProgress
|
||||||
err := rows.Scan(&exit.SatelliteID, &exit.InitiatedAt, &exit.FinishedAt, &exit.StartingDiskUsage, &exit.BytesDeleted, &exit.CompletionReceipt)
|
err := rows.Scan(&exit.SatelliteID, &exit.InitiatedAt, &exit.FinishedAt, &exit.StartingDiskUsage, &exit.BytesDeleted, &exit.CompletionReceipt, &exit.Status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user