mirror of https://github.com/k3s-io/k3s
fixed newRecycler func for HostPath & NFS
parent
dcd6537b1b
commit
649374ddb4
|
@ -86,11 +86,10 @@ func (plugin *hostPathPlugin) NewRecycler(spec *volume.Spec) (volume.Recycler, e
|
|||
}
|
||||
|
||||
func newRecycler(spec *volume.Spec, host volume.VolumeHost) (volume.Recycler, error) {
|
||||
if spec.VolumeSource.HostPath != nil {
|
||||
return &hostPathRecycler{spec.Name, spec.VolumeSource.HostPath.Path, host}, nil
|
||||
} else {
|
||||
return &hostPathRecycler{spec.Name, spec.PersistentVolumeSource.HostPath.Path, host}, nil
|
||||
if spec.PersistentVolumeSource.HostPath == nil {
|
||||
return nil, fmt.Errorf("spec.PersistentVolumeSource.HostPath is nil")
|
||||
}
|
||||
return &hostPathRecycler{spec.Name, spec.PersistentVolumeSource.HostPath.Path, host}, nil
|
||||
}
|
||||
|
||||
// HostPath volumes represent a bare host file or directory mount.
|
||||
|
|
|
@ -223,21 +223,15 @@ func (c *nfsCleaner) TearDownAt(dir string) error {
|
|||
}
|
||||
|
||||
func newRecycler(spec *volume.Spec, host volume.VolumeHost) (volume.Recycler, error) {
|
||||
if spec.VolumeSource.HostPath != nil {
|
||||
return &nfsRecycler{
|
||||
name: spec.Name,
|
||||
server: spec.VolumeSource.NFS.Server,
|
||||
path: spec.VolumeSource.NFS.Path,
|
||||
host: host,
|
||||
}, nil
|
||||
} else {
|
||||
return &nfsRecycler{
|
||||
name: spec.Name,
|
||||
server: spec.PersistentVolumeSource.NFS.Server,
|
||||
path: spec.PersistentVolumeSource.NFS.Path,
|
||||
host: host,
|
||||
}, nil
|
||||
if spec.PersistentVolumeSource.NFS == nil {
|
||||
return nil, fmt.Errorf("spec.PersistentVolumeSource.NFS is nil")
|
||||
}
|
||||
return &nfsRecycler{
|
||||
name: spec.Name,
|
||||
server: spec.PersistentVolumeSource.NFS.Server,
|
||||
path: spec.PersistentVolumeSource.NFS.Path,
|
||||
host: host,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// nfsRecycler scrubs an NFS volume by running "rm -rf" on the volume in a pod.
|
||||
|
|
Loading…
Reference in New Issue