in sharedlibraries/gce/gce.go [291:321]
func (g *GCE) waitForUploadCompletion(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error {
zos := compute.NewZoneOperationsService(g.service)
tracker, err := zos.Wait(project, diskZone, op.Name).Do()
if err != nil {
log.CtxLogger(ctx).Errorw("Error in operation", "operation", op.Name)
return err
}
log.CtxLogger(ctx).Infow("Operation in progress", "Name", op.Name, "percentage", tracker.Progress, "status", tracker.Status)
if tracker.Status != "DONE" {
return fmt.Errorf("compute operation is not DONE yet")
}
if tracker.Error != nil {
log.CtxLogger(ctx).Errorw("Error in operation", "operation", op.Name, "error", tracker.Error)
return fmt.Errorf("compute operation failed with error: %v", tracker.Error)
}
if tracker.HttpErrorMessage != "" {
log.CtxLogger(ctx).Errorw("Error in operation", "operation", op.Name, "errorStatusCode", tracker.HttpErrorStatusCode, "error", tracker.HttpErrorMessage)
return fmt.Errorf("compute operation failed with error: %v", tracker.HttpErrorMessage)
}
ss, err := g.service.Snapshots.Get(project, snapshotName).Do()
if err != nil {
return err
}
log.CtxLogger(ctx).Infow("Snapshot upload status", "snapshot", snapshotName, "SnapshotStatus", ss.Status, "OperationStatus", op.Status)
if ss.Status == "READY" {
return nil
}
return fmt.Errorf("snapshot %s not READY yet, snapshotStatus: %s, operationStatus: %s", snapshotName, ss.Status, op.Status)
}