*: update kube vendor to v1.7.4
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
c67859731f
commit
d56bf090ce
1032 changed files with 273965 additions and 40081 deletions
17
vendor/k8s.io/kubernetes/pkg/volume/plugins.go
generated
vendored
17
vendor/k8s.io/kubernetes/pkg/volume/plugins.go
generated
vendored
|
@ -68,9 +68,10 @@ type VolumePlugin interface {
|
|||
// depend on this.
|
||||
Init(host VolumeHost) error
|
||||
|
||||
// Name returns the plugin's name. Plugins should use namespaced names
|
||||
// such as "example.com/volume". The "kubernetes.io" namespace is
|
||||
// reserved for plugins which are bundled with kubernetes.
|
||||
// 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
|
||||
|
@ -156,8 +157,6 @@ 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
|
||||
|
@ -233,12 +232,19 @@ type VolumeHost interface {
|
|||
|
||||
// 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 the labels on the node
|
||||
GetNodeLabels() (map[string]string, error)
|
||||
}
|
||||
|
||||
// VolumePluginMgr tracks registered plugins.
|
||||
type VolumePluginMgr struct {
|
||||
mutex sync.Mutex
|
||||
plugins map[string]VolumePlugin
|
||||
Host VolumeHost
|
||||
}
|
||||
|
||||
// Spec is an internal representation of a volume. All API volume types translate to Spec.
|
||||
|
@ -337,6 +343,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, host VolumeHost)
|
|||
pm.mutex.Lock()
|
||||
defer pm.mutex.Unlock()
|
||||
|
||||
pm.Host = host
|
||||
if pm.plugins == nil {
|
||||
pm.plugins = map[string]VolumePlugin{}
|
||||
}
|
||||
|
|
46
vendor/k8s.io/kubernetes/pkg/volume/util.go
generated
vendored
46
vendor/k8s.io/kubernetes/pkg/volume/util.go
generated
vendored
|
@ -386,7 +386,7 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
|
|||
pv := spec.PersistentVolume
|
||||
|
||||
if pv != nil {
|
||||
if mo, ok := pv.Annotations[MountOptionAnnotation]; ok {
|
||||
if mo, ok := pv.Annotations[v1.MountOptionAnnotation]; ok {
|
||||
moList := strings.Split(mo, ",")
|
||||
return JoinMountOptions(moList, options)
|
||||
}
|
||||
|
@ -410,3 +410,47 @@ func JoinMountOptions(userOptions []string, systemOptions []string) []string {
|
|||
}
|
||||
return allMountOptions.UnsortedList()
|
||||
}
|
||||
|
||||
// ZonesToSet converts a string containing a comma separated list of zones to set
|
||||
func ZonesToSet(zonesString string) (sets.String, error) {
|
||||
zonesSlice := strings.Split(zonesString, ",")
|
||||
zonesSet := make(sets.String)
|
||||
for _, zone := range zonesSlice {
|
||||
trimmedZone := strings.TrimSpace(zone)
|
||||
if trimmedZone == "" {
|
||||
return make(sets.String), fmt.Errorf("comma separated list of zones (%q) must not contain an empty zone", zonesString)
|
||||
}
|
||||
zonesSet.Insert(trimmedZone)
|
||||
}
|
||||
return zonesSet, nil
|
||||
}
|
||||
|
||||
// ValidateZone returns:
|
||||
// - an error in case zone is an empty string or contains only any combination of spaces and tab characters
|
||||
// - nil otherwise
|
||||
func ValidateZone(zone string) error {
|
||||
if strings.TrimSpace(zone) == "" {
|
||||
return fmt.Errorf("the provided %q zone is not valid, it's an empty string or contains only spaces and tab characters", zone)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccessModesContains returns whether the requested mode is contained by modes
|
||||
func AccessModesContains(modes []v1.PersistentVolumeAccessMode, mode v1.PersistentVolumeAccessMode) bool {
|
||||
for _, m := range modes {
|
||||
if m == mode {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AccessModesContainedInAll returns whether all of the requested modes are contained by modes
|
||||
func AccessModesContainedInAll(indexedModes []v1.PersistentVolumeAccessMode, requestedModes []v1.PersistentVolumeAccessMode) bool {
|
||||
for _, mode := range requestedModes {
|
||||
if !AccessModesContains(indexedModes, mode) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
56
vendor/k8s.io/kubernetes/pkg/volume/util/util.go
generated
vendored
56
vendor/k8s.io/kubernetes/pkg/volume/util/util.go
generated
vendored
|
@ -23,8 +23,10 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
|
||||
v1helper "k8s.io/kubernetes/pkg/api/v1/helper"
|
||||
storage "k8s.io/kubernetes/pkg/apis/storage/v1"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
)
|
||||
|
@ -70,6 +72,15 @@ func SetReady(dir string) {
|
|||
// UnmountPath is a common unmount routine that unmounts the given path and
|
||||
// deletes the remaining directory if successful.
|
||||
func UnmountPath(mountPath string, mounter mount.Interface) error {
|
||||
return UnmountMountPoint(mountPath, mounter, false /* extensiveMountPointCheck */)
|
||||
}
|
||||
|
||||
// UnmountMountPoint is a common unmount routine that unmounts the given path and
|
||||
// deletes the remaining directory if successful.
|
||||
// if extensiveMountPointCheck is true
|
||||
// IsNotMountPoint will be called instead of IsLikelyNotMountPoint.
|
||||
// IsNotMountPoint is more expensive but properly handles bind mounts.
|
||||
func UnmountMountPoint(mountPath string, mounter mount.Interface, extensiveMountPointCheck bool) error {
|
||||
if pathExists, pathErr := PathExists(mountPath); pathErr != nil {
|
||||
return fmt.Errorf("Error checking if path exists: %v", pathErr)
|
||||
} else if !pathExists {
|
||||
|
@ -77,16 +88,26 @@ func UnmountPath(mountPath string, mounter mount.Interface) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
notMnt, err := mounter.IsLikelyNotMountPoint(mountPath)
|
||||
var notMnt bool
|
||||
var err error
|
||||
|
||||
if extensiveMountPointCheck {
|
||||
notMnt, err = mount.IsNotMountPoint(mounter, mountPath)
|
||||
} else {
|
||||
notMnt, err = mounter.IsLikelyNotMountPoint(mountPath)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if notMnt {
|
||||
glog.Warningf("Warning: %q is not a mountpoint, deleting", mountPath)
|
||||
return os.Remove(mountPath)
|
||||
}
|
||||
|
||||
// Unmount the mount path
|
||||
glog.V(4).Infof("%q is a mountpoint, unmounting", mountPath)
|
||||
if err := mounter.Unmount(mountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -152,14 +173,41 @@ func GetClassForVolume(kubeClient clientset.Interface, pv *v1.PersistentVolume)
|
|||
if kubeClient == nil {
|
||||
return nil, fmt.Errorf("Cannot get kube client")
|
||||
}
|
||||
className := v1.GetPersistentVolumeClass(pv)
|
||||
className := v1helper.GetPersistentVolumeClass(pv)
|
||||
if className == "" {
|
||||
return nil, fmt.Errorf("Volume has no storage class")
|
||||
}
|
||||
|
||||
class, err := kubeClient.StorageV1beta1().StorageClasses().Get(className, metav1.GetOptions{})
|
||||
class, err := kubeClient.StorageV1().StorageClasses().Get(className, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return class, nil
|
||||
}
|
||||
|
||||
// CheckNodeAffinity looks at the PV node affinity, and checks if the node has the same corresponding labels
|
||||
// This ensures that we don't mount a volume that doesn't belong to this node
|
||||
func CheckNodeAffinity(pv *v1.PersistentVolume, nodeLabels map[string]string) error {
|
||||
affinity, err := v1helper.GetStorageNodeAffinityFromAnnotation(pv.Annotations)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting storage node affinity: %v", err)
|
||||
}
|
||||
if affinity == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if affinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
|
||||
terms := affinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms
|
||||
glog.V(10).Infof("Match for RequiredDuringSchedulingIgnoredDuringExecution node selector terms %+v", terms)
|
||||
for _, term := range terms {
|
||||
selector, err := v1helper.NodeSelectorRequirementsAsSelector(term.MatchExpressions)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to parse MatchExpressions: %v", err)
|
||||
}
|
||||
if !selector.Matches(labels.Set(nodeLabels)) {
|
||||
return fmt.Errorf("NodeSelectorTerm %+v does not match node labels", term.MatchExpressions)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
99
vendor/k8s.io/kubernetes/pkg/volume/volume.go
generated
vendored
99
vendor/k8s.io/kubernetes/pkg/volume/volume.go
generated
vendored
|
@ -17,14 +17,8 @@ limitations under the License.
|
|||
package volume
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
filepath "path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
@ -234,96 +228,3 @@ func IsDeletedVolumeInUse(err error) bool {
|
|||
func (err deletedVolumeInUseError) Error() string {
|
||||
return string(err)
|
||||
}
|
||||
|
||||
func RenameDirectory(oldPath, newName string) (string, error) {
|
||||
newPath, err := ioutil.TempDir(filepath.Dir(oldPath), newName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// os.Rename call fails on windows (https://github.com/golang/go/issues/14527)
|
||||
// Replacing with copyFolder to the newPath and deleting the oldPath directory
|
||||
if runtime.GOOS == "windows" {
|
||||
err = copyFolder(oldPath, newPath)
|
||||
if err != nil {
|
||||
glog.Errorf("Error copying folder from: %s to: %s with error: %v", oldPath, newPath, err)
|
||||
return "", err
|
||||
}
|
||||
os.RemoveAll(oldPath)
|
||||
return newPath, nil
|
||||
}
|
||||
|
||||
err = os.Rename(oldPath, newPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return newPath, nil
|
||||
}
|
||||
|
||||
func copyFolder(source string, dest string) (err error) {
|
||||
fi, err := os.Lstat(source)
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting stats for %s. %v", source, err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(dest, fi.Mode())
|
||||
if err != nil {
|
||||
glog.Errorf("Unable to create %s directory %v", dest, err)
|
||||
}
|
||||
|
||||
directory, _ := os.Open(source)
|
||||
|
||||
defer directory.Close()
|
||||
|
||||
objects, err := directory.Readdir(-1)
|
||||
|
||||
for _, obj := range objects {
|
||||
if obj.Mode()&os.ModeSymlink != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
sourceFilePointer := source + "\\" + obj.Name()
|
||||
destinationFilePointer := dest + "\\" + obj.Name()
|
||||
|
||||
if obj.IsDir() {
|
||||
err = copyFolder(sourceFilePointer, destinationFilePointer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = copyFile(sourceFilePointer, destinationFilePointer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func copyFile(source string, dest string) (err error) {
|
||||
sourceFile, err := os.Open(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer sourceFile.Close()
|
||||
|
||||
destFile, err := os.Create(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer destFile.Close()
|
||||
|
||||
_, err = io.Copy(destFile, sourceFile)
|
||||
if err == nil {
|
||||
sourceInfo, err := os.Stat(source)
|
||||
if err != nil {
|
||||
err = os.Chmod(dest, sourceInfo.Mode())
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
9
vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go
generated
vendored
9
vendor/k8s.io/kubernetes/pkg/volume/volume_linux.go
generated
vendored
|
@ -22,9 +22,6 @@ import (
|
|||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/chmod"
|
||||
"k8s.io/kubernetes/pkg/util/chown"
|
||||
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
@ -44,8 +41,6 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
chownRunner := chown.New()
|
||||
chmodRunner := chmod.New()
|
||||
return filepath.Walk(mounter.GetPath(), func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -72,7 +67,7 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
err = chownRunner.Chown(path, int(stat.Uid), int(*fsGroup))
|
||||
err = os.Chown(path, int(stat.Uid), int(*fsGroup))
|
||||
if err != nil {
|
||||
glog.Errorf("Chown failed on %v: %v", path, err)
|
||||
}
|
||||
|
@ -86,7 +81,7 @@ func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error {
|
|||
mask |= os.ModeSetgid
|
||||
}
|
||||
|
||||
err = chmodRunner.Chmod(path, info.Mode()|mask)
|
||||
err = os.Chmod(path, info.Mode()|mask)
|
||||
if err != nil {
|
||||
glog.Errorf("Chmod failed on %v: %v", path, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue