예제 #1
0
func destroyVolumes(vman *volumemanager.Manager) error {
	someVolumesNotDestroyed := false
	var secondPass []string
	for volID := range vman.Volumes() {
		fmt.Printf("removing volume id=%q... ", volID)
		if err := vman.DestroyVolume(volID); err == nil {
			fmt.Println("success")
		} else if zfs.IsDatasetHasChildrenError(err) {
			fmt.Println("has children, coming back to it later")
			secondPass = append(secondPass, volID)
		} else {
			fmt.Printf("error: %s\n", err)
			someVolumesNotDestroyed = true
		}
	}
	for volID := range vman.Volumes() {
		fmt.Printf("removing volume id=%q... ", volID)
		if err := vman.DestroyVolume(volID); err == nil {
			fmt.Println("success")
		} else {
			fmt.Printf("error: %s\n", err)
			someVolumesNotDestroyed = true
		}
	}

	if someVolumesNotDestroyed {
		return fmt.Errorf("some volumes were not destroyed successfully")
	}
	return nil
}
예제 #2
0
func destroyVolumes(vman *volumemanager.Manager, keepSystemImages bool) error {
	someVolumesNotDestroyed := false
	var secondPass []string
	for id, vol := range vman.Volumes() {
		if keepSystemImages && vol.Info().Meta["flynn.system-image"] == "true" {
			continue
		}
		fmt.Printf("removing volume id=%q... ", id)
		if err := vman.DestroyVolume(id); err == nil {
			fmt.Println("success")
		} else if zfs.IsDatasetHasChildrenError(err) {
			fmt.Println("has children, coming back to it later")
			secondPass = append(secondPass, id)
		} else {
			fmt.Printf("error: %s\n", err)
			someVolumesNotDestroyed = true
		}
	}
	for id, vol := range vman.Volumes() {
		if keepSystemImages && vol.Info().Meta["flynn.system-image"] == "true" {
			continue
		}
		fmt.Printf("removing volume id=%q... ", id)
		if err := vman.DestroyVolume(id); err == nil {
			fmt.Println("success")
		} else {
			fmt.Printf("error: %s\n", err)
			someVolumesNotDestroyed = true
		}
	}

	if someVolumesNotDestroyed {
		return fmt.Errorf("some volumes were not destroyed successfully")
	}
	return nil
}