summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/kubernetes/pkg/volume
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/kubernetes/pkg/volume')
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/doc.go19
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/metrics_cached.go74
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go99
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/metrics_errors.go77
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/metrics_nil.go30
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go69
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/plugins.go807
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go97
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_unsupported.go38
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/util/recyclerclient/recycler_client.go252
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/volume.go273
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go105
-rw-r--r--vendor/k8s.io/kubernetes/pkg/volume/volume_unsupported.go27
13 files changed, 0 insertions, 1967 deletions
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/doc.go b/vendor/k8s.io/kubernetes/pkg/volume/doc.go
deleted file mode 100644
index c98a5a153..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/doc.go
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package volume includes internal representations of external volume types
-// as well as utility methods required to mount/unmount volumes to kubelets.
-package volume // import "k8s.io/kubernetes/pkg/volume"
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/metrics_cached.go b/vendor/k8s.io/kubernetes/pkg/volume/metrics_cached.go
deleted file mode 100644
index ac0dc9b7a..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/metrics_cached.go
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "sync"
- "sync/atomic"
-)
-
-var _ MetricsProvider = &cachedMetrics{}
-
-// cachedMetrics represents a MetricsProvider that wraps another provider and
-// caches the result.
-type cachedMetrics struct {
- wrapped MetricsProvider
- resultError error
- resultMetrics *Metrics
- once cacheOnce
-}
-
-// NewCachedMetrics creates a new cachedMetrics wrapping another
-// MetricsProvider and caching the results.
-func NewCachedMetrics(provider MetricsProvider) MetricsProvider {
- return &cachedMetrics{wrapped: provider}
-}
-
-// GetMetrics runs the wrapped metrics provider's GetMetrics methd once and
-// caches the result. Will not cache result if there is an error.
-// See MetricsProvider.GetMetrics
-func (md *cachedMetrics) GetMetrics() (*Metrics, error) {
- md.once.cache(func() error {
- md.resultMetrics, md.resultError = md.wrapped.GetMetrics()
- return md.resultError
- })
- return md.resultMetrics, md.resultError
-}
-
-// Copied from sync.Once but we don't want to cache the results if there is an
-// error
-type cacheOnce struct {
- m sync.Mutex
- done uint32
-}
-
-// Copied from sync.Once but we don't want to cache the results if there is an
-// error
-func (o *cacheOnce) cache(f func() error) {
- if atomic.LoadUint32(&o.done) == 1 {
- return
- }
- // Slow-path.
- o.m.Lock()
- defer o.m.Unlock()
- if o.done == 0 {
- err := f()
- if err == nil {
- atomic.StoreUint32(&o.done, 1)
- }
- }
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go b/vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go
deleted file mode 100644
index 88a985d5a..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "k8s.io/apimachinery/pkg/api/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/kubernetes/pkg/volume/util/fs"
-)
-
-var _ MetricsProvider = &metricsDu{}
-
-// metricsDu represents a MetricsProvider that calculates the used and
-// available Volume space by executing the "du" command and gathering
-// filesystem info for the Volume path.
-type metricsDu struct {
- // the directory path the volume is mounted to.
- path string
-}
-
-// NewMetricsDu creates a new metricsDu with the Volume path.
-func NewMetricsDu(path string) MetricsProvider {
- return &metricsDu{path}
-}
-
-// GetMetrics calculates the volume usage and device free space by executing "du"
-// and gathering filesystem info for the Volume path.
-// See MetricsProvider.GetMetrics
-func (md *metricsDu) GetMetrics() (*Metrics, error) {
- metrics := &Metrics{Time: metav1.Now()}
- if md.path == "" {
- return metrics, NewNoPathDefinedError()
- }
-
- err := md.runDu(metrics)
- if err != nil {
- return metrics, err
- }
-
- err = md.runFind(metrics)
- if err != nil {
- return metrics, err
- }
-
- err = md.getFsInfo(metrics)
- if err != nil {
- return metrics, err
- }
-
- return metrics, nil
-}
-
-// runDu executes the "du" command and writes the results to metrics.Used
-func (md *metricsDu) runDu(metrics *Metrics) error {
- used, err := fs.Du(md.path)
- if err != nil {
- return err
- }
- metrics.Used = used
- return nil
-}
-
-// runFind executes the "find" command and writes the results to metrics.InodesUsed
-func (md *metricsDu) runFind(metrics *Metrics) error {
- inodesUsed, err := fs.Find(md.path)
- if err != nil {
- return err
- }
- metrics.InodesUsed = resource.NewQuantity(inodesUsed, resource.BinarySI)
- return nil
-}
-
-// getFsInfo writes metrics.Capacity and metrics.Available from the filesystem
-// info
-func (md *metricsDu) getFsInfo(metrics *Metrics) error {
- available, capacity, _, inodes, inodesFree, _, err := fs.FsInfo(md.path)
- if err != nil {
- return NewFsInfoFailedError(err)
- }
- metrics.Available = resource.NewQuantity(available, resource.BinarySI)
- metrics.Capacity = resource.NewQuantity(capacity, resource.BinarySI)
- metrics.Inodes = resource.NewQuantity(inodes, resource.BinarySI)
- metrics.InodesFree = resource.NewQuantity(inodesFree, resource.BinarySI)
- return nil
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/metrics_errors.go b/vendor/k8s.io/kubernetes/pkg/volume/metrics_errors.go
deleted file mode 100644
index 50e7c2a21..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/metrics_errors.go
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright 2016 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "fmt"
-)
-
-const (
- // ErrCodeNotSupported code for NotSupported Errors.
- ErrCodeNotSupported int = iota + 1
- ErrCodeNoPathDefined
- ErrCodeFsInfoFailed
-)
-
-// NewNotSupportedError creates a new MetricsError with code NotSupported.
-func NewNotSupportedError() *MetricsError {
- return &MetricsError{
- Code: ErrCodeNotSupported,
- Msg: "metrics are not supported for MetricsNil Volumes",
- }
-}
-
-// NewNoPathDefined creates a new MetricsError with code NoPathDefined.
-func NewNoPathDefinedError() *MetricsError {
- return &MetricsError{
- Code: ErrCodeNoPathDefined,
- Msg: "no path defined for disk usage metrics.",
- }
-}
-
-// NewFsInfoFailedError creates a new MetricsError with code FsInfoFailed.
-func NewFsInfoFailedError(err error) *MetricsError {
- return &MetricsError{
- Code: ErrCodeFsInfoFailed,
- Msg: fmt.Sprintf("Failed to get FsInfo due to error %v", err),
- }
-}
-
-// MetricsError to distinguish different Metrics Errors.
-type MetricsError struct {
- Code int
- Msg string
-}
-
-func (e *MetricsError) Error() string {
- return fmt.Sprintf("%s", e.Msg)
-}
-
-// IsNotSupported returns true if and only if err is "key" not found error.
-func IsNotSupported(err error) bool {
- return isErrCode(err, ErrCodeNotSupported)
-}
-
-func isErrCode(err error, code int) bool {
- if err == nil {
- return false
- }
- if e, ok := err.(*MetricsError); ok {
- return e.Code == code
- }
- return false
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/metrics_nil.go b/vendor/k8s.io/kubernetes/pkg/volume/metrics_nil.go
deleted file mode 100644
index 5438dc3de..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/metrics_nil.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-var _ MetricsProvider = &MetricsNil{}
-
-// MetricsNil represents a MetricsProvider that does not support returning
-// Metrics. It serves as a placeholder for Volumes that do not yet support
-// metrics.
-type MetricsNil struct{}
-
-// GetMetrics returns an empty Metrics and an error.
-// See MetricsProvider.GetMetrics
-func (*MetricsNil) GetMetrics() (*Metrics, error) {
- return &Metrics{}, NewNotSupportedError()
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go b/vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go
deleted file mode 100644
index 66f99e30a..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright 2016 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "k8s.io/apimachinery/pkg/api/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/kubernetes/pkg/volume/util/fs"
-)
-
-var _ MetricsProvider = &metricsStatFS{}
-
-// metricsStatFS represents a MetricsProvider that calculates the used and available
-// Volume space by stat'ing and gathering filesystem info for the Volume path.
-type metricsStatFS struct {
- // the directory path the volume is mounted to.
- path string
-}
-
-// NewMetricsStatfs creates a new metricsStatFS with the Volume path.
-func NewMetricsStatFS(path string) MetricsProvider {
- return &metricsStatFS{path}
-}
-
-// See MetricsProvider.GetMetrics
-// GetMetrics calculates the volume usage and device free space by executing "du"
-// and gathering filesystem info for the Volume path.
-func (md *metricsStatFS) GetMetrics() (*Metrics, error) {
- metrics := &Metrics{Time: metav1.Now()}
- if md.path == "" {
- return metrics, NewNoPathDefinedError()
- }
-
- err := md.getFsInfo(metrics)
- if err != nil {
- return metrics, err
- }
-
- return metrics, nil
-}
-
-// getFsInfo writes metrics.Capacity, metrics.Used and metrics.Available from the filesystem info
-func (md *metricsStatFS) getFsInfo(metrics *Metrics) error {
- available, capacity, usage, inodes, inodesFree, inodesUsed, err := fs.FsInfo(md.path)
- if err != nil {
- return NewFsInfoFailedError(err)
- }
- metrics.Available = resource.NewQuantity(available, resource.BinarySI)
- metrics.Capacity = resource.NewQuantity(capacity, resource.BinarySI)
- metrics.Used = resource.NewQuantity(usage, resource.BinarySI)
- metrics.Inodes = resource.NewQuantity(inodes, resource.BinarySI)
- metrics.InodesFree = resource.NewQuantity(inodesFree, resource.BinarySI)
- metrics.InodesUsed = resource.NewQuantity(inodesUsed, resource.BinarySI)
- return nil
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/plugins.go b/vendor/k8s.io/kubernetes/pkg/volume/plugins.go
deleted file mode 100644
index ec4ec5791..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/plugins.go
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "fmt"
- "net"
- "strings"
- "sync"
-
- "github.com/golang/glog"
- "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/types"
- utilerrors "k8s.io/apimachinery/pkg/util/errors"
- "k8s.io/apimachinery/pkg/util/validation"
- clientset "k8s.io/client-go/kubernetes"
- "k8s.io/kubernetes/pkg/cloudprovider"
- "k8s.io/kubernetes/pkg/util/io"
- "k8s.io/kubernetes/pkg/util/mount"
- "k8s.io/kubernetes/pkg/volume/util/recyclerclient"
-)
-
-const (
- // Common parameter which can be specified in StorageClass to specify the desired FSType
- // Provisioners SHOULD implement support for this if they are block device based
- // Must be a filesystem type supported by the host operating system.
- // Ex. "ext4", "xfs", "ntfs". Default value depends on the provisioner
- VolumeParameterFSType = "fstype"
-)
-
-// VolumeOptions contains option information about a volume.
-type VolumeOptions struct {
- // The attributes below are required by volume.Provisioner
- // TODO: refactor all of this out of volumes when an admin can configure
- // many kinds of provisioners.
-
- // Reclamation policy for a persistent volume
- PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy
- // Mount options for a persistent volume
- MountOptions []string
- // Suggested PV.Name of the PersistentVolume to provision.
- // This is a generated name guaranteed to be unique in Kubernetes cluster.
- // If you choose not to use it as volume name, ensure uniqueness by either
- // combining it with your value or create unique values of your own.
- PVName string
- // PVC is reference to the claim that lead to provisioning of a new PV.
- // Provisioners *must* create a PV that would be matched by this PVC,
- // i.e. with required capacity, accessMode, labels matching PVC.Selector and
- // so on.
- PVC *v1.PersistentVolumeClaim
- // Unique name of Kubernetes cluster.
- ClusterName string
- // Tags to attach to the real volume in the cloud provider - e.g. AWS EBS
- CloudTags *map[string]string
- // Volume provisioning parameters from StorageClass
- Parameters map[string]string
-}
-
-type DynamicPluginProber interface {
- Init() error
-
- // If an update has occurred since the last probe, updated = true
- // and the list of probed plugins is returned.
- // Otherwise, update = false and probedPlugins = nil.
- //
- // If an error occurs, updated and probedPlugins are undefined.
- Probe() (updated bool, probedPlugins []VolumePlugin, err error)
-}
-
-// VolumePlugin is an interface to volume plugins that can be used on a
-// kubernetes node (e.g. by kubelet) to instantiate and manage volumes.
-type VolumePlugin interface {
- // Init initializes the plugin. This will be called exactly once
- // before any New* calls are made - implementations of plugins may
- // depend on this.
- Init(host VolumeHost) error
-
- // Name returns the plugin's name. Plugins must use namespaced names
- // such as "example.com/volume" and contain exactly one '/' character.
- // The "kubernetes.io" namespace is reserved for plugins which are
- // bundled with kubernetes.
- GetPluginName() string
-
- // GetVolumeName returns the name/ID to uniquely identifying the actual
- // backing device, directory, path, etc. referenced by the specified volume
- // spec.
- // For Attachable volumes, this value must be able to be passed back to
- // volume Detach methods to identify the device to act on.
- // If the plugin does not support the given spec, this returns an error.
- GetVolumeName(spec *Spec) (string, error)
-
- // CanSupport tests whether the plugin supports a given volume
- // specification from the API. The spec pointer should be considered
- // const.
- CanSupport(spec *Spec) bool
-
- // RequiresRemount returns true if this plugin requires mount calls to be
- // reexecuted. Atomically updating volumes, like Downward API, depend on
- // this to update the contents of the volume.
- RequiresRemount() bool
-
- // NewMounter creates a new volume.Mounter from an API specification.
- // Ownership of the spec pointer in *not* transferred.
- // - spec: The v1.Volume spec
- // - pod: The enclosing pod
- NewMounter(spec *Spec, podRef *v1.Pod, opts VolumeOptions) (Mounter, error)
-
- // NewUnmounter creates a new volume.Unmounter from recoverable state.
- // - name: The volume name, as per the v1.Volume spec.
- // - podUID: The UID of the enclosing pod
- NewUnmounter(name string, podUID types.UID) (Unmounter, error)
-
- // ConstructVolumeSpec constructs a volume spec based on the given volume name
- // and mountPath. The spec may have incomplete information due to limited
- // information from input. This function is used by volume manager to reconstruct
- // volume spec by reading the volume directories from disk
- ConstructVolumeSpec(volumeName, mountPath string) (*Spec, error)
-
- // SupportsMountOption returns true if volume plugins supports Mount options
- // Specifying mount options in a volume plugin that doesn't support
- // user specified mount options will result in error creating persistent volumes
- SupportsMountOption() bool
-
- // SupportsBulkVolumeVerification checks if volume plugin type is capable
- // of enabling bulk polling of all nodes. This can speed up verification of
- // attached volumes by quite a bit, but underlying pluging must support it.
- SupportsBulkVolumeVerification() bool
-}
-
-// PersistentVolumePlugin is an extended interface of VolumePlugin and is used
-// by volumes that want to provide long term persistence of data
-type PersistentVolumePlugin interface {
- VolumePlugin
- // GetAccessModes describes the ways a given volume can be accessed/mounted.
- GetAccessModes() []v1.PersistentVolumeAccessMode
-}
-
-// RecyclableVolumePlugin is an extended interface of VolumePlugin and is used
-// by persistent volumes that want to be recycled before being made available
-// again to new claims
-type RecyclableVolumePlugin interface {
- VolumePlugin
-
- // Recycle knows how to reclaim this
- // resource after the volume's release from a PersistentVolumeClaim.
- // Recycle will use the provided recorder to write any events that might be
- // interesting to user. It's expected that caller will pass these events to
- // the PV being recycled.
- Recycle(pvName string, spec *Spec, eventRecorder recyclerclient.RecycleEventRecorder) error
-}
-
-// DeletableVolumePlugin is an extended interface of VolumePlugin and is used
-// by persistent volumes that want to be deleted from the cluster after their
-// release from a PersistentVolumeClaim.
-type DeletableVolumePlugin interface {
- VolumePlugin
- // NewDeleter creates a new volume.Deleter which knows how to delete this
- // resource in accordance with the underlying storage provider after the
- // volume's release from a claim
- NewDeleter(spec *Spec) (Deleter, error)
-}
-
-const (
- // Name of a volume in external cloud that is being provisioned and thus
- // should be ignored by rest of Kubernetes.
- ProvisionedVolumeName = "placeholder-for-provisioning"
-)
-
-// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
-// used to create volumes for the cluster.
-type ProvisionableVolumePlugin interface {
- VolumePlugin
- // NewProvisioner creates a new volume.Provisioner which knows how to
- // create PersistentVolumes in accordance with the plugin's underlying
- // storage provider
- NewProvisioner(options VolumeOptions) (Provisioner, error)
-}
-
-// AttachableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that require attachment
-// to a node before mounting.
-type AttachableVolumePlugin interface {
- VolumePlugin
- NewAttacher() (Attacher, error)
- NewDetacher() (Detacher, error)
- GetDeviceMountRefs(deviceMountPath string) ([]string, error)
-}
-
-// ExpandableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that can be
-// expanded
-type ExpandableVolumePlugin interface {
- VolumePlugin
- ExpandVolumeDevice(spec *Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error)
- RequiresFSResize() bool
-}
-
-// BlockVolumePlugin is an extend interface of VolumePlugin and is used for block volumes support.
-type BlockVolumePlugin interface {
- VolumePlugin
- // NewBlockVolumeMapper creates a new volume.BlockVolumeMapper from an API specification.
- // Ownership of the spec pointer in *not* transferred.
- // - spec: The v1.Volume spec
- // - pod: The enclosing pod
- NewBlockVolumeMapper(spec *Spec, podRef *v1.Pod, opts VolumeOptions) (BlockVolumeMapper, error)
- // NewBlockVolumeUnmapper creates a new volume.BlockVolumeUnmapper from recoverable state.
- // - name: The volume name, as per the v1.Volume spec.
- // - podUID: The UID of the enclosing pod
- NewBlockVolumeUnmapper(name string, podUID types.UID) (BlockVolumeUnmapper, error)
- // ConstructBlockVolumeSpec constructs a volume spec based on the given
- // podUID, volume name and a pod device map path.
- // The spec may have incomplete information due to limited information
- // from input. This function is used by volume manager to reconstruct
- // volume spec by reading the volume directories from disk.
- ConstructBlockVolumeSpec(podUID types.UID, volumeName, mountPath string) (*Spec, error)
-}
-
-// VolumeHost is an interface that plugins can use to access the kubelet.
-type VolumeHost interface {
- // GetPluginDir returns the absolute path to a directory under which
- // a given plugin may store data. This directory might not actually
- // exist on disk yet. For plugin data that is per-pod, see
- // GetPodPluginDir().
- GetPluginDir(pluginName string) string
-
- // GetVolumeDevicePluginDir returns the absolute path to a directory
- // under which a given plugin may store data.
- // ex. plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumePluginDependentPath}/
- GetVolumeDevicePluginDir(pluginName string) string
-
- // GetPodVolumeDir returns the absolute path a directory which
- // represents the named volume under the named plugin for the given
- // pod. If the specified pod does not exist, the result of this call
- // might not exist.
- GetPodVolumeDir(podUID types.UID, pluginName string, volumeName string) string
-
- // GetPodPluginDir returns the absolute path to a directory under which
- // a given plugin may store data for a given pod. If the specified pod
- // does not exist, the result of this call might not exist. This
- // directory might not actually exist on disk yet.
- GetPodPluginDir(podUID types.UID, pluginName string) string
-
- // GetPodVolumeDeviceDir returns the absolute path a directory which
- // represents the named plugin for the given pod.
- // If the specified pod does not exist, the result of this call
- // might not exist.
- // ex. pods/{podUid}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/
- GetPodVolumeDeviceDir(podUID types.UID, pluginName string) string
-
- // GetKubeClient returns a client interface
- GetKubeClient() clientset.Interface
-
- // NewWrapperMounter finds an appropriate plugin with which to handle
- // the provided spec. This is used to implement volume plugins which
- // "wrap" other plugins. For example, the "secret" volume is
- // implemented in terms of the "emptyDir" volume.
- NewWrapperMounter(volName string, spec Spec, pod *v1.Pod, opts VolumeOptions) (Mounter, error)
-
- // NewWrapperUnmounter finds an appropriate plugin with which to handle
- // the provided spec. See comments on NewWrapperMounter for more
- // context.
- NewWrapperUnmounter(volName string, spec Spec, podUID types.UID) (Unmounter, error)
-
- // Get cloud provider from kubelet.
- GetCloudProvider() cloudprovider.Interface
-
- // Get mounter interface.
- GetMounter(pluginName string) mount.Interface
-
- // Get writer interface for writing data to disk.
- GetWriter() io.Writer
-
- // Returns the hostname of the host kubelet is running on
- GetHostName() string
-
- // Returns host IP or nil in the case of error.
- GetHostIP() (net.IP, error)
-
- // Returns node allocatable.
- GetNodeAllocatable() (v1.ResourceList, error)
-
- // Returns a function that returns a secret.
- GetSecretFunc() func(namespace, name string) (*v1.Secret, error)
-
- // Returns a function that returns a configmap.
- GetConfigMapFunc() func(namespace, name string) (*v1.ConfigMap, error)
-
- // Returns an interface that should be used to execute any utilities in volume plugins
- GetExec(pluginName string) mount.Exec
-
- // Returns the labels on the node
- GetNodeLabels() (map[string]string, error)
-
- // Returns the name of the node
- GetNodeName() types.NodeName
-}
-
-// VolumePluginMgr tracks registered plugins.
-type VolumePluginMgr struct {
- mutex sync.Mutex
- plugins map[string]VolumePlugin
- prober DynamicPluginProber
- probedPlugins []VolumePlugin
- Host VolumeHost
-}
-
-// Spec is an internal representation of a volume. All API volume types translate to Spec.
-type Spec struct {
- Volume *v1.Volume
- PersistentVolume *v1.PersistentVolume
- ReadOnly bool
-}
-
-// Name returns the name of either Volume or PersistentVolume, one of which must not be nil.
-func (spec *Spec) Name() string {
- switch {
- case spec.Volume != nil:
- return spec.Volume.Name
- case spec.PersistentVolume != nil:
- return spec.PersistentVolume.Name
- default:
- return ""
- }
-}
-
-// VolumeConfig is how volume plugins receive configuration. An instance
-// specific to the plugin will be passed to the plugin's
-// ProbeVolumePlugins(config) func. Reasonable defaults will be provided by
-// the binary hosting the plugins while allowing override of those default
-// values. Those config values are then set to an instance of VolumeConfig
-// and passed to the plugin.
-//
-// Values in VolumeConfig are intended to be relevant to several plugins, but
-// not necessarily all plugins. The preference is to leverage strong typing
-// in this struct. All config items must have a descriptive but non-specific
-// name (i.e, RecyclerMinimumTimeout is OK but RecyclerMinimumTimeoutForNFS is
-// !OK). An instance of config will be given directly to the plugin, so
-// config names specific to plugins are unneeded and wrongly expose plugins in
-// this VolumeConfig struct.
-//
-// OtherAttributes is a map of string values intended for one-off
-// configuration of a plugin or config that is only relevant to a single
-// plugin. All values are passed by string and require interpretation by the
-// plugin. Passing config as strings is the least desirable option but can be
-// used for truly one-off configuration. The binary should still use strong
-// typing for this value when binding CLI values before they are passed as
-// strings in OtherAttributes.
-type VolumeConfig struct {
- // RecyclerPodTemplate is pod template that understands how to scrub clean
- // a persistent volume after its release. The template is used by plugins
- // which override specific properties of the pod in accordance with that
- // plugin. See NewPersistentVolumeRecyclerPodTemplate for the properties
- // that are expected to be overridden.
- RecyclerPodTemplate *v1.Pod
-
- // RecyclerMinimumTimeout is the minimum amount of time in seconds for the
- // recycler pod's ActiveDeadlineSeconds attribute. Added to the minimum
- // timeout is the increment per Gi of capacity.
- RecyclerMinimumTimeout int
-
- // RecyclerTimeoutIncrement is the number of seconds added to the recycler
- // pod's ActiveDeadlineSeconds for each Gi of capacity in the persistent
- // volume. 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
-
- // ProvisioningEnabled configures whether provisioning of this plugin is
- // enabled or not. Currently used only in host_path plugin.
- ProvisioningEnabled bool
-}
-
-// NewSpecFromVolume creates an Spec from an v1.Volume
-func NewSpecFromVolume(vs *v1.Volume) *Spec {
- return &Spec{
- Volume: vs,
- }
-}
-
-// NewSpecFromPersistentVolume creates an Spec from an v1.PersistentVolume
-func NewSpecFromPersistentVolume(pv *v1.PersistentVolume, readOnly bool) *Spec {
- return &Spec{
- PersistentVolume: pv,
- ReadOnly: readOnly,
- }
-}
-
-// InitPlugins initializes each plugin. All plugins must have unique names.
-// This must be called exactly once before any New* methods are called on any
-// plugins.
-func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, prober DynamicPluginProber, host VolumeHost) error {
- pm.mutex.Lock()
- defer pm.mutex.Unlock()
-
- pm.Host = host
-
- if prober == nil {
- // Use a dummy prober to prevent nil deference.
- pm.prober = &dummyPluginProber{}
- } else {
- pm.prober = prober
- }
- if err := pm.prober.Init(); err != nil {
- // Prober init failure should not affect the initialization of other plugins.
- glog.Errorf("Error initializing dynamic plugin prober: %s", err)
- pm.prober = &dummyPluginProber{}
- }
-
- if pm.plugins == nil {
- pm.plugins = map[string]VolumePlugin{}
- }
-
- allErrs := []error{}
- for _, plugin := range plugins {
- name := plugin.GetPluginName()
- if errs := validation.IsQualifiedName(name); len(errs) != 0 {
- allErrs = append(allErrs, fmt.Errorf("volume plugin has invalid name: %q: %s", name, strings.Join(errs, ";")))
- continue
- }
-
- if _, found := pm.plugins[name]; found {
- allErrs = append(allErrs, fmt.Errorf("volume plugin %q was registered more than once", name))
- continue
- }
- err := plugin.Init(host)
- if err != nil {
- glog.Errorf("Failed to load volume plugin %s, error: %s", name, err.Error())
- allErrs = append(allErrs, err)
- continue
- }
- pm.plugins[name] = plugin
- glog.V(1).Infof("Loaded volume plugin %q", name)
- }
- return utilerrors.NewAggregate(allErrs)
-}
-
-func (pm *VolumePluginMgr) initProbedPlugin(probedPlugin VolumePlugin) error {
- name := probedPlugin.GetPluginName()
- if errs := validation.IsQualifiedName(name); len(errs) != 0 {
- return fmt.Errorf("volume plugin has invalid name: %q: %s", name, strings.Join(errs, ";"))
- }
-
- err := probedPlugin.Init(pm.Host)
- if err != nil {
- return fmt.Errorf("Failed to load volume plugin %s, error: %s", name, err.Error())
- }
-
- glog.V(1).Infof("Loaded volume plugin %q", name)
- return nil
-}
-
-// FindPluginBySpec looks for a plugin that can support a given volume
-// specification. If no plugins can support or more than one plugin can
-// support it, return error.
-func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
- pm.mutex.Lock()
- defer pm.mutex.Unlock()
-
- if spec == nil {
- return nil, fmt.Errorf("Could not find plugin because volume spec is nil")
- }
-
- matchedPluginNames := []string{}
- matches := []VolumePlugin{}
- for k, v := range pm.plugins {
- if v.CanSupport(spec) {
- matchedPluginNames = append(matchedPluginNames, k)
- matches = append(matches, v)
- }
- }
-
- pm.refreshProbedPlugins()
- for _, plugin := range pm.probedPlugins {
- if plugin.CanSupport(spec) {
- matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
- matches = append(matches, plugin)
- }
- }
-
- if len(matches) == 0 {
- return nil, fmt.Errorf("no volume plugin matched")
- }
- if len(matches) > 1 {
- return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
- }
- return matches[0], nil
-}
-
-// FindPluginByName fetches a plugin by name or by legacy name. If no plugin
-// is found, returns error.
-func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error) {
- pm.mutex.Lock()
- defer pm.mutex.Unlock()
-
- // Once we can get rid of legacy names we can reduce this to a map lookup.
- matchedPluginNames := []string{}
- matches := []VolumePlugin{}
- for k, v := range pm.plugins {
- if v.GetPluginName() == name {
- matchedPluginNames = append(matchedPluginNames, k)
- matches = append(matches, v)
- }
- }
-
- pm.refreshProbedPlugins()
- for _, plugin := range pm.probedPlugins {
- if plugin.GetPluginName() == name {
- matchedPluginNames = append(matchedPluginNames, plugin.GetPluginName())
- matches = append(matches, plugin)
- }
- }
-
- if len(matches) == 0 {
- return nil, fmt.Errorf("no volume plugin matched")
- }
- if len(matches) > 1 {
- return nil, fmt.Errorf("multiple volume plugins matched: %s", strings.Join(matchedPluginNames, ","))
- }
- return matches[0], nil
-}
-
-// Check if probedPlugin cache update is required.
-// If it is, initialize all probed plugins and replace the cache with them.
-func (pm *VolumePluginMgr) refreshProbedPlugins() {
- updated, plugins, err := pm.prober.Probe()
- if err != nil {
- glog.Errorf("Error dynamically probing plugins: %s", err)
- return // Use cached plugins upon failure.
- }
-
- if updated {
- pm.probedPlugins = []VolumePlugin{}
- for _, plugin := range plugins {
- if err := pm.initProbedPlugin(plugin); err != nil {
- glog.Errorf("Error initializing dynamically probed plugin %s; error: %s",
- plugin.GetPluginName(), err)
- continue
- }
- pm.probedPlugins = append(pm.probedPlugins, plugin)
- }
- }
-}
-
-// FindPersistentPluginBySpec looks for a persistent volume plugin that can
-// support a given volume specification. If no plugin is found, return an
-// error
-func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, fmt.Errorf("Could not find volume plugin for spec: %#v", spec)
- }
- if persistentVolumePlugin, ok := volumePlugin.(PersistentVolumePlugin); ok {
- return persistentVolumePlugin, nil
- }
- return nil, fmt.Errorf("no persistent volume plugin matched")
-}
-
-// FindPersistentPluginByName fetches a persistent volume plugin by name. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
- if persistentVolumePlugin, ok := volumePlugin.(PersistentVolumePlugin); ok {
- return persistentVolumePlugin, nil
- }
- return nil, fmt.Errorf("no persistent volume plugin matched")
-}
-
-// FindRecyclablePluginByName fetches a persistent volume plugin by name. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindRecyclablePluginBySpec(spec *Spec) (RecyclableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
- if recyclableVolumePlugin, ok := volumePlugin.(RecyclableVolumePlugin); ok {
- return recyclableVolumePlugin, nil
- }
- return nil, fmt.Errorf("no recyclable volume plugin matched")
-}
-
-// FindProvisionablePluginByName fetches a persistent volume plugin by name. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindProvisionablePluginByName(name string) (ProvisionableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
- if provisionableVolumePlugin, ok := volumePlugin.(ProvisionableVolumePlugin); ok {
- return provisionableVolumePlugin, nil
- }
- return nil, fmt.Errorf("no provisionable volume plugin matched")
-}
-
-// FindDeletablePluginBySppec fetches a persistent volume plugin by spec. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindDeletablePluginBySpec(spec *Spec) (DeletableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
- if deletableVolumePlugin, ok := volumePlugin.(DeletableVolumePlugin); ok {
- return deletableVolumePlugin, nil
- }
- return nil, fmt.Errorf("no deletable volume plugin matched")
-}
-
-// FindDeletablePluginByName fetches a persistent volume plugin by name. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindDeletablePluginByName(name string) (DeletableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
- if deletableVolumePlugin, ok := volumePlugin.(DeletableVolumePlugin); ok {
- return deletableVolumePlugin, nil
- }
- return nil, fmt.Errorf("no deletable volume plugin matched")
-}
-
-// FindCreatablePluginBySpec fetches a persistent volume plugin by name. If
-// no plugin is found, returns error.
-func (pm *VolumePluginMgr) FindCreatablePluginBySpec(spec *Spec) (ProvisionableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
- if provisionableVolumePlugin, ok := volumePlugin.(ProvisionableVolumePlugin); ok {
- return provisionableVolumePlugin, nil
- }
- return nil, fmt.Errorf("no creatable volume plugin matched")
-}
-
-// FindAttachablePluginBySpec fetches a persistent volume plugin by spec.
-// Unlike the other "FindPlugin" methods, this does not return error if no
-// plugin is found. All volumes require a mounter and unmounter, but not
-// every volume will have an attacher/detacher.
-func (pm *VolumePluginMgr) FindAttachablePluginBySpec(spec *Spec) (AttachableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
- if attachableVolumePlugin, ok := volumePlugin.(AttachableVolumePlugin); ok {
- return attachableVolumePlugin, nil
- }
- return nil, nil
-}
-
-// FindAttachablePluginByName fetches an attachable volume plugin by name.
-// Unlike the other "FindPlugin" methods, this does not return error if no
-// plugin is found. All volumes require a mounter and unmounter, but not
-// every volume will have an attacher/detacher.
-func (pm *VolumePluginMgr) FindAttachablePluginByName(name string) (AttachableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
- if attachablePlugin, ok := volumePlugin.(AttachableVolumePlugin); ok {
- return attachablePlugin, nil
- }
- return nil, nil
-}
-
-// FindExpandablePluginBySpec fetches a persistent volume plugin by spec.
-func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
-
- if expandableVolumePlugin, ok := volumePlugin.(ExpandableVolumePlugin); ok {
- return expandableVolumePlugin, nil
- }
- return nil, nil
-}
-
-// FindExpandablePluginBySpec fetches a persistent volume plugin by name.
-func (pm *VolumePluginMgr) FindExpandablePluginByName(name string) (ExpandableVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
-
- if expandableVolumePlugin, ok := volumePlugin.(ExpandableVolumePlugin); ok {
- return expandableVolumePlugin, nil
- }
- return nil, nil
-}
-
-// FindMapperPluginBySpec fetches a block volume plugin by spec.
-func (pm *VolumePluginMgr) FindMapperPluginBySpec(spec *Spec) (BlockVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginBySpec(spec)
- if err != nil {
- return nil, err
- }
-
- if blockVolumePlugin, ok := volumePlugin.(BlockVolumePlugin); ok {
- return blockVolumePlugin, nil
- }
- return nil, nil
-}
-
-// FindMapperPluginByName fetches a block volume plugin by name.
-func (pm *VolumePluginMgr) FindMapperPluginByName(name string) (BlockVolumePlugin, error) {
- volumePlugin, err := pm.FindPluginByName(name)
- if err != nil {
- return nil, err
- }
-
- if blockVolumePlugin, ok := volumePlugin.(BlockVolumePlugin); ok {
- return blockVolumePlugin, nil
- }
- return nil, nil
-}
-
-// NewPersistentVolumeRecyclerPodTemplate creates a template for a recycler
-// pod. By default, a recycler pod simply runs "rm -rf" on a volume and tests
-// for emptiness. Most attributes of the template will be correct for most
-// plugin implementations. The following attributes can be overridden per
-// plugin via configuration:
-//
-// 1. pod.Spec.Volumes[0].VolumeSource must be overridden. Recycler
-// implementations without a valid VolumeSource will fail.
-// 2. pod.GenerateName helps distinguish recycler pods by name. Recommended.
-// Default is "pv-recycler-".
-// 3. pod.Spec.ActiveDeadlineSeconds gives the recycler pod a maximum timeout
-// before failing. Recommended. Default is 60 seconds.
-//
-// See HostPath and NFS for working recycler examples
-func NewPersistentVolumeRecyclerPodTemplate() *v1.Pod {
- timeout := int64(60)
- pod := &v1.Pod{
- ObjectMeta: metav1.ObjectMeta{
- GenerateName: "pv-recycler-",
- Namespace: metav1.NamespaceDefault,
- },
- Spec: v1.PodSpec{
- ActiveDeadlineSeconds: &timeout,
- RestartPolicy: v1.RestartPolicyNever,
- Volumes: []v1.Volume{
- {
- Name: "vol",
- // IMPORTANT! All plugins using this template MUST
- // override pod.Spec.Volumes[0].VolumeSource Recycler
- // implementations without a valid VolumeSource will fail.
- VolumeSource: v1.VolumeSource{},
- },
- },
- Containers: []v1.Container{
- {
- Name: "pv-recycler",
- Image: "busybox:1.27",
- Command: []string{"/bin/sh"},
- Args: []string{"-c", "test -e /scrub && rm -rf /scrub/..?* /scrub/.[!.]* /scrub/* && test -z \"$(ls -A /scrub)\" || exit 1"},
- VolumeMounts: []v1.VolumeMount{
- {
- Name: "vol",
- MountPath: "/scrub",
- },
- },
- },
- },
- },
- }
- return pod
-}
-
-// Check validity of recycle pod template
-// List of checks:
-// - at least one volume is defined in the recycle pod template
-// If successful, returns nil
-// if unsuccessful, returns an error.
-func ValidateRecyclerPodTemplate(pod *v1.Pod) error {
- if len(pod.Spec.Volumes) < 1 {
- return fmt.Errorf("does not contain any volume(s)")
- }
- return nil
-}
-
-type dummyPluginProber struct{}
-
-func (*dummyPluginProber) Init() error { return nil }
-func (*dummyPluginProber) Probe() (bool, []VolumePlugin, error) { return false, nil, nil }
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go b/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go
deleted file mode 100644
index bbb4b0105..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// +build linux darwin
-
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package fs
-
-import (
- "bytes"
- "fmt"
- "os/exec"
- "strings"
-
- "golang.org/x/sys/unix"
-
- "k8s.io/apimachinery/pkg/api/resource"
-)
-
-// FSInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
-// for the filesystem that path resides upon.
-func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
- statfs := &unix.Statfs_t{}
- err := unix.Statfs(path, statfs)
- if err != nil {
- return 0, 0, 0, 0, 0, 0, err
- }
-
- // Available is blocks available * fragment size
- available := int64(statfs.Bavail) * int64(statfs.Bsize)
-
- // Capacity is total block count * fragment size
- capacity := int64(statfs.Blocks) * int64(statfs.Bsize)
-
- // Usage is block being used * fragment size (aka block size).
- usage := (int64(statfs.Blocks) - int64(statfs.Bfree)) * int64(statfs.Bsize)
-
- inodes := int64(statfs.Files)
- inodesFree := int64(statfs.Ffree)
- inodesUsed := inodes - inodesFree
-
- return available, capacity, usage, inodes, inodesFree, inodesUsed, nil
-}
-
-func Du(path string) (*resource.Quantity, error) {
- // Uses the same niceness level as cadvisor.fs does when running du
- // Uses -B 1 to always scale to a blocksize of 1 byte
- out, err := exec.Command("nice", "-n", "19", "du", "-s", "-B", "1", path).CombinedOutput()
- if err != nil {
- return nil, fmt.Errorf("failed command 'du' ($ nice -n 19 du -s -B 1) on path %s with error %v", path, err)
- }
- used, err := resource.ParseQuantity(strings.Fields(string(out))[0])
- if err != nil {
- return nil, fmt.Errorf("failed to parse 'du' output %s due to error %v", out, err)
- }
- used.Format = resource.BinarySI
- return &used, nil
-}
-
-// Find uses the equivalent of the command `find <path> -dev -printf '.' | wc -c` to count files and directories.
-// While this is not an exact measure of inodes used, it is a very good approximation.
-func Find(path string) (int64, error) {
- if path == "" {
- return 0, fmt.Errorf("invalid directory")
- }
- var counter byteCounter
- var stderr bytes.Buffer
- findCmd := exec.Command("find", path, "-xdev", "-printf", ".")
- findCmd.Stdout, findCmd.Stderr = &counter, &stderr
- if err := findCmd.Start(); err != nil {
- return 0, fmt.Errorf("failed to exec cmd %v - %v; stderr: %v", findCmd.Args, err, stderr.String())
- }
- if err := findCmd.Wait(); err != nil {
- return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stderr.String(), err)
- }
- return counter.bytesWritten, nil
-}
-
-// Simple io.Writer implementation that counts how many bytes were written.
-type byteCounter struct{ bytesWritten int64 }
-
-func (b *byteCounter) Write(p []byte) (int, error) {
- b.bytesWritten += int64(len(p))
- return len(p), nil
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_unsupported.go b/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_unsupported.go
deleted file mode 100644
index da41fc8ee..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_unsupported.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// +build !linux,!darwin
-
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package fs
-
-import (
- "fmt"
-
- "k8s.io/apimachinery/pkg/api/resource"
-)
-
-// FSInfo unsupported returns 0 values for available and capacity and an error.
-func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
- return 0, 0, 0, 0, 0, 0, fmt.Errorf("FsInfo not supported for this build.")
-}
-
-func Du(path string) (*resource.Quantity, error) {
- return nil, fmt.Errorf("Du not supported for this build.")
-}
-
-func Find(path string) (int64, error) {
- return 0, fmt.Errorf("Find not supported for this build.")
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/util/recyclerclient/recycler_client.go b/vendor/k8s.io/kubernetes/pkg/volume/util/recyclerclient/recycler_client.go
deleted file mode 100644
index 1af6465c6..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/util/recyclerclient/recycler_client.go
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-Copyright 2018 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package recyclerclient
-
-import (
- "fmt"
-
- "github.com/golang/glog"
- "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/errors"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/fields"
- "k8s.io/apimachinery/pkg/watch"
- clientset "k8s.io/client-go/kubernetes"
-)
-
-type RecycleEventRecorder func(eventtype, message string)
-
-// 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 {
- return internalRecycleVolumeByWatchingPodUntilCompletion(pvName, pod, newRecyclerClient(kubeClient, recorder))
-}
-
-// 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 {
- glog.V(5).Infof("creating recycler pod for volume %s\n", pod.Name)
-
- // Generate unique name for the recycler pod - we need to get "already
- // exists" error when a previous controller has already started recycling
- // the volume. Here we assume that pv.Name is already unique.
- pod.Name = "recycler-for-" + pvName
- pod.GenerateName = ""
-
- stopChannel := make(chan struct{})
- defer close(stopChannel)
- podCh, err := recyclerClient.WatchPod(pod.Name, pod.Namespace, stopChannel)
- if err != nil {
- glog.V(4).Infof("cannot start watcher for pod %s/%s: %v", pod.Namespace, pod.Name, err)
- return err
- }
-
- // Start the pod
- _, err = recyclerClient.CreatePod(pod)
- if err != nil {
- if errors.IsAlreadyExists(err) {
- deleteErr := recyclerClient.DeletePod(pod.Name, pod.Namespace)
- if deleteErr != nil {
- return fmt.Errorf("failed to delete old recycler pod %s/%s: %s", pod.Namespace, pod.Name, deleteErr)
- }
- // Recycler will try again and the old pod will be hopefully deleted
- // at that time.
- return fmt.Errorf("old recycler pod found, will retry later")
- }
- return fmt.Errorf("unexpected error creating recycler pod: %+v", err)
- }
- err = waitForPod(pod, recyclerClient, podCh)
-
- // In all cases delete the recycler pod and log its result.
- glog.V(2).Infof("deleting recycler pod %s/%s", pod.Namespace, pod.Name)
- deleteErr := recyclerClient.DeletePod(pod.Name, pod.Namespace)
- if deleteErr != nil {
- glog.Errorf("failed to delete recycler pod %s/%s: %v", pod.Namespace, pod.Name, err)
- }
-
- // Returning recycler error is preferred, the pod will be deleted again on
- // the next retry.
- if err != nil {
- return fmt.Errorf("failed to recycle volume: %s", err)
- }
-
- // Recycle succeeded but we failed to delete the recycler pod. Report it,
- // the controller will re-try recycling the PV again shortly.
- if deleteErr != nil {
- return fmt.Errorf("failed to delete recycler pod: %s", deleteErr)
- }
-
- return nil
-}
-
-// 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 {
- for {
- event, ok := <-podCh
- if !ok {
- return fmt.Errorf("recycler pod %q watch channel had been closed", pod.Name)
- }
- switch event.Object.(type) {
- case *v1.Pod:
- // POD changed
- pod := event.Object.(*v1.Pod)
- glog.V(4).Infof("recycler pod update received: %s %s/%s %s", event.Type, pod.Namespace, pod.Name, pod.Status.Phase)
- switch event.Type {
- case watch.Added, watch.Modified:
- if pod.Status.Phase == v1.PodSucceeded {
- // Recycle succeeded.
- return nil
- }
- if pod.Status.Phase == v1.PodFailed {
- if pod.Status.Message != "" {
- return fmt.Errorf(pod.Status.Message)
- } else {
- return fmt.Errorf("pod failed, pod.Status.Message unknown.")
- }
- }
-
- case watch.Deleted:
- return fmt.Errorf("recycler pod was deleted")
-
- case watch.Error:
- return fmt.Errorf("recycler pod watcher failed")
- }
-
- case *v1.Event:
- // Event received
- podEvent := event.Object.(*v1.Event)
- glog.V(4).Infof("recycler event received: %s %s/%s %s/%s %s", event.Type, podEvent.Namespace, podEvent.Name, podEvent.InvolvedObject.Namespace, podEvent.InvolvedObject.Name, podEvent.Message)
- if event.Type == watch.Added {
- recyclerClient.Event(podEvent.Type, podEvent.Message)
- }
- }
- }
-}
-
-// recyclerClient abstracts access to a Pod by providing a narrower interface.
-// This makes it easier to mock a client for testing.
-type recyclerClient interface {
- CreatePod(pod *v1.Pod) (*v1.Pod, error)
- GetPod(name, namespace string) (*v1.Pod, error)
- DeletePod(name, namespace string) error
- // WatchPod returns a ListWatch for watching a pod. The stopChannel is used
- // to close the reflector backing the watch. The caller is responsible for
- // derring a close on the channel to stop the reflector.
- WatchPod(name, namespace string, stopChannel chan struct{}) (<-chan watch.Event, error)
- // Event sends an event to the volume that is being recycled.
- Event(eventtype, message string)
-}
-
-func newRecyclerClient(client clientset.Interface, recorder RecycleEventRecorder) recyclerClient {
- return &realRecyclerClient{
- client,
- recorder,
- }
-}
-
-type realRecyclerClient struct {
- client clientset.Interface
- recorder RecycleEventRecorder
-}
-
-func (c *realRecyclerClient) CreatePod(pod *v1.Pod) (*v1.Pod, error) {
- return c.client.CoreV1().Pods(pod.Namespace).Create(pod)
-}
-
-func (c *realRecyclerClient) GetPod(name, namespace string) (*v1.Pod, error) {
- return c.client.CoreV1().Pods(namespace).Get(name, metav1.GetOptions{})
-}
-
-func (c *realRecyclerClient) DeletePod(name, namespace string) error {
- return c.client.CoreV1().Pods(namespace).Delete(name, nil)
-}
-
-func (c *realRecyclerClient) Event(eventtype, message string) {
- c.recorder(eventtype, message)
-}
-
-func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan struct{}) (<-chan watch.Event, error) {
- podSelector, err := fields.ParseSelector("metadata.name=" + name)
- if err != nil {
- return nil, err
- }
- options := metav1.ListOptions{
- FieldSelector: podSelector.String(),
- Watch: true,
- }
-
- podWatch, err := c.client.CoreV1().Pods(namespace).Watch(options)
- if err != nil {
- return nil, err
- }
-
- eventSelector, _ := fields.ParseSelector("involvedObject.name=" + name)
- eventWatch, err := c.client.CoreV1().Events(namespace).Watch(metav1.ListOptions{
- FieldSelector: eventSelector.String(),
- Watch: true,
- })
- if err != nil {
- podWatch.Stop()
- return nil, err
- }
-
- eventCh := make(chan watch.Event, 30)
-
- go func() {
- defer eventWatch.Stop()
- defer podWatch.Stop()
- defer close(eventCh)
- var podWatchChannelClosed bool
- var eventWatchChannelClosed bool
- for {
- select {
- case _ = <-stopChannel:
- return
-
- case podEvent, ok := <-podWatch.ResultChan():
- if !ok {
- podWatchChannelClosed = true
- } else {
- eventCh <- podEvent
- }
- case eventEvent, ok := <-eventWatch.ResultChan():
- if !ok {
- eventWatchChannelClosed = true
- } else {
- eventCh <- eventEvent
- }
- }
- if podWatchChannelClosed && eventWatchChannelClosed {
- break
- }
- }
- }()
-
- return eventCh, nil
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/volume.go b/vendor/k8s.io/kubernetes/pkg/volume/volume.go
deleted file mode 100644
index 471963556..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/volume.go
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
-Copyright 2014 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "time"
-
- "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/resource"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/types"
-)
-
-// Volume represents a directory used by pods or hosts on a node. All method
-// implementations of methods in the volume interface must be idempotent.
-type Volume interface {
- // GetPath returns the path to which the volume should be mounted for the
- // pod.
- GetPath() string
-
- // MetricsProvider embeds methods for exposing metrics (e.g.
- // used, available space).
- MetricsProvider
-}
-
-// BlockVolume interface provides methods to generate global map path
-// and pod device map path.
-type BlockVolume interface {
- // GetGlobalMapPath returns a global map path which contains
- // symbolic links associated to a block device.
- // ex. plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumePluginDependentPath}/{pod uuid}
- GetGlobalMapPath(spec *Spec) (string, error)
- // GetPodDeviceMapPath returns a pod device map path
- // and name of a symbolic link associated to a block device.
- // ex. pods/{podUid}}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/{volumeName}
- GetPodDeviceMapPath() (string, string)
-}
-
-// MetricsProvider exposes metrics (e.g. used,available space) related to a
-// Volume.
-type MetricsProvider interface {
- // GetMetrics returns the Metrics for the Volume. Maybe expensive for
- // some implementations.
- GetMetrics() (*Metrics, error)
-}
-
-// Metrics represents the used and available bytes of the Volume.
-type Metrics struct {
- // The time at which these stats were updated.
- Time metav1.Time
-
- // Used represents the total bytes used by the Volume.
- // Note: For block devices this maybe more than the total size of the files.
- Used *resource.Quantity
-
- // Capacity represents the total capacity (bytes) of the volume's
- // underlying storage. For Volumes that share a filesystem with the host
- // (e.g. emptydir, hostpath) this is the size of the underlying storage,
- // and will not equal Used + Available as the fs is shared.
- Capacity *resource.Quantity
-
- // Available represents the storage space available (bytes) for the
- // Volume. For Volumes that share a filesystem with the host (e.g.
- // emptydir, hostpath), this is the available space on the underlying
- // storage, and is shared with host processes and other Volumes.
- Available *resource.Quantity
-
- // InodesUsed represents the total inodes used by the Volume.
- InodesUsed *resource.Quantity
-
- // Inodes represents the total number of inodes available in the volume.
- // For volumes that share a filesystem with the host (e.g. emptydir, hostpath),
- // this is the inodes available in the underlying storage,
- // and will not equal InodesUsed + InodesFree as the fs is shared.
- Inodes *resource.Quantity
-
- // InodesFree represent the inodes available for the volume. For Volumes that share
- // a filesystem with the host (e.g. emptydir, hostpath), this is the free inodes
- // on the underlying storage, and is shared with host processes and other volumes
- InodesFree *resource.Quantity
-}
-
-// Attributes represents the attributes of this mounter.
-type Attributes struct {
- ReadOnly bool
- Managed bool
- SupportsSELinux bool
-}
-
-// Mounter interface provides methods to set up/mount the volume.
-type Mounter interface {
- // Uses Interface to provide the path for Docker binds.
- Volume
-
- // CanMount is called immediately prior to Setup to check if
- // the required components (binaries, etc.) are available on
- // the underlying node to complete the subsequent SetUp (mount)
- // operation. If CanMount returns error, the mount operation is
- // aborted and an event is generated indicating that the node
- // does not have the required binaries to complete the mount.
- // If CanMount succeeds, the mount operation continues
- // normally. The CanMount check can be enabled or disabled
- // using the experimental-check-mount-binaries binary flag
- CanMount() error
-
- // SetUp prepares and mounts/unpacks the volume to a
- // self-determined directory path. The mount point and its
- // content should be owned by 'fsGroup' so that it can be
- // accessed by the pod. This may be called more than once, so
- // implementations must be idempotent.
- SetUp(fsGroup *int64) error
- // SetUpAt prepares and mounts/unpacks the volume to the
- // specified directory path, which may or may not exist yet.
- // The mount point and its content should be owned by
- // 'fsGroup' so that it can be accessed by the pod. This may
- // be called more than once, so implementations must be
- // idempotent.
- SetUpAt(dir string, fsGroup *int64) error
- // GetAttributes returns the attributes of the mounter.
- GetAttributes() Attributes
-}
-
-// Unmounter interface provides methods to cleanup/unmount the volumes.
-type Unmounter interface {
- Volume
- // TearDown unmounts the volume from a self-determined directory and
- // removes traces of the SetUp procedure.
- TearDown() error
- // TearDown unmounts the volume from the specified directory and
- // removes traces of the SetUp procedure.
- TearDownAt(dir string) error
-}
-
-// BlockVolumeMapper interface provides methods to set up/map the volume.
-type BlockVolumeMapper interface {
- BlockVolume
- // SetUpDevice prepares the volume to a self-determined directory path,
- // which may or may not exist yet and returns combination of physical
- // device path of a block volume and error.
- // If the plugin is non-attachable, it should prepare the device
- // in /dev/ (or where appropriate) and return unique device path.
- // Unique device path across kubelet node reboot is required to avoid
- // unexpected block volume destruction.
- // If the plugin is attachable, it should not do anything here,
- // just return empty string for device path.
- // Instead, attachable plugin have to return unique device path
- // at attacher.Attach() and attacher.WaitForAttach().
- // This may be called more than once, so implementations must be idempotent.
- SetUpDevice() (string, error)
-}
-
-// BlockVolumeUnmapper interface provides methods to cleanup/unmap the volumes.
-type BlockVolumeUnmapper interface {
- BlockVolume
- // TearDownDevice removes traces of the SetUpDevice procedure under
- // a self-determined directory.
- // If the plugin is non-attachable, this method detaches the volume
- // from a node.
- TearDownDevice(mapPath string, devicePath string) error
-}
-
-// Provisioner is an interface that creates templates for PersistentVolumes
-// and can create the volume as a new resource in the infrastructure provider.
-type Provisioner interface {
- // Provision creates the resource by allocating the underlying volume in a
- // storage system. This method should block until completion and returns
- // PersistentVolume representing the created storage resource.
- Provision() (*v1.PersistentVolume, error)
-}
-
-// Deleter removes the resource from the underlying storage provider. Calls
-// to this method should block until the deletion is complete. Any error
-// returned indicates the volume has failed to be reclaimed. A nil return
-// indicates success.
-type Deleter interface {
- Volume
- // This method should block until completion.
- // deletedVolumeInUseError returned from this function will not be reported
- // as error and it will be sent as "Info" event to the PV being deleted. The
- // volume controller will retry deleting the volume in the next periodic
- // sync. This can be used to postpone deletion of a volume that is being
- // detached from a node. Deletion of such volume would fail anyway and such
- // error would confuse users.
- Delete() error
-}
-
-// Attacher can attach a volume to a node.
-type Attacher interface {
- // Attaches the volume specified by the given spec to the node with the given Name.
- // On success, returns the device path where the device was attached on the
- // node.
- Attach(spec *Spec, nodeName types.NodeName) (string, error)
-
- // VolumesAreAttached checks whether the list of volumes still attached to the specified
- // node. It returns a map which maps from the volume spec to the checking result.
- // If an error is occurred during checking, the error will be returned
- VolumesAreAttached(specs []*Spec, nodeName types.NodeName) (map[*Spec]bool, error)
-
- // WaitForAttach blocks until the device is attached to this
- // node. If it successfully attaches, the path to the device
- // is returned. Otherwise, if the device does not attach after
- // the given timeout period, an error will be returned.
- WaitForAttach(spec *Spec, devicePath string, pod *v1.Pod, timeout time.Duration) (string, error)
-
- // GetDeviceMountPath returns a path where the device should
- // be mounted after it is attached. This is a global mount
- // point which should be bind mounted for individual volumes.
- GetDeviceMountPath(spec *Spec) (string, error)
-
- // MountDevice mounts the disk to a global path which
- // individual pods can then bind mount
- MountDevice(spec *Spec, devicePath string, deviceMountPath string) error
-}
-
-type BulkVolumeVerifier interface {
- // BulkVerifyVolumes checks whether the list of volumes still attached to the
- // the clusters in the node. It returns a map which maps from the volume spec to the checking result.
- // If an error occurs during check - error should be returned and volume on nodes
- // should be assumed as still attached.
- BulkVerifyVolumes(volumesByNode map[types.NodeName][]*Spec) (map[types.NodeName]map[*Spec]bool, error)
-}
-
-// Detacher can detach a volume from a node.
-type Detacher interface {
- // Detach the given volume from the node with the given Name.
- // volumeName is name of the volume as returned from plugin's
- // GetVolumeName().
- Detach(volumeName string, nodeName types.NodeName) error
-
- // UnmountDevice unmounts the global mount of the disk. This
- // should only be called once all bind mounts have been
- // unmounted.
- UnmountDevice(deviceMountPath string) error
-}
-
-// NewDeletedVolumeInUseError returns a new instance of DeletedVolumeInUseError
-// error.
-func NewDeletedVolumeInUseError(message string) error {
- return deletedVolumeInUseError(message)
-}
-
-type deletedVolumeInUseError string
-
-var _ error = deletedVolumeInUseError("")
-
-// IsDeletedVolumeInUse returns true if an error returned from Delete() is
-// deletedVolumeInUseError
-func IsDeletedVolumeInUse(err error) bool {
- switch err.(type) {
- case deletedVolumeInUseError:
- return true
- default:
- return false
- }
-}
-
-func (err deletedVolumeInUseError) Error() string {
- return string(err)
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go b/vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go
deleted file mode 100644
index d67ee4a95..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// +build linux
-
-/*
-Copyright 2016 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-import (
- "path/filepath"
- "syscall"
-
- "os"
-
- "github.com/golang/glog"
-)
-
-const (
- rwMask = os.FileMode(0660)
- roMask = os.FileMode(0440)
-)
-
-// SetVolumeOwnership modifies the given volume to be owned by
-// fsGroup, and sets SetGid so that newly created files are owned by
-// fsGroup. If fsGroup is nil nothing is done.
-func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
-
- if fsGroup == nil {
- return nil
- }
-
- return filepath.Walk(mounter.GetPath(), func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- // chown and chmod pass through to the underlying file for symlinks.
- // Symlinks have a mode of 777 but this really doesn't mean anything.
- // The permissions of the underlying file are what matter.
- // However, if one reads the mode of a symlink then chmods the symlink
- // with that mode, it changes the mode of the underlying file, overridden
- // the defaultMode and permissions initialized by the volume plugin, which
- // is not what we want; thus, we skip chown/chmod for symlinks.
- if info.Mode()&os.ModeSymlink != 0 {
- return nil
- }
-
- stat, ok := info.Sys().(*syscall.Stat_t)
- if !ok {
- return nil
- }
-
- if stat == nil {
- glog.Errorf("Got nil stat_t for path %v while setting ownership of volume", path)
- return nil
- }
-
- err = os.Chown(path, int(stat.Uid), int(*fsGroup))
- if err != nil {
- glog.Errorf("Chown failed on %v: %v", path, err)
- }
-
- mask := rwMask
- if mounter.GetAttributes().ReadOnly {
- mask = roMask
- }
-
- if info.IsDir() {
- mask |= os.ModeSetgid
- }
-
- err = os.Chmod(path, info.Mode()|mask)
- if err != nil {
- glog.Errorf("Chmod failed on %v: %v", path, err)
- }
-
- return nil
- })
-}
-
-// IsSameFSGroup is called only for requests to mount an already mounted
-// volume. It checks if fsGroup of new mount request is the same or not.
-// It returns false if it not the same. It also returns current Gid of a path
-// provided for dir variable.
-func IsSameFSGroup(dir string, fsGroup int64) (bool, int, error) {
- info, err := os.Stat(dir)
- if err != nil {
- glog.Errorf("Error getting stats for %s (%v)", dir, err)
- return false, 0, err
- }
- s := info.Sys().(*syscall.Stat_t)
- return int(s.Gid) == int(fsGroup), int(s.Gid), nil
-}
diff --git a/vendor/k8s.io/kubernetes/pkg/volume/volume_unsupported.go b/vendor/k8s.io/kubernetes/pkg/volume/volume_unsupported.go
deleted file mode 100644
index 46a6aeaf0..000000000
--- a/vendor/k8s.io/kubernetes/pkg/volume/volume_unsupported.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// +build !linux
-
-/*
-Copyright 2016 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package volume
-
-func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
- return nil
-}
-
-func IsSameFSGroup(dir string, fsGroup int64) (bool, int, error) {
- return true, int(fsGroup), nil
-}