type RecycleEventRecorder … // RecycleVolumeByWatchingPodUntilCompletion is intended for use with volume // Recyclers. This function will save the given Pod to the API and watch it // until it completes, fails, or the pod's ActiveDeadlineSeconds is exceeded, // whichever comes first. An attempt to delete a recycler pod is always // attempted before returning. // // In case there is a pod with the same namespace+name already running, this // function deletes it as it is not able to judge if it is an old recycler // or user has forged a fake recycler to block Kubernetes from recycling.// // // pod - the pod designed by a volume plugin to recycle the volume. pod.Name // will be overwritten with unique name based on PV.Name. // client - kube client for API operations. func RecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *v1.Pod, kubeClient clientset.Interface, recorder RecycleEventRecorder) error { … } // same as above func comments, except 'recyclerClient' is a narrower pod API // interface to ease testing func internalRecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *v1.Pod, recyclerClient recyclerClient) error { … } // waitForPod watches the pod it until it finishes and send all events on the // pod to the PV. func waitForPod(pod *v1.Pod, recyclerClient recyclerClient, podCh <-chan watch.Event) error { … } type recyclerClient … func newRecyclerClient(client clientset.Interface, recorder RecycleEventRecorder) recyclerClient { … } type realRecyclerClient … func (c *realRecyclerClient) CreatePod(pod *v1.Pod) (*v1.Pod, error) { … } func (c *realRecyclerClient) GetPod(name, namespace string) (*v1.Pod, error) { … } func (c *realRecyclerClient) DeletePod(name, namespace string) error { … } func (c *realRecyclerClient) Event(eventtype, message string) { … } // WatchPod watches a pod and events related to it. It sends pod updates and events over the returned channel // It will continue until stopChannel is closed func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan struct{ … }