volume recycler: Don't start a new recycler pod if one already exists.

Recycling is a long duration process and when the recycler controller is
restarted in the meantime, it should not start a new recycler pod if there is
one already running.

This means that the recycler pod must have deterministic name based on name
of the recycled PV, we then get name conflicts when creating the pod.

Two things need to be changed:
- recycler controller and recycler plugins must pass the PV.Name to place,
  where the pod is created.

- create recycler pod with deterministic name and check "already exists" error.

When at it, remove useless 'resourceVersion' argument and make log messages
starting with lowercase.
This commit is contained in:
Jan Safranek
2016-05-19 12:58:25 +02:00
parent c63ac4e664
commit 0ee9160f88
10 changed files with 125 additions and 43 deletions

View File

@@ -101,7 +101,7 @@ type RecyclableVolumePlugin interface {
VolumePlugin
// NewRecycler creates a new volume.Recycler which knows how to reclaim this resource
// after the volume's release from a PersistentVolumeClaim
NewRecycler(spec *Spec) (Recycler, error)
NewRecycler(pvName string, spec *Spec) (Recycler, error)
}
// DeletableVolumePlugin is an extended interface of VolumePlugin and is used by persistent volumes that want
@@ -238,6 +238,9 @@ type VolumeConfig struct {
// Example: 5Gi volume x 30s increment = 150s + 30s minimum = 180s ActiveDeadlineSeconds for recycler pod
RecyclerTimeoutIncrement int
// PVName is name of the PersistentVolume instance that is being recycled. It is used to generate unique recycler pod name.
PVName string
// OtherAttributes stores config as strings. These strings are opaque to the system and only understood by the binary
// hosting the plugin and the plugin itself.
OtherAttributes map[string]string