Update go dependencies
This commit is contained in:
parent
e0561ddeb9
commit
88a2751234
1970 changed files with 413928 additions and 222867 deletions
86
vendor/k8s.io/kubernetes/pkg/volume/BUILD
generated
vendored
86
vendor/k8s.io/kubernetes/pkg/volume/BUILD
generated
vendored
|
|
@ -4,10 +4,8 @@ licenses(["notice"])
|
|||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
"go_test",
|
||||
"cgo_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
|
@ -26,23 +24,24 @@ go_library(
|
|||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/errors:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/client/clientset_generated/clientset:go_default_library",
|
||||
"//pkg/cloudprovider:go_default_library",
|
||||
"//pkg/fields:go_default_library",
|
||||
"//pkg/types:go_default_library",
|
||||
"//pkg/util/chmod:go_default_library",
|
||||
"//pkg/util/chown:go_default_library",
|
||||
"//pkg/util/errors:go_default_library",
|
||||
"//pkg/util/io:go_default_library",
|
||||
"//pkg/util/mount:go_default_library",
|
||||
"//pkg/util/sets:go_default_library",
|
||||
"//pkg/util/validation:go_default_library",
|
||||
"//pkg/volume/util:go_default_library",
|
||||
"//pkg/watch:go_default_library",
|
||||
"//vendor:github.com/golang/glog",
|
||||
"//vendor:k8s.io/apimachinery/pkg/api/errors",
|
||||
"//vendor:k8s.io/apimachinery/pkg/api/resource",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/fields",
|
||||
"//vendor:k8s.io/apimachinery/pkg/types",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/errors",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/validation",
|
||||
"//vendor:k8s.io/apimachinery/pkg/watch",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -53,23 +52,74 @@ go_test(
|
|||
"plugins_test.go",
|
||||
"util_test.go",
|
||||
],
|
||||
library = "go_default_library",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/errors:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/watch:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/util/slice:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/api/errors",
|
||||
"//vendor:k8s.io/apimachinery/pkg/api/resource",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/types",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
"//vendor:k8s.io/apimachinery/pkg/watch",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_xtest",
|
||||
srcs = ["metrics_du_test.go"],
|
||||
srcs = [
|
||||
"metrics_du_test.go",
|
||||
"metrics_statfs_test.go",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/util/testing:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/testing:go_default_library",
|
||||
"//vendor:k8s.io/client-go/util/testing",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/volume/aws_ebs:all-srcs",
|
||||
"//pkg/volume/azure_dd:all-srcs",
|
||||
"//pkg/volume/azure_file:all-srcs",
|
||||
"//pkg/volume/cephfs:all-srcs",
|
||||
"//pkg/volume/cinder:all-srcs",
|
||||
"//pkg/volume/configmap:all-srcs",
|
||||
"//pkg/volume/downwardapi:all-srcs",
|
||||
"//pkg/volume/empty_dir:all-srcs",
|
||||
"//pkg/volume/fc:all-srcs",
|
||||
"//pkg/volume/flexvolume:all-srcs",
|
||||
"//pkg/volume/flocker:all-srcs",
|
||||
"//pkg/volume/gce_pd:all-srcs",
|
||||
"//pkg/volume/git_repo:all-srcs",
|
||||
"//pkg/volume/glusterfs:all-srcs",
|
||||
"//pkg/volume/host_path:all-srcs",
|
||||
"//pkg/volume/iscsi:all-srcs",
|
||||
"//pkg/volume/nfs:all-srcs",
|
||||
"//pkg/volume/photon_pd:all-srcs",
|
||||
"//pkg/volume/portworx:all-srcs",
|
||||
"//pkg/volume/projected:all-srcs",
|
||||
"//pkg/volume/quobyte:all-srcs",
|
||||
"//pkg/volume/rbd:all-srcs",
|
||||
"//pkg/volume/scaleio:all-srcs",
|
||||
"//pkg/volume/secret:all-srcs",
|
||||
"//pkg/volume/testing:all-srcs",
|
||||
"//pkg/volume/util:all-srcs",
|
||||
"//pkg/volume/validation:all-srcs",
|
||||
"//pkg/volume/vsphere_volume:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
|
|
|||
26
vendor/k8s.io/kubernetes/pkg/volume/OWNERS
generated
vendored
26
vendor/k8s.io/kubernetes/pkg/volume/OWNERS
generated
vendored
|
|
@ -1,5 +1,21 @@
|
|||
assignees:
|
||||
- saad-ali
|
||||
- thockin
|
||||
- pmorie
|
||||
- jsafrane
|
||||
approvers:
|
||||
- saad-ali
|
||||
- thockin
|
||||
- jsafrane
|
||||
- matchstick
|
||||
reviewers:
|
||||
- thockin
|
||||
- smarterclayton
|
||||
- deads2k
|
||||
- brendandburns
|
||||
- derekwaynecarr
|
||||
- bprashanth
|
||||
- pmorie
|
||||
- saad-ali
|
||||
- justinsb
|
||||
- jsafrane
|
||||
- rootfs
|
||||
- jingxu97
|
||||
- rkouj
|
||||
- msau42
|
||||
- gnufied
|
||||
|
|
|
|||
27
vendor/k8s.io/kubernetes/pkg/volume/README.md
generated
vendored
Normal file
27
vendor/k8s.io/kubernetes/pkg/volume/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
## Multipath
|
||||
|
||||
To leverage multiple paths for block storage, it is important to perform the
|
||||
multipath configuration on the host.
|
||||
If your distribution does not provide `/etc/multipath.conf`, then you can
|
||||
either use the following minimalistic one:
|
||||
|
||||
defaults {
|
||||
find_multipaths yes
|
||||
user_friendly_names yes
|
||||
}
|
||||
|
||||
or create a new one by running:
|
||||
|
||||
$ mpathconf --enable
|
||||
|
||||
Finally you'll need to ensure to start or reload and enable multipath:
|
||||
|
||||
$ systemctl enable multipathd.service
|
||||
$ systemctl restart multipathd.service
|
||||
|
||||
**Note:** Any change to `multipath.conf` or enabling multipath can lead to
|
||||
inaccessible block devices, because they'll be claimed by multipath and
|
||||
exposed as a device in /dev/mapper/*.
|
||||
|
||||
Some additional informations about multipath can be found in the
|
||||
[iSCSI documentation](iscsi/README.md)
|
||||
5
vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go
generated
vendored
5
vendor/k8s.io/kubernetes/pkg/volume/metrics_du.go
generated
vendored
|
|
@ -17,7 +17,8 @@ limitations under the License.
|
|||
package volume
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ func NewMetricsDu(path string) MetricsProvider {
|
|||
// and gathering filesystem info for the Volume path.
|
||||
// See MetricsProvider.GetMetrics
|
||||
func (md *metricsDu) GetMetrics() (*Metrics, error) {
|
||||
metrics := &Metrics{}
|
||||
metrics := &Metrics{Time: metav1.Now()}
|
||||
if md.path == "" {
|
||||
return metrics, NewNoPathDefinedError()
|
||||
}
|
||||
|
|
|
|||
5
vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go
generated
vendored
5
vendor/k8s.io/kubernetes/pkg/volume/metrics_statfs.go
generated
vendored
|
|
@ -17,7 +17,8 @@ limitations under the License.
|
|||
package volume
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ func NewMetricsStatFS(path string) MetricsProvider {
|
|||
// 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{}
|
||||
metrics := &Metrics{Time: metav1.Now()}
|
||||
if md.path == "" {
|
||||
return metrics, NewNoPathDefinedError()
|
||||
}
|
||||
|
|
|
|||
105
vendor/k8s.io/kubernetes/pkg/volume/plugins.go
generated
vendored
105
vendor/k8s.io/kubernetes/pkg/volume/plugins.go
generated
vendored
|
|
@ -23,14 +23,15 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
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"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
utilerrors "k8s.io/kubernetes/pkg/util/errors"
|
||||
"k8s.io/kubernetes/pkg/util/io"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
"k8s.io/kubernetes/pkg/util/validation"
|
||||
)
|
||||
|
||||
// VolumeOptions contains option information about a volume.
|
||||
|
|
@ -40,15 +41,17 @@ type VolumeOptions struct {
|
|||
// many kinds of provisioners.
|
||||
|
||||
// Reclamation policy for a persistent volume
|
||||
PersistentVolumeReclaimPolicy api.PersistentVolumeReclaimPolicy
|
||||
// PV.Name of the appropriate PersistentVolume. Used to generate cloud
|
||||
// volume name.
|
||||
PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy
|
||||
// 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 *api.PersistentVolumeClaim
|
||||
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
|
||||
|
|
@ -90,12 +93,12 @@ type VolumePlugin interface {
|
|||
|
||||
// NewMounter creates a new volume.Mounter from an API specification.
|
||||
// Ownership of the spec pointer in *not* transferred.
|
||||
// - spec: The api.Volume spec
|
||||
// - spec: The v1.Volume spec
|
||||
// - pod: The enclosing pod
|
||||
NewMounter(spec *Spec, podRef *api.Pod, opts VolumeOptions) (Mounter, error)
|
||||
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 api.Volume spec.
|
||||
// - 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)
|
||||
|
||||
|
|
@ -104,6 +107,16 @@ type VolumePlugin interface {
|
|||
// 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
|
||||
|
|
@ -111,7 +124,7 @@ type VolumePlugin interface {
|
|||
type PersistentVolumePlugin interface {
|
||||
VolumePlugin
|
||||
// GetAccessModes describes the ways a given volume can be accessed/mounted.
|
||||
GetAccessModes() []api.PersistentVolumeAccessMode
|
||||
GetAccessModes() []v1.PersistentVolumeAccessMode
|
||||
}
|
||||
|
||||
// RecyclableVolumePlugin is an extended interface of VolumePlugin and is used
|
||||
|
|
@ -119,12 +132,13 @@ type PersistentVolumePlugin interface {
|
|||
// again to new claims
|
||||
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. The
|
||||
// recycler will use the provided recorder to write any events that might be
|
||||
|
||||
// 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.
|
||||
NewRecycler(pvName string, spec *Spec, eventRecorder RecycleEventRecorder) (Recycler, error)
|
||||
Recycle(pvName string, spec *Spec, eventRecorder RecycleEventRecorder) error
|
||||
}
|
||||
|
||||
// DeletableVolumePlugin is an extended interface of VolumePlugin and is used
|
||||
|
|
@ -142,6 +156,8 @@ 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"
|
||||
// Mount options annotations
|
||||
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
||||
)
|
||||
|
||||
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
|
||||
|
|
@ -190,7 +206,7 @@ type VolumeHost interface {
|
|||
// 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 *api.Pod, opts VolumeOptions) (Mounter, error)
|
||||
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
|
||||
|
|
@ -212,8 +228,11 @@ type VolumeHost interface {
|
|||
// Returns host IP or nil in the case of error.
|
||||
GetHostIP() (net.IP, error)
|
||||
|
||||
// Returns node allocatable
|
||||
GetNodeAllocatable() (api.ResourceList, error)
|
||||
// Returns node allocatable.
|
||||
GetNodeAllocatable() (v1.ResourceList, error)
|
||||
|
||||
// Returns a function that returns a secret.
|
||||
GetSecretFunc() func(namespace, name string) (*v1.Secret, error)
|
||||
}
|
||||
|
||||
// VolumePluginMgr tracks registered plugins.
|
||||
|
|
@ -224,8 +243,8 @@ type VolumePluginMgr struct {
|
|||
|
||||
// Spec is an internal representation of a volume. All API volume types translate to Spec.
|
||||
type Spec struct {
|
||||
Volume *api.Volume
|
||||
PersistentVolume *api.PersistentVolume
|
||||
Volume *v1.Volume
|
||||
PersistentVolume *v1.PersistentVolume
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +288,7 @@ type VolumeConfig struct {
|
|||
// which override specific properties of the pod in accordance with that
|
||||
// plugin. See NewPersistentVolumeRecyclerPodTemplate for the properties
|
||||
// that are expected to be overridden.
|
||||
RecyclerPodTemplate *api.Pod
|
||||
RecyclerPodTemplate *v1.Pod
|
||||
|
||||
// RecyclerMinimumTimeout is the minimum amount of time in seconds for the
|
||||
// recycler pod's ActiveDeadlineSeconds attribute. Added to the minimum
|
||||
|
|
@ -296,15 +315,15 @@ type VolumeConfig struct {
|
|||
ProvisioningEnabled bool
|
||||
}
|
||||
|
||||
// NewSpecFromVolume creates an Spec from an api.Volume
|
||||
func NewSpecFromVolume(vs *api.Volume) *Spec {
|
||||
// NewSpecFromVolume creates an Spec from an v1.Volume
|
||||
func NewSpecFromVolume(vs *v1.Volume) *Spec {
|
||||
return &Spec{
|
||||
Volume: vs,
|
||||
}
|
||||
}
|
||||
|
||||
// NewSpecFromPersistentVolume creates an Spec from an api.PersistentVolume
|
||||
func NewSpecFromPersistentVolume(pv *api.PersistentVolume, readOnly bool) *Spec {
|
||||
// NewSpecFromPersistentVolume creates an Spec from an v1.PersistentVolume
|
||||
func NewSpecFromPersistentVolume(pv *v1.PersistentVolume, readOnly bool) *Spec {
|
||||
return &Spec{
|
||||
PersistentVolume: pv,
|
||||
ReadOnly: readOnly,
|
||||
|
|
@ -526,32 +545,32 @@ func (pm *VolumePluginMgr) FindAttachablePluginByName(name string) (AttachableVo
|
|||
// before failing. Recommended. Default is 60 seconds.
|
||||
//
|
||||
// See HostPath and NFS for working recycler examples
|
||||
func NewPersistentVolumeRecyclerPodTemplate() *api.Pod {
|
||||
func NewPersistentVolumeRecyclerPodTemplate() *v1.Pod {
|
||||
timeout := int64(60)
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
GenerateName: "pv-recycler-",
|
||||
Namespace: api.NamespaceDefault,
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Spec: v1.PodSpec{
|
||||
ActiveDeadlineSeconds: &timeout,
|
||||
RestartPolicy: api.RestartPolicyNever,
|
||||
Volumes: []api.Volume{
|
||||
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: api.VolumeSource{},
|
||||
VolumeSource: v1.VolumeSource{},
|
||||
},
|
||||
},
|
||||
Containers: []api.Container{
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Name: "pv-recycler",
|
||||
Image: "gcr.io/google_containers/busybox",
|
||||
Command: []string{"/bin/sh"},
|
||||
Args: []string{"-c", "test -e /scrub && rm -rf /scrub/..?* /scrub/.[!.]* /scrub/* && test -z \"$(ls -A /scrub)\" || exit 1"},
|
||||
VolumeMounts: []api.VolumeMount{
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
{
|
||||
Name: "vol",
|
||||
MountPath: "/scrub",
|
||||
|
|
@ -563,3 +582,15 @@ func NewPersistentVolumeRecyclerPodTemplate() *api.Pod {
|
|||
}
|
||||
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
|
||||
}
|
||||
|
|
|
|||
161
vendor/k8s.io/kubernetes/pkg/volume/util.go
generated
vendored
161
vendor/k8s.io/kubernetes/pkg/volume/util.go
generated
vendored
|
|
@ -20,10 +20,11 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||
|
||||
"hash/fnv"
|
||||
"math/rand"
|
||||
|
|
@ -31,9 +32,11 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api/errors"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
volutil "k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
|
||||
type RecycleEventRecorder func(eventtype, message string)
|
||||
|
|
@ -51,13 +54,13 @@ type RecycleEventRecorder func(eventtype, message string)
|
|||
// 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 *api.Pod, kubeClient clientset.Interface, recorder RecycleEventRecorder) error {
|
||||
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 *api.Pod, recyclerClient recyclerClient) error {
|
||||
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
|
||||
|
|
@ -83,7 +86,7 @@ func internalRecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *api.P
|
|||
return fmt.Errorf("unexpected error creating recycler pod: %+v\n", err)
|
||||
}
|
||||
}
|
||||
defer func(pod *api.Pod) {
|
||||
defer func(pod *v1.Pod) {
|
||||
glog.V(2).Infof("deleting recycler pod %s/%s", pod.Namespace, pod.Name)
|
||||
if err := recyclerClient.DeletePod(pod.Name, pod.Namespace); err != nil {
|
||||
glog.Errorf("failed to delete recycler pod %s/%s: %v", pod.Namespace, pod.Name, err)
|
||||
|
|
@ -93,19 +96,22 @@ func internalRecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *api.P
|
|||
// Now only the old pod or the new pod run. Watch it until it finishes
|
||||
// and send all events on the pod to the PV
|
||||
for {
|
||||
event := <-podCh
|
||||
event, ok := <-podCh
|
||||
if !ok {
|
||||
return fmt.Errorf("recycler pod %q watch channel had been closed", pod.Name)
|
||||
}
|
||||
switch event.Object.(type) {
|
||||
case *api.Pod:
|
||||
case *v1.Pod:
|
||||
// POD changed
|
||||
pod := event.Object.(*api.Pod)
|
||||
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 == api.PodSucceeded {
|
||||
if pod.Status.Phase == v1.PodSucceeded {
|
||||
// Recycle succeeded.
|
||||
return nil
|
||||
}
|
||||
if pod.Status.Phase == api.PodFailed {
|
||||
if pod.Status.Phase == v1.PodFailed {
|
||||
if pod.Status.Message != "" {
|
||||
return fmt.Errorf(pod.Status.Message)
|
||||
} else {
|
||||
|
|
@ -120,9 +126,9 @@ func internalRecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *api.P
|
|||
return fmt.Errorf("recycler pod watcher failed")
|
||||
}
|
||||
|
||||
case *api.Event:
|
||||
case *v1.Event:
|
||||
// Event received
|
||||
podEvent := event.Object.(*api.Event)
|
||||
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)
|
||||
|
|
@ -134,8 +140,8 @@ func internalRecycleVolumeByWatchingPodUntilCompletion(pvName string, pod *api.P
|
|||
// 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 *api.Pod) (*api.Pod, error)
|
||||
GetPod(name, namespace string) (*api.Pod, error)
|
||||
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
|
||||
|
|
@ -157,12 +163,12 @@ type realRecyclerClient struct {
|
|||
recorder RecycleEventRecorder
|
||||
}
|
||||
|
||||
func (c *realRecyclerClient) CreatePod(pod *api.Pod) (*api.Pod, error) {
|
||||
func (c *realRecyclerClient) CreatePod(pod *v1.Pod) (*v1.Pod, error) {
|
||||
return c.client.Core().Pods(pod.Namespace).Create(pod)
|
||||
}
|
||||
|
||||
func (c *realRecyclerClient) GetPod(name, namespace string) (*api.Pod, error) {
|
||||
return c.client.Core().Pods(namespace).Get(name)
|
||||
func (c *realRecyclerClient) GetPod(name, namespace string) (*v1.Pod, error) {
|
||||
return c.client.Core().Pods(namespace).Get(name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func (c *realRecyclerClient) DeletePod(name, namespace string) error {
|
||||
|
|
@ -175,8 +181,8 @@ func (c *realRecyclerClient) Event(eventtype, message string) {
|
|||
|
||||
func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan struct{}) (<-chan watch.Event, error) {
|
||||
podSelector, _ := fields.ParseSelector("metadata.name=" + name)
|
||||
options := api.ListOptions{
|
||||
FieldSelector: podSelector,
|
||||
options := metav1.ListOptions{
|
||||
FieldSelector: podSelector.String(),
|
||||
Watch: true,
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +192,8 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
|
|||
}
|
||||
|
||||
eventSelector, _ := fields.ParseSelector("involvedObject.name=" + name)
|
||||
eventWatch, err := c.client.Core().Events(namespace).Watch(api.ListOptions{
|
||||
FieldSelector: eventSelector,
|
||||
eventWatch, err := c.client.Core().Events(namespace).Watch(metav1.ListOptions{
|
||||
FieldSelector: eventSelector.String(),
|
||||
Watch: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -195,13 +201,14 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
|
|||
return nil, err
|
||||
}
|
||||
|
||||
eventCh := make(chan watch.Event, 0)
|
||||
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:
|
||||
|
|
@ -209,15 +216,19 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
|
|||
|
||||
case podEvent, ok := <-podWatch.ResultChan():
|
||||
if !ok {
|
||||
return
|
||||
podWatchChannelClosed = true
|
||||
} else {
|
||||
eventCh <- podEvent
|
||||
}
|
||||
eventCh <- podEvent
|
||||
|
||||
case eventEvent, ok := <-eventWatch.ResultChan():
|
||||
if !ok {
|
||||
return
|
||||
eventWatchChannelClosed = true
|
||||
} else {
|
||||
eventCh <- eventEvent
|
||||
}
|
||||
eventCh <- eventEvent
|
||||
}
|
||||
if podWatchChannelClosed && eventWatchChannelClosed {
|
||||
break
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
@ -229,9 +240,9 @@ func (c *realRecyclerClient) WatchPod(name, namespace string, stopChannel chan s
|
|||
// recycle operation. The calculation and return value is either the
|
||||
// minimumTimeout or the timeoutIncrement per Gi of storage size, whichever is
|
||||
// greater.
|
||||
func CalculateTimeoutForVolume(minimumTimeout, timeoutIncrement int, pv *api.PersistentVolume) int64 {
|
||||
func CalculateTimeoutForVolume(minimumTimeout, timeoutIncrement int, pv *v1.PersistentVolume) int64 {
|
||||
giQty := resource.MustParse("1Gi")
|
||||
pvQty := pv.Spec.Capacity[api.ResourceStorage]
|
||||
pvQty := pv.Spec.Capacity[v1.ResourceStorage]
|
||||
giSize := giQty.Value()
|
||||
pvSize := pvQty.Value()
|
||||
timeout := (pvSize / giSize) * int64(timeoutIncrement)
|
||||
|
|
@ -297,16 +308,34 @@ func ChooseZoneForVolume(zones sets.String, pvcName string) string {
|
|||
|
||||
// Heuristic to make sure that volumes in a StatefulSet are spread across zones
|
||||
// StatefulSet PVCs are (currently) named ClaimName-StatefulSetName-Id,
|
||||
// where Id is an integer index
|
||||
// where Id is an integer index.
|
||||
// Note though that if a StatefulSet pod has multiple claims, we need them to be
|
||||
// in the same zone, because otherwise the pod will be unable to mount both volumes,
|
||||
// and will be unschedulable. So we hash _only_ the "StatefulSetName" portion when
|
||||
// it looks like `ClaimName-StatefulSetName-Id`.
|
||||
// We continue to round-robin volume names that look like `Name-Id` also; this is a useful
|
||||
// feature for users that are creating statefulset-like functionality without using statefulsets.
|
||||
lastDash := strings.LastIndexByte(pvcName, '-')
|
||||
if lastDash != -1 {
|
||||
petIDString := pvcName[lastDash+1:]
|
||||
petID, err := strconv.ParseUint(petIDString, 10, 32)
|
||||
statefulsetIDString := pvcName[lastDash+1:]
|
||||
statefulsetID, err := strconv.ParseUint(statefulsetIDString, 10, 32)
|
||||
if err == nil {
|
||||
// Offset by the pet id, so we round-robin across zones
|
||||
index = uint32(petID)
|
||||
// We still hash the volume name, but only the base
|
||||
// Offset by the statefulsetID, so we round-robin across zones
|
||||
index = uint32(statefulsetID)
|
||||
// We still hash the volume name, but only the prefix
|
||||
hashString = pvcName[:lastDash]
|
||||
|
||||
// In the special case where it looks like `ClaimName-StatefulSetName-Id`,
|
||||
// hash only the StatefulSetName, so that different claims on the same StatefulSet
|
||||
// member end up in the same zone.
|
||||
// Note that StatefulSetName (and ClaimName) might themselves both have dashes.
|
||||
// We actually just take the portion after the final - of ClaimName-StatefulSetName.
|
||||
// For our purposes it doesn't much matter (just suboptimal spreading).
|
||||
lastDash := strings.LastIndexByte(hashString, '-')
|
||||
if lastDash != -1 {
|
||||
hashString = hashString[lastDash+1:]
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Detected StatefulSet-style volume name %q; index=%d", pvcName, index)
|
||||
}
|
||||
}
|
||||
|
|
@ -331,3 +360,53 @@ func ChooseZoneForVolume(zones sets.String, pvcName string) string {
|
|||
glog.V(2).Infof("Creating volume for PVC %q; chose zone=%q from zones=%q", pvcName, zone, zoneSlice)
|
||||
return zone
|
||||
}
|
||||
|
||||
// UnmountViaEmptyDir delegates the tear down operation for secret, configmap, git_repo and downwardapi
|
||||
// to empty_dir
|
||||
func UnmountViaEmptyDir(dir string, host VolumeHost, volName string, volSpec Spec, podUID types.UID) error {
|
||||
glog.V(3).Infof("Tearing down volume %v for pod %v at %v", volName, podUID, dir)
|
||||
|
||||
if pathExists, pathErr := volutil.PathExists(dir); pathErr != nil {
|
||||
return fmt.Errorf("Error checking if path exists: %v", pathErr)
|
||||
} else if !pathExists {
|
||||
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Wrap EmptyDir, let it do the teardown.
|
||||
wrapped, err := host.NewWrapperUnmounter(volName, volSpec, podUID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return wrapped.TearDownAt(dir)
|
||||
}
|
||||
|
||||
// MountOptionFromSpec extracts and joins mount options from volume spec with supplied options
|
||||
func MountOptionFromSpec(spec *Spec, options ...string) []string {
|
||||
pv := spec.PersistentVolume
|
||||
|
||||
if pv != nil {
|
||||
if mo, ok := pv.Annotations[MountOptionAnnotation]; ok {
|
||||
moList := strings.Split(mo, ",")
|
||||
return JoinMountOptions(moList, options)
|
||||
}
|
||||
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
// JoinMountOptions joins mount options eliminating duplicates
|
||||
func JoinMountOptions(userOptions []string, systemOptions []string) []string {
|
||||
allMountOptions := sets.NewString()
|
||||
|
||||
for _, mountOption := range userOptions {
|
||||
if len(mountOption) > 0 {
|
||||
allMountOptions.Insert(mountOption)
|
||||
}
|
||||
}
|
||||
|
||||
for _, mountOption := range systemOptions {
|
||||
allMountOptions.Insert(mountOption)
|
||||
}
|
||||
return allMountOptions.UnsortedList()
|
||||
}
|
||||
|
|
|
|||
38
vendor/k8s.io/kubernetes/pkg/volume/util/BUILD
generated
vendored
38
vendor/k8s.io/kubernetes/pkg/volume/util/BUILD
generated
vendored
|
|
@ -4,10 +4,8 @@ licenses(["notice"])
|
|||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
"go_test",
|
||||
"cgo_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
|
@ -23,13 +21,14 @@ go_library(
|
|||
],
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/resource:go_default_library",
|
||||
"//pkg/apis/storage:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset:go_default_library",
|
||||
"//pkg/api/v1:go_default_library",
|
||||
"//pkg/apis/storage/v1beta1:go_default_library",
|
||||
"//pkg/client/clientset_generated/clientset:go_default_library",
|
||||
"//pkg/util/mount:go_default_library",
|
||||
"//pkg/util/sets:go_default_library",
|
||||
"//vendor:github.com/golang/glog",
|
||||
"//vendor:k8s.io/apimachinery/pkg/api/resource",
|
||||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
@ -39,10 +38,29 @@ go_test(
|
|||
"atomic_writer_test.go",
|
||||
"device_util_linux_test.go",
|
||||
],
|
||||
library = "go_default_library",
|
||||
library = ":go_default_library",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//pkg/util/sets:go_default_library",
|
||||
"//pkg/util/testing:go_default_library",
|
||||
"//vendor:k8s.io/apimachinery/pkg/util/sets",
|
||||
"//vendor:k8s.io/client-go/util/testing",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/volume/util/nestedpendingoperations:all-srcs",
|
||||
"//pkg/volume/util/operationexecutor:all-srcs",
|
||||
"//pkg/volume/util/types:all-srcs",
|
||||
"//pkg/volume/util/volumehelper:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
|
|
|||
11
vendor/k8s.io/kubernetes/pkg/volume/util/OWNERS
generated
vendored
Executable file
11
vendor/k8s.io/kubernetes/pkg/volume/util/OWNERS
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
approvers:
|
||||
- saad-ali
|
||||
reviewers:
|
||||
- thockin
|
||||
- smarterclayton
|
||||
- pmorie
|
||||
- saad-ali
|
||||
- justinsb
|
||||
- rootfs
|
||||
- jingxu97
|
||||
- screeley44
|
||||
2
vendor/k8s.io/kubernetes/pkg/volume/util/atomic_writer.go
generated
vendored
2
vendor/k8s.io/kubernetes/pkg/volume/util/atomic_writer.go
generated
vendored
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
49
vendor/k8s.io/kubernetes/pkg/volume/util/fs.go
generated
vendored
49
vendor/k8s.io/kubernetes/pkg/volume/util/fs.go
generated
vendored
|
|
@ -22,11 +22,10 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// FSInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
|
||||
|
|
@ -69,35 +68,29 @@ func Du(path string) (*resource.Quantity, error) {
|
|||
return &used, nil
|
||||
}
|
||||
|
||||
// Find uses the command `find <path> -dev -printf '.' | wc -c` to count files and directories.
|
||||
// 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) {
|
||||
var stdout, stdwcerr, stdfinderr bytes.Buffer
|
||||
var err error
|
||||
if path == "" {
|
||||
return 0, fmt.Errorf("invalid directory")
|
||||
}
|
||||
var counter byteCounter
|
||||
var stderr bytes.Buffer
|
||||
findCmd := exec.Command("find", path, "-xdev", "-printf", ".")
|
||||
wcCmd := exec.Command("wc", "-c")
|
||||
if wcCmd.Stdin, err = findCmd.StdoutPipe(); err != nil {
|
||||
return 0, fmt.Errorf("failed to setup stdout for cmd %v - %v", findCmd.Args, err)
|
||||
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())
|
||||
}
|
||||
wcCmd.Stdout, wcCmd.Stderr, findCmd.Stderr = &stdout, &stdwcerr, &stdfinderr
|
||||
if err = findCmd.Start(); err != nil {
|
||||
return 0, fmt.Errorf("failed to exec cmd %v - %v; stderr: %v", findCmd.Args, err, stdfinderr.String())
|
||||
if err := findCmd.Wait(); err != nil {
|
||||
return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stderr.String(), err)
|
||||
}
|
||||
|
||||
if err = wcCmd.Start(); err != nil {
|
||||
return 0, fmt.Errorf("failed to exec cmd %v - %v; stderr %v", wcCmd.Args, err, stdwcerr.String())
|
||||
}
|
||||
err = findCmd.Wait()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stdfinderr.String(), err)
|
||||
}
|
||||
err = wcCmd.Wait()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", wcCmd.Args, stdwcerr.String(), err)
|
||||
}
|
||||
inodeUsage, err := strconv.ParseInt(strings.TrimSpace(stdout.String()), 10, 64)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot parse cmds: %v, %v output %s - %s", findCmd.Args, wcCmd.Args, stdout.String(), err)
|
||||
}
|
||||
return inodeUsage, nil
|
||||
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
|
||||
}
|
||||
|
|
|
|||
2
vendor/k8s.io/kubernetes/pkg/volume/util/fs_unsupported.go
generated
vendored
2
vendor/k8s.io/kubernetes/pkg/volume/util/fs_unsupported.go
generated
vendored
|
|
@ -21,7 +21,7 @@ package util
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// FSInfo unsupported returns 0 values for available and capacity and an error.
|
||||
|
|
|
|||
24
vendor/k8s.io/kubernetes/pkg/volume/util/util.go
generated
vendored
24
vendor/k8s.io/kubernetes/pkg/volume/util/util.go
generated
vendored
|
|
@ -22,9 +22,10 @@ import (
|
|||
"path"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/storage"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
)
|
||||
|
||||
|
|
@ -97,7 +98,7 @@ func UnmountPath(mountPath string, mounter mount.Interface) error {
|
|||
glog.V(4).Infof("%q is unmounted, deleting the directory", mountPath)
|
||||
return os.Remove(mountPath)
|
||||
}
|
||||
return nil
|
||||
return fmt.Errorf("Failed to unmount path %v", mountPath)
|
||||
}
|
||||
|
||||
// PathExists returns true if the specified path exists.
|
||||
|
|
@ -113,12 +114,12 @@ func PathExists(path string) (bool, error) {
|
|||
}
|
||||
|
||||
// GetSecretForPod locates secret by name in the pod's namespace and returns secret map
|
||||
func GetSecretForPod(pod *api.Pod, secretName string, kubeClient clientset.Interface) (map[string]string, error) {
|
||||
func GetSecretForPod(pod *v1.Pod, secretName string, kubeClient clientset.Interface) (map[string]string, error) {
|
||||
secret := make(map[string]string)
|
||||
if kubeClient == nil {
|
||||
return secret, fmt.Errorf("Cannot get kube client")
|
||||
}
|
||||
secrets, err := kubeClient.Core().Secrets(pod.Namespace).Get(secretName)
|
||||
secrets, err := kubeClient.Core().Secrets(pod.Namespace).Get(secretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return secret, err
|
||||
}
|
||||
|
|
@ -134,11 +135,11 @@ func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeCl
|
|||
if kubeClient == nil {
|
||||
return secret, fmt.Errorf("Cannot get kube client")
|
||||
}
|
||||
secrets, err := kubeClient.Core().Secrets(secretNamespace).Get(secretName)
|
||||
secrets, err := kubeClient.Core().Secrets(secretNamespace).Get(secretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return secret, err
|
||||
}
|
||||
if secrets.Type != api.SecretType(volumePluginName) {
|
||||
if secrets.Type != v1.SecretType(volumePluginName) {
|
||||
return secret, fmt.Errorf("Cannot get secret of type %s", volumePluginName)
|
||||
}
|
||||
for name, data := range secrets.Data {
|
||||
|
|
@ -147,14 +148,17 @@ func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeCl
|
|||
return secret, nil
|
||||
}
|
||||
|
||||
func GetClassForVolume(kubeClient clientset.Interface, pv *api.PersistentVolume) (*storage.StorageClass, error) {
|
||||
func GetClassForVolume(kubeClient clientset.Interface, pv *v1.PersistentVolume) (*storage.StorageClass, error) {
|
||||
if kubeClient == nil {
|
||||
return nil, fmt.Errorf("Cannot get kube client")
|
||||
}
|
||||
// TODO: replace with a real attribute after beta
|
||||
className, found := pv.Annotations["volume.beta.kubernetes.io/storage-class"]
|
||||
if !found {
|
||||
return nil, fmt.Errorf("Volume has no class annotation")
|
||||
}
|
||||
|
||||
class, err := kubeClient.Storage().StorageClasses().Get(className)
|
||||
class, err := kubeClient.StorageV1beta1().StorageClasses().Get(className, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
63
vendor/k8s.io/kubernetes/pkg/volume/volume.go
generated
vendored
63
vendor/k8s.io/kubernetes/pkg/volume/volume.go
generated
vendored
|
|
@ -25,9 +25,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
)
|
||||
|
||||
// Volume represents a directory used by pods or hosts on a node. All method
|
||||
|
|
@ -52,6 +53,9 @@ type MetricsProvider interface {
|
|||
|
||||
// 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
|
||||
|
|
@ -71,15 +75,15 @@ type Metrics struct {
|
|||
// InodesUsed represents the total inodes used by the Volume.
|
||||
InodesUsed *resource.Quantity
|
||||
|
||||
// Inodes represents the total number of inodes availible in the volume.
|
||||
// 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 Volues that share
|
||||
// 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 sporage, and is shared with host processes and other volumes
|
||||
// on the underlying storage, and is shared with host processes and other volumes
|
||||
InodesFree *resource.Quantity
|
||||
}
|
||||
|
||||
|
|
@ -134,22 +138,13 @@ type Unmounter interface {
|
|||
TearDownAt(dir string) error
|
||||
}
|
||||
|
||||
// Recycler provides methods to reclaim the volume resource.
|
||||
type Recycler interface {
|
||||
Volume
|
||||
// Recycle reclaims the resource. Calls to this method should block until
|
||||
// the recycling task is complete. Any error returned indicates the volume
|
||||
// has failed to be reclaimed. A nil return indicates success.
|
||||
Recycle() 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() (*api.PersistentVolume, error)
|
||||
Provision() (*v1.PersistentVolume, error)
|
||||
}
|
||||
|
||||
// Deleter removes the resource from the underlying storage provider. Calls
|
||||
|
|
@ -163,7 +158,7 @@ type Deleter interface {
|
|||
// 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
|
||||
// dettached from a node. Deletion of such volume would fail anyway and such
|
||||
// detached from a node. Deletion of such volume would fail anyway and such
|
||||
// error would confuse users.
|
||||
Delete() error
|
||||
}
|
||||
|
|
@ -176,8 +171,8 @@ type Attacher interface {
|
|||
Attach(spec *Spec, nodeName types.NodeName) (string, error)
|
||||
|
||||
// VolumesAreAttached checks whether the list of volumes still attached to the specified
|
||||
// the node. It returns a map which maps from the volume spec to the checking result.
|
||||
// If an error is occured during checking, the error will be returned
|
||||
// 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
|
||||
|
|
@ -196,6 +191,14 @@ type Attacher interface {
|
|||
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 device from the node with the given Name.
|
||||
|
|
@ -280,16 +283,16 @@ func copyFolder(source string, dest string) (err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
sourcefilepointer := source + "\\" + obj.Name()
|
||||
destinationfilepointer := dest + "\\" + obj.Name()
|
||||
sourceFilePointer := source + "\\" + obj.Name()
|
||||
destinationFilePointer := dest + "\\" + obj.Name()
|
||||
|
||||
if obj.IsDir() {
|
||||
err = copyFolder(sourcefilepointer, destinationfilepointer)
|
||||
err = copyFolder(sourceFilePointer, destinationFilePointer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = copyFile(sourcefilepointer, destinationfilepointer)
|
||||
err = copyFile(sourceFilePointer, destinationFilePointer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -300,25 +303,25 @@ func copyFolder(source string, dest string) (err error) {
|
|||
}
|
||||
|
||||
func copyFile(source string, dest string) (err error) {
|
||||
sourcefile, err := os.Open(source)
|
||||
sourceFile, err := os.Open(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer sourcefile.Close()
|
||||
defer sourceFile.Close()
|
||||
|
||||
destfile, err := os.Create(dest)
|
||||
destFile, err := os.Create(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer destfile.Close()
|
||||
defer destFile.Close()
|
||||
|
||||
_, err = io.Copy(destfile, sourcefile)
|
||||
_, err = io.Copy(destFile, sourceFile)
|
||||
if err == nil {
|
||||
sourceinfo, err := os.Stat(source)
|
||||
sourceInfo, err := os.Stat(source)
|
||||
if err != nil {
|
||||
err = os.Chmod(dest, sourceinfo.Mode())
|
||||
err = os.Chmod(dest, sourceInfo.Mode())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue