mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
Fresh dep ensure
This commit is contained in:
20
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/BUILD
generated
vendored
20
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/BUILD
generated
vendored
@ -15,17 +15,17 @@ go_library(
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/volume/photon_pd",
|
||||
deps = [
|
||||
"//pkg/cloudprovider:go_default_library",
|
||||
"//pkg/cloudprovider/providers/photon:go_default_library",
|
||||
"//pkg/util/mount:go_default_library",
|
||||
"//pkg/util/strings:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/util:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@ -41,10 +41,10 @@ go_test(
|
||||
"//pkg/util/mount:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/testing:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/testing:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/util/testing:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
61
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/attacher.go
generated
vendored
61
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/attacher.go
generated
vendored
@ -25,9 +25,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
@ -40,12 +40,17 @@ type photonPersistentDiskAttacher struct {
|
||||
}
|
||||
|
||||
var _ volume.Attacher = &photonPersistentDiskAttacher{}
|
||||
|
||||
var _ volume.DeviceMounter = &photonPersistentDiskAttacher{}
|
||||
|
||||
var _ volume.AttachableVolumePlugin = &photonPersistentDiskPlugin{}
|
||||
|
||||
var _ volume.DeviceMountableVolumePlugin = &photonPersistentDiskPlugin{}
|
||||
|
||||
func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error) {
|
||||
photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: NewAttacher failed to get cloud provider")
|
||||
klog.Errorf("Photon Controller attacher: NewAttacher failed to get cloud provider")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -55,6 +60,10 @@ func (plugin *photonPersistentDiskPlugin) NewAttacher() (volume.Attacher, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (plugin *photonPersistentDiskPlugin) NewDeviceMounter() (volume.DeviceMounter, error) {
|
||||
return plugin.NewAttacher()
|
||||
}
|
||||
|
||||
// Attaches the volume specified by the given spec to the given host.
|
||||
// On success, returns the device path where the device was attached on the
|
||||
// node.
|
||||
@ -65,22 +74,22 @@ func (attacher *photonPersistentDiskAttacher) Attach(spec *volume.Spec, nodeName
|
||||
hostName := string(nodeName)
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: Attach failed to get volume source")
|
||||
klog.Errorf("Photon Controller attacher: Attach failed to get volume source")
|
||||
return "", err
|
||||
}
|
||||
attached, err := attacher.photonDisks.DiskIsAttached(context.TODO(), volumeSource.PdID, nodeName)
|
||||
|
||||
if err != nil {
|
||||
glog.Warningf("Photon Controller: couldn't check if disk is Attached for host %s, will try attach disk: %+v", hostName, err)
|
||||
klog.Warningf("Photon Controller: couldn't check if disk is Attached for host %s, will try attach disk: %+v", hostName, err)
|
||||
attached = false
|
||||
}
|
||||
|
||||
if !attached {
|
||||
glog.V(4).Infof("Photon Controller: Attach disk called for host %s", hostName)
|
||||
klog.V(4).Infof("Photon Controller: Attach disk called for host %s", hostName)
|
||||
|
||||
err = attacher.photonDisks.AttachDisk(context.TODO(), volumeSource.PdID, nodeName)
|
||||
if err != nil {
|
||||
glog.Errorf("Error attaching volume %q to node %q: %+v", volumeSource.PdID, nodeName, err)
|
||||
klog.Errorf("Error attaching volume %q to node %q: %+v", volumeSource.PdID, nodeName, err)
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
@ -96,7 +105,7 @@ func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume
|
||||
for _, spec := range specs {
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err)
|
||||
klog.Errorf("Error getting volume (%q) source : %v", spec.Name(), err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -106,7 +115,7 @@ func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume
|
||||
}
|
||||
attachedResult, err := attacher.photonDisks.DisksAreAttached(context.TODO(), pdIDList, nodeName)
|
||||
if err != nil {
|
||||
glog.Errorf(
|
||||
klog.Errorf(
|
||||
"Error checking if volumes (%v) are attached to current node (%q). err=%v",
|
||||
pdIDList, nodeName, err)
|
||||
return volumesAttachedCheck, err
|
||||
@ -116,7 +125,7 @@ func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume
|
||||
if !attached {
|
||||
spec := volumeSpecMap[pdID]
|
||||
volumesAttachedCheck[spec] = false
|
||||
glog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", pdID, spec.Name())
|
||||
klog.V(2).Infof("VolumesAreAttached: check volume %q (specName: %q) is no longer attached", pdID, spec.Name())
|
||||
}
|
||||
}
|
||||
return volumesAttachedCheck, nil
|
||||
@ -125,7 +134,7 @@ func (attacher *photonPersistentDiskAttacher) VolumesAreAttached(specs []*volume
|
||||
func (attacher *photonPersistentDiskAttacher) WaitForAttach(spec *volume.Spec, devicePath string, _ *v1.Pod, timeout time.Duration) (string, error) {
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: WaitForAttach failed to get volume source")
|
||||
klog.Errorf("Photon Controller attacher: WaitForAttach failed to get volume source")
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -145,14 +154,14 @@ func (attacher *photonPersistentDiskAttacher) WaitForAttach(spec *volume.Spec, d
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
glog.V(4).Infof("Checking PD %s is attached", volumeSource.PdID)
|
||||
klog.V(4).Infof("Checking PD %s is attached", volumeSource.PdID)
|
||||
checkPath, err := verifyDevicePath(devicePath)
|
||||
if err != nil {
|
||||
// Log error, if any, and continue checking periodically. See issue #11321
|
||||
glog.Warningf("Photon Controller attacher: WaitForAttach with devicePath %s Checking PD %s Error verify path", devicePath, volumeSource.PdID)
|
||||
klog.Warningf("Photon Controller attacher: WaitForAttach with devicePath %s Checking PD %s Error verify path", devicePath, volumeSource.PdID)
|
||||
} else if checkPath != "" {
|
||||
// A device path has successfully been created for the VMDK
|
||||
glog.V(4).Infof("Successfully found attached PD %s.", volumeSource.PdID)
|
||||
klog.V(4).Infof("Successfully found attached PD %s.", volumeSource.PdID)
|
||||
// map path with spec.Name()
|
||||
volName := spec.Name()
|
||||
realPath, _ := filepath.EvalSymlinks(devicePath)
|
||||
@ -171,7 +180,7 @@ func (attacher *photonPersistentDiskAttacher) WaitForAttach(spec *volume.Spec, d
|
||||
func (attacher *photonPersistentDiskAttacher) GetDeviceMountPath(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: GetDeviceMountPath failed to get volume source")
|
||||
klog.Errorf("Photon Controller attacher: GetDeviceMountPath failed to get volume source")
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -182,7 +191,7 @@ func (attacher *photonPersistentDiskAttacher) GetDeviceMountPath(spec *volume.Sp
|
||||
// by deviceMountPath; returns a list of paths.
|
||||
func (plugin *photonPersistentDiskPlugin) GetDeviceMountRefs(deviceMountPath string) ([]string, error) {
|
||||
mounter := plugin.host.GetMounter(plugin.GetPluginName())
|
||||
return mount.GetMountRefs(mounter, deviceMountPath)
|
||||
return mounter.GetMountRefs(deviceMountPath)
|
||||
}
|
||||
|
||||
// MountDevice mounts device to global mount point.
|
||||
@ -192,7 +201,7 @@ func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, dev
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(deviceMountPath, 0750); err != nil {
|
||||
glog.Errorf("Failed to create directory at %#v. err: %s", deviceMountPath, err)
|
||||
klog.Errorf("Failed to create directory at %#v. err: %s", deviceMountPath, err)
|
||||
return err
|
||||
}
|
||||
notMnt = true
|
||||
@ -203,7 +212,7 @@ func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, dev
|
||||
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: MountDevice failed to get volume source. err: %s", err)
|
||||
klog.Errorf("Photon Controller attacher: MountDevice failed to get volume source. err: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -217,7 +226,7 @@ func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, dev
|
||||
os.Remove(deviceMountPath)
|
||||
return err
|
||||
}
|
||||
glog.V(4).Infof("formatting spec %v devicePath %v deviceMountPath %v fs %v with options %+v", spec.Name(), devicePath, deviceMountPath, volumeSource.FSType, options)
|
||||
klog.V(4).Infof("formatting spec %v devicePath %v deviceMountPath %v fs %v with options %+v", spec.Name(), devicePath, deviceMountPath, volumeSource.FSType, options)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -229,10 +238,12 @@ type photonPersistentDiskDetacher struct {
|
||||
|
||||
var _ volume.Detacher = &photonPersistentDiskDetacher{}
|
||||
|
||||
var _ volume.DeviceUnmounter = &photonPersistentDiskDetacher{}
|
||||
|
||||
func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error) {
|
||||
photonCloud, err := getCloudProvider(plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller attacher: NewDetacher failed to get cloud provider. err: %s", err)
|
||||
klog.Errorf("Photon Controller attacher: NewDetacher failed to get cloud provider. err: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -242,6 +253,10 @@ func (plugin *photonPersistentDiskPlugin) NewDetacher() (volume.Detacher, error)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (plugin *photonPersistentDiskPlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) {
|
||||
return plugin.NewDetacher()
|
||||
}
|
||||
|
||||
// Detach the given device from the given host.
|
||||
func (detacher *photonPersistentDiskDetacher) Detach(volumeName string, nodeName types.NodeName) error {
|
||||
|
||||
@ -250,19 +265,19 @@ func (detacher *photonPersistentDiskDetacher) Detach(volumeName string, nodeName
|
||||
attached, err := detacher.photonDisks.DiskIsAttached(context.TODO(), pdID, nodeName)
|
||||
if err != nil {
|
||||
// Log error and continue with detach
|
||||
glog.Errorf(
|
||||
klog.Errorf(
|
||||
"Error checking if persistent disk (%q) is already attached to current node (%q). Will continue and try detach anyway. err=%v",
|
||||
pdID, hostName, err)
|
||||
}
|
||||
|
||||
if err == nil && !attached {
|
||||
// Volume is already detached from node.
|
||||
glog.V(4).Infof("detach operation was successful. persistent disk %q is already detached from node %q.", pdID, hostName)
|
||||
klog.V(4).Infof("detach operation was successful. persistent disk %q is already detached from node %q.", pdID, hostName)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := detacher.photonDisks.DetachDisk(context.TODO(), pdID, nodeName); err != nil {
|
||||
glog.Errorf("Error detaching volume %q: %v", pdID, err)
|
||||
klog.Errorf("Error detaching volume %q: %v", pdID, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -277,7 +292,7 @@ func (detacher *photonPersistentDiskDetacher) WaitForDetach(devicePath string, t
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
glog.V(4).Infof("Checking device %q is detached.", devicePath)
|
||||
klog.V(4).Infof("Checking device %q is detached.", devicePath)
|
||||
if pathExists, err := volumeutil.PathExists(devicePath); err != nil {
|
||||
return fmt.Errorf("Error checking if device path exists: %v", err)
|
||||
} else if !pathExists {
|
||||
|
8
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/attacher_test.go
generated
vendored
8
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/attacher_test.go
generated
vendored
@ -26,8 +26,8 @@ import (
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
func TestGetDeviceName_Volume(t *testing.T) {
|
||||
@ -254,7 +254,7 @@ func (testcase *testcase) AttachDisk(ctx context.Context, diskName string, nodeN
|
||||
return errors.New("Unexpected AttachDisk call: wrong nodeName")
|
||||
}
|
||||
|
||||
glog.V(4).Infof("AttachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret)
|
||||
klog.V(4).Infof("AttachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret)
|
||||
|
||||
return expected.ret
|
||||
}
|
||||
@ -279,7 +279,7 @@ func (testcase *testcase) DetachDisk(ctx context.Context, diskName string, nodeN
|
||||
return errors.New("Unexpected DetachDisk call: wrong nodeName")
|
||||
}
|
||||
|
||||
glog.V(4).Infof("DetachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret)
|
||||
klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret)
|
||||
|
||||
return expected.ret
|
||||
}
|
||||
@ -304,7 +304,7 @@ func (testcase *testcase) DiskIsAttached(ctx context.Context, diskName string, n
|
||||
return false, errors.New("Unexpected DiskIsAttached call: wrong nodeName")
|
||||
}
|
||||
|
||||
glog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", diskName, nodeName, expected.isAttached, expected.ret)
|
||||
klog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", diskName, nodeName, expected.isAttached, expected.ret)
|
||||
|
||||
return expected.isAttached, expected.ret
|
||||
}
|
||||
|
32
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_pd.go
generated
vendored
32
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_pd.go
generated
vendored
@ -21,11 +21,11 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"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"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
utilstrings "k8s.io/kubernetes/pkg/util/strings"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
@ -62,7 +62,7 @@ func (plugin *photonPersistentDiskPlugin) GetPluginName() string {
|
||||
func (plugin *photonPersistentDiskPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon volume plugin: GetVolumeName failed to get volume source")
|
||||
klog.Errorf("Photon volume plugin: GetVolumeName failed to get volume source")
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ func (plugin *photonPersistentDiskPlugin) NewUnmounter(volName string, podUID ty
|
||||
func (plugin *photonPersistentDiskPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Mounter, error) {
|
||||
vvol, _, err := getVolumeSource(spec)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon volume plugin: newMounterInternal failed to get volume source")
|
||||
klog.Errorf("Photon volume plugin: newMounterInternal failed to get volume source")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -114,7 +114,9 @@ func (plugin *photonPersistentDiskPlugin) newMounterInternal(spec *volume.Spec,
|
||||
plugin: plugin,
|
||||
},
|
||||
fsType: fsType,
|
||||
diskMounter: util.NewSafeFormatAndMountFromHost(plugin.GetPluginName(), plugin.host)}, nil
|
||||
diskMounter: util.NewSafeFormatAndMountFromHost(plugin.GetPluginName(), plugin.host),
|
||||
mountOption: util.MountOptionFromSpec(spec),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (plugin *photonPersistentDiskPlugin) newUnmounterInternal(volName string, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Unmounter, error) {
|
||||
@ -177,6 +179,7 @@ type photonPersistentDiskMounter struct {
|
||||
*photonPersistentDisk
|
||||
fsType string
|
||||
diskMounter *mount.SafeFormatAndMount
|
||||
mountOption []string
|
||||
}
|
||||
|
||||
func (b *photonPersistentDiskMounter) GetAttributes() volume.Attributes {
|
||||
@ -199,12 +202,12 @@ func (b *photonPersistentDiskMounter) SetUp(fsGroup *int64) error {
|
||||
|
||||
// SetUp attaches the disk and bind mounts to the volume path.
|
||||
func (b *photonPersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
|
||||
glog.V(4).Infof("Photon Persistent Disk setup %s to %s", b.pdID, dir)
|
||||
klog.V(4).Infof("Photon Persistent Disk setup %s to %s", b.pdID, dir)
|
||||
|
||||
// TODO: handle failed mounts here.
|
||||
notmnt, err := b.mounter.IsLikelyNotMountPoint(dir)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
glog.Errorf("cannot validate mount point: %s %v", dir, err)
|
||||
klog.Errorf("cannot validate mount point: %s %v", dir, err)
|
||||
return err
|
||||
}
|
||||
if !notmnt {
|
||||
@ -212,7 +215,7 @@ func (b *photonPersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(dir, 0750); err != nil {
|
||||
glog.Errorf("mkdir failed on disk %s (%v)", dir, err)
|
||||
klog.Errorf("mkdir failed on disk %s (%v)", dir, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -220,32 +223,33 @@ func (b *photonPersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error
|
||||
|
||||
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
|
||||
globalPDPath := makeGlobalPDPath(b.plugin.host, b.pdID)
|
||||
glog.V(4).Infof("attempting to mount %s", dir)
|
||||
klog.V(4).Infof("attempting to mount %s", dir)
|
||||
|
||||
err = b.mounter.Mount(globalPDPath, dir, "", options)
|
||||
mountOptions := util.JoinMountOptions(options, b.mountOption)
|
||||
err = b.mounter.Mount(globalPDPath, dir, "", mountOptions)
|
||||
if err != nil {
|
||||
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||
if mntErr != nil {
|
||||
glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||
klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||
return err
|
||||
}
|
||||
if !notmnt {
|
||||
if mntErr = b.mounter.Unmount(dir); mntErr != nil {
|
||||
glog.Errorf("Failed to unmount: %v", mntErr)
|
||||
klog.Errorf("Failed to unmount: %v", mntErr)
|
||||
return err
|
||||
}
|
||||
notmnt, mntErr := b.mounter.IsLikelyNotMountPoint(dir)
|
||||
if mntErr != nil {
|
||||
glog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||
klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr)
|
||||
return err
|
||||
}
|
||||
if !notmnt {
|
||||
glog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", b.GetPath())
|
||||
klog.Errorf("%s is still mounted, despite call to unmount(). Will try again next sync loop.", b.GetPath())
|
||||
return err
|
||||
}
|
||||
}
|
||||
os.Remove(dir)
|
||||
glog.Errorf("Mount of disk %s failed: %v", dir, err)
|
||||
klog.Errorf("Mount of disk %s failed: %v", dir, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
2
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_pd_test.go
generated
vendored
2
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_pd_test.go
generated
vendored
@ -159,7 +159,7 @@ func TestPlugin(t *testing.T) {
|
||||
|
||||
// Test Provisioner
|
||||
options := volume.VolumeOptions{
|
||||
PVC: volumetest.CreateTestPVC("10Gi", []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}),
|
||||
PVC: volumetest.CreateTestPVC("10Gi", []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}),
|
||||
PersistentVolumeReclaimPolicy: v1.PersistentVolumeReclaimDelete,
|
||||
}
|
||||
provisioner, err := plug.(*photonPersistentDiskPlugin).newProvisionerInternal(options, &fakePDManager{})
|
||||
|
36
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_util.go
generated
vendored
36
vendor/k8s.io/kubernetes/pkg/volume/photon_pd/photon_util.go
generated
vendored
@ -23,9 +23,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/photon"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
||||
@ -63,7 +63,7 @@ func scsiHostScan() {
|
||||
name := scsi_path + f.Name() + "/scan"
|
||||
data := []byte("- - -")
|
||||
ioutil.WriteFile(name, data, 0666)
|
||||
glog.Errorf("scsiHostScan scan for %s", name)
|
||||
klog.Errorf("scsiHostScan scan for %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ func verifyDevicePath(path string) (string, error) {
|
||||
return path, nil
|
||||
}
|
||||
|
||||
glog.V(4).Infof("verifyDevicePath: path not exists yet")
|
||||
klog.V(4).Infof("verifyDevicePath: path not exists yet")
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@ -83,14 +83,16 @@ func verifyDevicePath(path string) (string, error) {
|
||||
func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pdID string, capacityGB int, fstype string, err error) {
|
||||
cloud, err := getCloudProvider(p.plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller Util: CreateVolume failed to get cloud provider. Error [%v]", err)
|
||||
klog.Errorf("Photon Controller Util: CreateVolume failed to get cloud provider. Error [%v]", err)
|
||||
return "", 0, "", err
|
||||
}
|
||||
|
||||
capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
|
||||
volSizeBytes := capacity.Value()
|
||||
// PhotonController works with GB, convert to GB with rounding up
|
||||
volSizeGB := int(volumeutil.RoundUpSize(volSizeBytes, 1024*1024*1024))
|
||||
// PhotonController works with GiB, convert to GiB with rounding up
|
||||
volSizeGB, err := volumeutil.RoundUpToGiBInt(capacity)
|
||||
if err != nil {
|
||||
return "", 0, "", err
|
||||
}
|
||||
name := volumeutil.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 255)
|
||||
volumeOptions := &photon.VolumeOptions{
|
||||
CapacityGB: volSizeGB,
|
||||
@ -104,20 +106,20 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
|
||||
volumeOptions.Flavor = value
|
||||
case volume.VolumeParameterFSType:
|
||||
fstype = value
|
||||
glog.V(4).Infof("Photon Controller Util: Setting fstype to %s", fstype)
|
||||
klog.V(4).Infof("Photon Controller Util: Setting fstype to %s", fstype)
|
||||
default:
|
||||
glog.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName())
|
||||
klog.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName())
|
||||
return "", 0, "", fmt.Errorf("Photon Controller Util: invalid option %s for volume plugin %s.", parameter, p.plugin.GetPluginName())
|
||||
}
|
||||
}
|
||||
|
||||
pdID, err = cloud.CreateDisk(volumeOptions)
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller Util: failed to CreateDisk. Error [%v]", err)
|
||||
klog.Errorf("Photon Controller Util: failed to CreateDisk. Error [%v]", err)
|
||||
return "", 0, "", err
|
||||
}
|
||||
|
||||
glog.V(4).Infof("Successfully created Photon Controller persistent disk %s", name)
|
||||
klog.V(4).Infof("Successfully created Photon Controller persistent disk %s", name)
|
||||
return pdID, volSizeGB, "", nil
|
||||
}
|
||||
|
||||
@ -125,28 +127,28 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
|
||||
func (util *PhotonDiskUtil) DeleteVolume(pd *photonPersistentDiskDeleter) error {
|
||||
cloud, err := getCloudProvider(pd.plugin.host.GetCloudProvider())
|
||||
if err != nil {
|
||||
glog.Errorf("Photon Controller Util: DeleteVolume failed to get cloud provider. Error [%v]", err)
|
||||
klog.Errorf("Photon Controller Util: DeleteVolume failed to get cloud provider. Error [%v]", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err = cloud.DeleteDisk(pd.pdID); err != nil {
|
||||
glog.Errorf("Photon Controller Util: failed to DeleteDisk for pdID %s. Error [%v]", pd.pdID, err)
|
||||
klog.Errorf("Photon Controller Util: failed to DeleteDisk for pdID %s. Error [%v]", pd.pdID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
glog.V(4).Infof("Successfully deleted PhotonController persistent disk %s", pd.pdID)
|
||||
klog.V(4).Infof("Successfully deleted PhotonController persistent disk %s", pd.pdID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCloudProvider(cloud cloudprovider.Interface) (*photon.PCCloud, error) {
|
||||
if cloud == nil {
|
||||
glog.Errorf("Photon Controller Util: Cloud provider not initialized properly")
|
||||
klog.Errorf("Photon Controller Util: Cloud provider not initialized properly")
|
||||
return nil, fmt.Errorf("Photon Controller Util: Cloud provider not initialized properly")
|
||||
}
|
||||
|
||||
pcc := cloud.(*photon.PCCloud)
|
||||
if pcc == nil {
|
||||
glog.Errorf("Invalid cloud provider: expected Photon Controller")
|
||||
klog.Errorf("Invalid cloud provider: expected Photon Controller")
|
||||
return nil, fmt.Errorf("Invalid cloud provider: expected Photon Controller")
|
||||
}
|
||||
return pcc, nil
|
||||
|
Reference in New Issue
Block a user