func waitMount(volumeID string) (*goscaleio.SdcMappedVolume, error) { timeout := make(chan bool, 1) go func() { time.Sleep(10 * time.Second) timeout <- true }() successCh := make(chan *goscaleio.SdcMappedVolume, 1) errorCh := make(chan error, 1) go func(volumeID string) { log.WithField("provider", ProviderName).Debug("waiting for volume mount") for { sdcMappedVolumes, err := goscaleio.GetLocalVolumeMap() if err != nil { errorCh <- errors.WithFieldE( "provider", ProviderName, "problem getting local volume mappings", err) return } sdcMappedVolume := &goscaleio.SdcMappedVolume{} var foundVolume bool for _, sdcMappedVolume = range sdcMappedVolumes { if sdcMappedVolume.VolumeID == volumeID && sdcMappedVolume.SdcDevice != "" { foundVolume = true break } } if foundVolume { successCh <- sdcMappedVolume return } time.Sleep(100 * time.Millisecond) } }(volumeID) select { case sdcMappedVolume := <-successCh: log.WithFields(log.Fields{ "provider": ProviderName, "volumeId": sdcMappedVolume.VolumeID, "volume": sdcMappedVolume.SdcDevice, }).Debug("got sdcMappedVolume") return sdcMappedVolume, nil case err := <-errorCh: return &goscaleio.SdcMappedVolume{}, err case <-timeout: return &goscaleio.SdcMappedVolume{}, errors.WithFields( ef(), "timed out waiting for mount") } }
func (driver *Driver) RemoveSnapshot(snapshotID string) error { resp := snapshots.Delete(driver.ClientBlockStorage, snapshotID) if resp.Err != nil { return errors.WithFieldE( "snapshotId", snapshotID, "error removing snapshot", resp.Err) } log.WithField("snapshotId", snapshotID).Debug("removed snapshot") return nil }