in sharedlibraries/gce/gce.go [471:501]
func (g *GCE) waitForGlobalUploadCompletion(ctx context.Context, op *compute.Operation, project, diskZone, snapshotName string) error {
gos := compute.NewGlobalOperationsService(g.service)
tracker, err := gos.Wait(project, op.Name).Do()
if err != nil {
log.CtxLogger(ctx).Errorw("Error in operation", "operation", op.Name, "error", err)
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)
}