Introduce new kubelet volume manager
This commit adds a new volume manager in kubelet that synchronizes volume mount/unmount (and attach/detach, if attach/detach controller is not enabled). This eliminates the race conditions between the pod creation loop and the orphaned volumes loops. It also removes the unmount/detach from the `syncPod()` path so volume clean up never blocks the `syncPod` loop.
This commit is contained in:
@@ -55,9 +55,9 @@ func (plugin *rbdPlugin) GetPluginName() string {
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _ := getVolumeSource(spec)
|
||||
if volumeSource == nil {
|
||||
return "", fmt.Errorf("Spec does not reference a RBD volume type")
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
@@ -74,6 +74,10 @@ func (plugin *rbdPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) RequiresRemount() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
|
||||
return []api.PersistentVolumeAccessMode{
|
||||
api.ReadWriteOnce,
|
||||
@@ -234,17 +238,14 @@ func (plugin *rbdPlugin) execCommand(command string, args []string) ([]byte, err
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (*api.RBDVolumeSource, bool) {
|
||||
var readOnly bool
|
||||
var volumeSource *api.RBDVolumeSource
|
||||
|
||||
func getVolumeSource(
|
||||
spec *volume.Spec) (*api.RBDVolumeSource, bool, error) {
|
||||
if spec.Volume != nil && spec.Volume.RBD != nil {
|
||||
volumeSource = spec.Volume.RBD
|
||||
readOnly = volumeSource.ReadOnly
|
||||
} else {
|
||||
volumeSource = spec.PersistentVolume.Spec.RBD
|
||||
readOnly = spec.ReadOnly
|
||||
return spec.Volume.RBD, spec.Volume.RBD.ReadOnly, nil
|
||||
} else if spec.PersistentVolume != nil &&
|
||||
spec.PersistentVolume.Spec.RBD != nil {
|
||||
return spec.PersistentVolume.Spec.RBD, spec.ReadOnly, nil
|
||||
}
|
||||
|
||||
return volumeSource, readOnly
|
||||
return nil, false, fmt.Errorf("Spec does not reference a RBD volume type")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user