package util
import "k8s.io/kubernetes/pkg/volume/util"
Contains utility code for use by volume plugins.
Index ¶
- func Du(path string) (*resource.Quantity, error)
- func Find(path string) (int64, error)
- func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error)
- func GetClassForVolume(kubeClient clientset.Interface, pv *v1.PersistentVolume) (*storage.StorageClass, error)
- func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeClient clientset.Interface) (map[string]string, error)
- func GetSecretForPod(pod *v1.Pod, secretName string, kubeClient clientset.Interface) (map[string]string, error)
- func IsReady(dir string) bool
- func PathExists(path string) (bool, error)
- func SetReady(dir string)
- func UnmountPath(mountPath string, mounter mount.Interface) error
- type AtomicWriter
- func NewAtomicWriter(targetDir string, logContext string) (*AtomicWriter, error)
- func (w *AtomicWriter) Write(payload map[string]FileProjection) error
- type DeviceUtil
- type FileProjection
- type IoUtil
Functions ¶
func Du ¶
func Find ¶
func FsInfo ¶
FSInfo unsupported returns 0 values for available and capacity and an error.
func GetClassForVolume ¶
func GetClassForVolume(kubeClient clientset.Interface, pv *v1.PersistentVolume) (*storage.StorageClass, error)
func GetSecretForPV ¶
func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeClient clientset.Interface) (map[string]string, error)
GetSecretForPV locates secret by name and namespace, verifies the secret type, and returns secret map
func GetSecretForPod ¶
func GetSecretForPod(pod *v1.Pod, secretName string, kubeClient clientset.Interface) (map[string]string, error)
GetSecretForPod locates secret by name in the pod's namespace and returns secret map
func IsReady ¶
IsReady checks for the existence of a regular file called 'ready' in the given directory and returns true if that file exists.
func PathExists ¶
PathExists returns true if the specified path exists.
func SetReady ¶
func SetReady(dir string)
SetReady creates a file called 'ready' in the given directory. It logs an error if the file cannot be created.
func UnmountPath ¶
UnmountPath is a common unmount routine that unmounts the given path and deletes the remaining directory if successful.
Types ¶
type AtomicWriter ¶
type AtomicWriter struct {
// contains filtered or unexported fields
}
AtomicWriter handles atomically projecting content for a set of files into a target directory.
Note:
- AtomicWriter reserves the set of pathnames starting with `..`.
- AtomicWriter offers no concurrency guarantees and must be synchronized by the caller.
The visible files in this volume are symlinks to files in the writer's data directory. Actual files are stored in a hidden timestamped directory which is symlinked to by the data directory. The timestamped directory and data directory symlink are created in the writer's target dir. This scheme allows the files to be atomically updated by changing the target of the data directory symlink.
Consumers of the target directory can monitor the ..data symlink using inotify or fanotify to receive events when the content in the volume is updated.
func NewAtomicWriter ¶
func NewAtomicWriter(targetDir string, logContext string) (*AtomicWriter, error)
NewAtomicWriter creates a new AtomicWriter configured to write to the given target directory, or returns an error if the target directory does not exist.
func (*AtomicWriter) Write ¶
func (w *AtomicWriter) Write(payload map[string]FileProjection) error
Write does an atomic projection of the given payload into the writer's target directory. Input paths must not begin with '..'.
The Write algorithm is:
The payload is validated; if the payload is invalid, the function returns
The user-visible portion of the volume is walked to determine whether any portion of the payload was deleted and is still present on disk. If the payload is already present on disk and there are no deleted files, the function returns
A check is made to determine whether data present in the payload has changed 4. A new timestamped dir is created
The payload is written to the new timestamped directory 6. Symlinks and directory for new user-visible files are created (if needed).
For example, consider the files: <target-dir>/podName <target-dir>/user/labels <target-dir>/k8s/annotations
The user visible files are symbolic links into the internal data directory: <target-dir>/podName -> ..data/podName <target-dir>/usr/labels -> ../..data/usr/labels <target-dir>/k8s/annotations -> ../..data/k8s/annotations
Relative links are created into the data directory for files in subdirectories.
The data directory itself is a link to a timestamped directory with the real data: <target-dir>/..data -> ..2016_02_01_15_04_05.12345678/ 7. The current timestamped directory is detected by reading the data directory symlink 8. A symlink to the new timestamped directory ..data_tmp is created that will become the new data directory 9. The new data directory symlink is renamed to the data directory; rename is atomic
10. Old paths are removed from the user-visible portion of the target directory 11. The previous timestamped directory is removed, if it exists
type DeviceUtil ¶
DeviceUtil is a util for common device methods
func NewDeviceHandler ¶
func NewDeviceHandler(io IoUtil) DeviceUtil
NewDeviceHandler Create a new IoHandler implementation
type FileProjection ¶
type IoUtil ¶
type IoUtil interface { ReadDir(dirname string) ([]os.FileInfo, error) Lstat(name string) (os.FileInfo, error) EvalSymlinks(path string) (string, error) }
IoUtil is a mockable util for common IO operations
func NewIOHandler ¶
func NewIOHandler() IoUtil
NewIOHandler Create a new IoHandler implementation
Source Files ¶
atomic_writer.go device_util.go device_util_unsupported.go doc.go fs_unsupported.go io_util.go util.go
Directories ¶
Path | Synopsis |
---|---|
pkg/volume/util/nestedpendingoperations | Package nestedpendingoperations is a modified implementation of pkg/util/goroutinemap. |
pkg/volume/util/operationexecutor | Package operationexecutor implements interfaces that enable execution of attach, detach, mount, and unmount operations with a nestedpendingoperations so that more than one operation is never triggered on the same volume for the same pod. |
pkg/volume/util/types | Package types defines types used only by volume components |
pkg/volume/util/volumehelper | Package volumehelper contains consts and helper methods used by various volume components (attach/detach controller, kubelet, etc.). |
- Version
- v1.6.12
- Published
- Oct 25, 2017
- Platform
- js/wasm
- Imports
- 17 packages
- Last checked
- 19 seconds ago –
Tools for package owners.