Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f737ad62
Commit
f737ad62
authored
Feb 06, 2018
by
wackxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update import
parent
dad09c11
Hide whitespace changes
Inline
Side-by-side
Showing
93 changed files
with
318 additions
and
321 deletions
+318
-321
aws.go
pkg/cloudprovider/providers/aws/aws.go
+4
-4
gce_disks.go
pkg/cloudprovider/providers/gce/gce_disks.go
+1
-1
openstack_volumes.go
pkg/cloudprovider/providers/openstack/openstack_volumes.go
+1
-1
attach_detach_controller.go
...ontroller/volume/attachdetach/attach_detach_controller.go
+5
-5
actual_state_of_world.go
...roller/volume/attachdetach/cache/actual_state_of_world.go
+2
-2
desired_state_of_world.go
...oller/volume/attachdetach/cache/desired_state_of_world.go
+2
-2
desired_state_of_world_populator.go
...ttachdetach/populator/desired_state_of_world_populator.go
+3
-3
desired_state_of_world_populator_test.go
...detach/populator/desired_state_of_world_populator_test.go
+2
-2
testvolumespec.go
pkg/controller/volume/attachdetach/testing/testvolumespec.go
+2
-2
util.go
pkg/controller/volume/attachdetach/util/util.go
+4
-4
expand_controller.go
pkg/controller/volume/expand/expand_controller.go
+2
-2
framework_test.go
pkg/controller/volume/persistentvolume/framework_test.go
+2
-1
index.go
pkg/controller/volume/persistentvolume/index.go
+1
-2
index_test.go
pkg/controller/volume/persistentvolume/index_test.go
+3
-3
pv_controller.go
pkg/controller/volume/persistentvolume/pv_controller.go
+3
-3
pvc_protection_controller.go
...troller/volume/pvcprotection/pvc_protection_controller.go
+2
-3
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+7
-7
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+3
-3
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+5
-6
kubelet_test.go
pkg/kubelet/kubelet_test.go
+2
-2
kubelet_volumes_test.go
pkg/kubelet/kubelet_volumes_test.go
+8
-8
volume_host.go
pkg/kubelet/volume_host.go
+2
-1
actual_state_of_world.go
pkg/kubelet/volumemanager/cache/actual_state_of_world.go
+2
-2
actual_state_of_world_test.go
...kubelet/volumemanager/cache/actual_state_of_world_test.go
+10
-10
desired_state_of_world.go
pkg/kubelet/volumemanager/cache/desired_state_of_world.go
+3
-3
desired_state_of_world_test.go
...ubelet/volumemanager/cache/desired_state_of_world_test.go
+7
-7
desired_state_of_world_populator.go
...lumemanager/populator/desired_state_of_world_populator.go
+5
-5
desired_state_of_world_populator_test.go
...anager/populator/desired_state_of_world_populator_test.go
+3
-3
reconciler.go
pkg/kubelet/volumemanager/reconciler/reconciler.go
+3
-3
reconciler_test.go
pkg/kubelet/volumemanager/reconciler/reconciler_test.go
+9
-9
volume_manager.go
pkg/kubelet/volumemanager/volume_manager.go
+4
-4
volume_manager_test.go
pkg/kubelet/volumemanager/volume_manager_test.go
+2
-2
attacher.go
pkg/volume/aws_ebs/attacher.go
+2
-3
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+3
-4
aws_ebs_block.go
pkg/volume/aws_ebs/aws_ebs_block.go
+2
-2
aws_util.go
pkg/volume/aws_ebs/aws_util.go
+2
-2
attacher.go
pkg/volume/azure_dd/attacher.go
+4
-5
azure_mounter.go
pkg/volume/azure_dd/azure_mounter.go
+1
-1
azure_provision.go
pkg/volume/azure_dd/azure_provision.go
+4
-3
azure_file.go
pkg/volume/azure_file/azure_file.go
+5
-5
azure_provision.go
pkg/volume/azure_file/azure_provision.go
+5
-5
cephfs.go
pkg/volume/cephfs/cephfs.go
+2
-2
attacher.go
pkg/volume/cinder/attacher.go
+2
-3
cinder.go
pkg/volume/cinder/cinder.go
+3
-4
cinder_util.go
pkg/volume/cinder/cinder_util.go
+4
-3
configmap.go
pkg/volume/configmap/configmap.go
+1
-1
downwardapi.go
pkg/volume/downwardapi/downwardapi.go
+1
-1
attacher.go
pkg/volume/fc/attacher.go
+4
-5
fc.go
pkg/volume/fc/fc.go
+3
-3
fc_util.go
pkg/volume/fc/fc_util.go
+5
-4
plugin.go
pkg/volume/flexvolume/plugin.go
+2
-1
flocker_util.go
pkg/volume/flocker/flocker_util.go
+3
-2
flocker_volume.go
pkg/volume/flocker/flocker_volume.go
+3
-3
attacher.go
pkg/volume/gce_pd/attacher.go
+2
-3
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+2
-3
gce_pd_block.go
pkg/volume/gce_pd/gce_pd_block.go
+2
-2
gce_pd_test.go
pkg/volume/gce_pd/gce_pd_test.go
+2
-1
gce_util.go
pkg/volume/gce_pd/gce_util.go
+5
-5
git_repo.go
pkg/volume/git_repo/git_repo.go
+1
-1
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+15
-15
host_path.go
pkg/volume/host_path/host_path.go
+6
-5
attacher.go
pkg/volume/iscsi/attacher.go
+2
-3
disk_manager.go
pkg/volume/iscsi/disk_manager.go
+2
-1
iscsi.go
pkg/volume/iscsi/iscsi.go
+3
-2
iscsi_util.go
pkg/volume/iscsi/iscsi_util.go
+5
-4
metrics_du.go
pkg/volume/metrics_du.go
+4
-4
metrics_statfs.go
pkg/volume/metrics_statfs.go
+2
-2
nfs.go
pkg/volume/nfs/nfs.go
+6
-5
attacher.go
pkg/volume/photon_pd/attacher.go
+2
-3
photon_pd.go
pkg/volume/photon_pd/photon_pd.go
+3
-4
photon_util.go
pkg/volume/photon_pd/photon_util.go
+2
-2
plugins.go
pkg/volume/plugins.go
+2
-1
portworx.go
pkg/volume/portworx/portworx.go
+4
-4
portworx_util.go
pkg/volume/portworx/portworx_util.go
+2
-1
quobyte.go
pkg/volume/quobyte/quobyte.go
+4
-5
quobyte_util.go
pkg/volume/quobyte/quobyte_util.go
+2
-2
attacher.go
pkg/volume/rbd/attacher.go
+3
-4
disk_manager.go
pkg/volume/rbd/disk_manager.go
+2
-1
rbd.go
pkg/volume/rbd/rbd.go
+9
-9
rbd_util.go
pkg/volume/rbd/rbd_util.go
+2
-2
sio_volume.go
pkg/volume/scaleio/sio_volume.go
+5
-6
secret.go
pkg/volume/secret/secret.go
+1
-1
storageos.go
pkg/volume/storageos/storageos.go
+5
-6
testing.go
pkg/volume/testing/testing.go
+6
-5
operation_executor.go
pkg/volume/util/operationexecutor/operation_executor.go
+7
-7
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+5
-5
volume_path_handler.go
pkg/volume/util/volumepathhandler/volume_path_handler.go
+1
-1
attacher.go
pkg/volume/vsphere_volume/attacher.go
+2
-3
vsphere_volume.go
pkg/volume/vsphere_volume/vsphere_volume.go
+3
-4
vsphere_volume_util.go
pkg/volume/vsphere_volume/vsphere_volume_util.go
+2
-2
pv_util.go
test/e2e/framework/pv_util.go
+2
-2
vsphere_utils.go
test/e2e/storage/vsphere/vsphere_utils.go
+2
-2
attach_detach_test.go
test/integration/volume/attach_detach_test.go
+6
-6
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
f737ad62
...
...
@@ -2150,17 +2150,17 @@ func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (KubernetesVolumeID, er
var
createAZ
string
if
!
volumeOptions
.
ZonePresent
&&
!
volumeOptions
.
ZonesPresent
{
createAZ
=
volume
.
ChooseZoneForVolume
(
allZones
,
volumeOptions
.
PVCName
)
createAZ
=
volume
util
.
ChooseZoneForVolume
(
allZones
,
volumeOptions
.
PVCName
)
}
if
!
volumeOptions
.
ZonePresent
&&
volumeOptions
.
ZonesPresent
{
if
adminSetOfZones
,
err
:=
volumeutil
.
ZonesToSet
(
volumeOptions
.
AvailabilityZones
);
err
!=
nil
{
return
""
,
err
}
else
{
createAZ
=
volume
.
ChooseZoneForVolume
(
adminSetOfZones
,
volumeOptions
.
PVCName
)
createAZ
=
volume
util
.
ChooseZoneForVolume
(
adminSetOfZones
,
volumeOptions
.
PVCName
)
}
}
if
volumeOptions
.
ZonePresent
&&
!
volumeOptions
.
ZonesPresent
{
if
err
:=
volume
.
ValidateZone
(
volumeOptions
.
AvailabilityZone
);
err
!=
nil
{
if
err
:=
volume
util
.
ValidateZone
(
volumeOptions
.
AvailabilityZone
);
err
!=
nil
{
return
""
,
err
}
createAZ
=
volumeOptions
.
AvailabilityZone
...
...
@@ -2476,7 +2476,7 @@ func (c *Cloud) ResizeDisk(
}
requestBytes
:=
newSize
.
Value
()
// AWS resizes in chunks of GiB (not GB)
requestGiB
:=
volume
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
)
requestGiB
:=
volume
util
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
)
newSizeQuant
:=
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dGi"
,
requestGiB
))
// If disk already if of greater or equal size than requested we return
...
...
pkg/cloudprovider/providers/gce/gce_disks.go
View file @
f737ad62
...
...
@@ -771,7 +771,7 @@ func (gce *GCECloud) ResizeDisk(diskToResize string, oldSize resource.Quantity,
requestBytes
:=
newSize
.
Value
()
// GCE resizes in chunks of GBs (not GiB)
requestGB
:=
volume
.
RoundUpSize
(
requestBytes
,
1000
*
1000
*
1000
)
requestGB
:=
volume
util
.
RoundUpSize
(
requestBytes
,
1000
*
1000
*
1000
)
newSizeQuant
:=
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dG"
,
requestGB
))
// If disk is already of size equal or greater than requested size, we simply return
...
...
pkg/cloudprovider/providers/openstack/openstack_volumes.go
View file @
f737ad62
...
...
@@ -412,7 +412,7 @@ func (os *OpenStack) ExpandVolume(volumeID string, oldSize resource.Quantity, ne
volSizeBytes
:=
newSize
.
Value
()
// Cinder works with gigabytes, convert to GiB with rounding up
volSizeGB
:=
int
(
k8s_volume
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
volSizeGB
:=
int
(
volumeutil
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
newSizeQuant
:=
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dGi"
,
volSizeGB
))
// if volume size equals to or greater than the newSize, return nil
...
...
pkg/controller/volume/attachdetach/attach_detach_controller.go
View file @
f737ad62
...
...
@@ -47,7 +47,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
// TimerConfig contains configuration of internal attach/detach timers and
...
...
@@ -137,7 +137,7 @@ func NewAttachDetachController(
eventBroadcaster
.
StartLogging
(
glog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
v1core
.
New
(
kubeClient
.
CoreV1
()
.
RESTClient
())
.
Events
(
""
)})
recorder
:=
eventBroadcaster
.
NewRecorder
(
scheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"attachdetach-controller"
})
blkutil
:=
volume
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volume
pathhandler
.
NewBlockVolumePathHandler
()
adc
.
desiredStateOfWorld
=
cache
.
NewDesiredStateOfWorld
(
&
adc
.
volumePluginMgr
)
adc
.
actualStateOfWorld
=
cache
.
NewActualStateOfWorld
(
&
adc
.
volumePluginMgr
)
...
...
@@ -361,7 +361,7 @@ func (adc *attachDetachController) populateDesiredStateOfWorld() error {
err
)
continue
}
volumeName
,
err
:=
volume
helper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
volumeName
,
err
:=
volume
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to find unique name for volume %q, pod %q/%q: %v"
,
...
...
@@ -587,10 +587,10 @@ func (adc *attachDetachController) GetExec(pluginName string) mount.Exec {
}
func
(
adc
*
attachDetachController
)
addNodeToDswp
(
node
*
v1
.
Node
,
nodeName
types
.
NodeName
)
{
if
_
,
exists
:=
node
.
Annotations
[
volume
helper
.
ControllerManagedAttachAnnotation
];
exists
{
if
_
,
exists
:=
node
.
Annotations
[
volume
util
.
ControllerManagedAttachAnnotation
];
exists
{
keepTerminatedPodVolumes
:=
false
if
t
,
ok
:=
node
.
Annotations
[
volume
helper
.
KeepTerminatedPodVolumesAnnotation
];
ok
{
if
t
,
ok
:=
node
.
Annotations
[
volume
util
.
KeepTerminatedPodVolumesAnnotation
];
ok
{
keepTerminatedPodVolumes
=
(
t
==
"true"
)
}
...
...
pkg/controller/volume/attachdetach/cache/actual_state_of_world.go
View file @
f737ad62
...
...
@@ -31,8 +31,8 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// ActualStateOfWorld defines a set of thread-safe operations supported on
...
...
@@ -275,7 +275,7 @@ func (asw *actualStateOfWorld) AddVolumeNode(
err
)
}
volumeName
,
err
=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
volumeName
,
err
=
util
.
GetUniqueVolumeNameFromSpec
(
attachableVolumePlugin
,
volumeSpec
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
...
...
pkg/controller/volume/attachdetach/cache/desired_state_of_world.go
View file @
f737ad62
...
...
@@ -28,9 +28,9 @@ import (
"k8s.io/api/core/v1"
k8stypes
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// DesiredStateOfWorld defines a set of thread-safe operations supported on
...
...
@@ -231,7 +231,7 @@ func (dsw *desiredStateOfWorld) AddPod(
err
)
}
volumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
volumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
attachableVolumePlugin
,
volumeSpec
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
...
...
pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator.go
View file @
f737ad62
...
...
@@ -33,7 +33,7 @@ import (
"k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache"
"k8s.io/kubernetes/pkg/controller/volume/attachdetach/util"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util/volumehelper
"
volutil
"k8s.io/kubernetes/pkg/volume/util
"
)
// DesiredStateOfWorldPopulator periodically verifies that the pods in the
...
...
@@ -133,7 +133,7 @@ func (dswp *desiredStateOfWorldPopulator) findAndRemoveDeletedPods() {
true
/* default volume action */
)
if
volumeActionFlag
{
informerPodUID
:=
volu
mehelper
.
GetUniquePodName
(
informerPod
)
informerPodUID
:=
volu
til
.
GetUniquePodName
(
informerPod
)
// Check whether the unique identifier of the pod from dsw matches the one retrieved from pod informer
if
informerPodUID
==
dswPodUID
{
glog
.
V
(
10
)
.
Infof
(
"Verified pod %q (UID %q) from dsw exists in pod informer."
,
dswPodKey
,
dswPodUID
)
...
...
@@ -158,7 +158,7 @@ func (dswp *desiredStateOfWorldPopulator) findAndAddActivePods() {
dswp
.
timeOfLastListPods
=
time
.
Now
()
for
_
,
pod
:=
range
pods
{
if
volu
mehelper
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
if
volu
til
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
// Do not add volumes for terminated pods
continue
}
...
...
pkg/controller/volume/attachdetach/populator/desired_state_of_world_populator_test.go
View file @
f737ad62
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache"
volumetesting
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
func
TestFindAndAddActivePods_FindAndRemoveDeletedPods
(
t
*
testing
.
T
)
{
...
...
@@ -66,7 +66,7 @@ func TestFindAndAddActivePods_FindAndRemoveDeletedPods(t *testing.T) {
fakePodInformer
.
Informer
()
.
GetStore
()
.
Add
(
pod
)
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
:=
"fake-plugin/"
+
pod
.
Spec
.
Volumes
[
0
]
.
Name
...
...
pkg/controller/volume/attachdetach/testing/testvolumespec.go
View file @
f737ad62
...
...
@@ -30,7 +30,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
core
"k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
const
TestPluginName
=
"kubernetes.io/testPlugin"
...
...
@@ -142,7 +142,7 @@ func CreateTestClient() *fake.Clientset {
"name"
:
nodeName
,
},
Annotations
:
map
[
string
]
string
{
volumehelper
.
ControllerManagedAttachAnnotation
:
"true"
,
util
.
ControllerManagedAttachAnnotation
:
"true"
,
},
},
Status
:
v1
.
NodeStatus
{
...
...
pkg/controller/volume/attachdetach/util/util.go
View file @
f737ad62
...
...
@@ -25,7 +25,7 @@ import (
corelisters
"k8s.io/client-go/listers/core/v1"
"k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
// CreateVolumeSpec creates and returns a mutatable volume.Spec object for the
...
...
@@ -150,7 +150,7 @@ func DetermineVolumeAction(pod *v1.Pod, desiredStateOfWorld cache.DesiredStateOf
nodeName
:=
types
.
NodeName
(
pod
.
Spec
.
NodeName
)
keepTerminatedPodVolume
:=
desiredStateOfWorld
.
GetKeepTerminatedPodVolumesForNode
(
nodeName
)
if
volumehelper
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
if
util
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
// if pod is terminate we let kubelet policy dictate if volume
// should be detached or not
return
keepTerminatedPodVolume
...
...
@@ -216,7 +216,7 @@ func ProcessPodVolumes(pod *v1.Pod, addVolumes bool, desiredStateOfWorld cache.D
continue
}
uniquePodName
:=
volumehelper
.
GetUniquePodName
(
pod
)
uniquePodName
:=
util
.
GetUniquePodName
(
pod
)
if
addVolumes
{
// Add volume to desired state of world
_
,
err
:=
desiredStateOfWorld
.
AddPod
(
...
...
@@ -232,7 +232,7 @@ func ProcessPodVolumes(pod *v1.Pod, addVolumes bool, desiredStateOfWorld cache.D
}
else
{
// Remove volume from desired state of world
uniqueVolumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
uniqueVolumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
attachableVolumePlugin
,
volumeSpec
)
if
err
!=
nil
{
glog
.
V
(
10
)
.
Infof
(
...
...
pkg/controller/volume/expand/expand_controller.go
View file @
f737ad62
...
...
@@ -42,8 +42,8 @@ import (
"k8s.io/kubernetes/pkg/util/io"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
const
(
...
...
@@ -118,7 +118,7 @@ func NewExpandController(
eventBroadcaster
.
StartLogging
(
glog
.
Infof
)
eventBroadcaster
.
StartRecordingToSink
(
&
v1core
.
EventSinkImpl
{
Interface
:
v1core
.
New
(
kubeClient
.
CoreV1
()
.
RESTClient
())
.
Events
(
""
)})
recorder
:=
eventBroadcaster
.
NewRecorder
(
scheme
.
Scheme
,
v1
.
EventSource
{
Component
:
"volume_expand"
})
blkutil
:=
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
expc
.
opExecutor
=
operationexecutor
.
NewOperationExecutor
(
operationexecutor
.
NewOperationGenerator
(
kubeClient
,
...
...
pkg/controller/volume/persistentvolume/framework_test.go
View file @
f737ad62
...
...
@@ -49,6 +49,7 @@ import (
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/controller"
vol
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
)
// This is a unit test framework for persistent volume controller.
...
...
@@ -1262,7 +1263,7 @@ func (plugin *mockVolumePlugin) GetMetrics() (*vol.Metrics, error) {
// Recycler interfaces
func
(
plugin
*
mockVolumePlugin
)
Recycle
(
pvName
string
,
spec
*
vol
.
Spec
,
eventRecorder
vol
.
RecycleEventRecorder
)
error
{
func
(
plugin
*
mockVolumePlugin
)
Recycle
(
pvName
string
,
spec
*
vol
.
Spec
,
eventRecorder
recyclerclient
.
RecycleEventRecorder
)
error
{
if
len
(
plugin
.
recycleCalls
)
==
0
{
return
fmt
.
Errorf
(
"Mock plugin error: no recycleCalls configured"
)
}
...
...
pkg/controller/volume/persistentvolume/index.go
View file @
f737ad62
...
...
@@ -28,7 +28,6 @@ import (
"k8s.io/client-go/tools/cache"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
)
...
...
@@ -321,7 +320,7 @@ func (pvIndex *persistentVolumeOrderedIndex) allPossibleMatchingAccessModes(requ
keys
:=
pvIndex
.
store
.
ListIndexFuncValues
(
"accessmodes"
)
for
_
,
key
:=
range
keys
{
indexedModes
:=
v1helper
.
GetAccessModesFromString
(
key
)
if
volume
.
AccessModesContainedInAll
(
indexedModes
,
requestedModes
)
{
if
volume
util
.
AccessModesContainedInAll
(
indexedModes
,
requestedModes
)
{
matchedModes
=
append
(
matchedModes
,
indexedModes
)
}
}
...
...
pkg/controller/volume/persistentvolume/index_test.go
View file @
f737ad62
...
...
@@ -27,7 +27,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
ref
"k8s.io/client-go/tools/reference"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume
/util
"
)
func
makePVC
(
size
string
,
modfn
func
(
*
v1
.
PersistentVolumeClaim
))
*
v1
.
PersistentVolumeClaim
{
...
...
@@ -304,7 +304,7 @@ func TestAllPossibleAccessModes(t *testing.T) {
t
.
Errorf
(
"Expected 3 arrays of modes that match RWO, but got %v"
,
len
(
possibleModes
))
}
for
_
,
m
:=
range
possibleModes
{
if
!
volume
.
AccessModesContains
(
m
,
v1
.
ReadWriteOnce
)
{
if
!
util
.
AccessModesContains
(
m
,
v1
.
ReadWriteOnce
)
{
t
.
Errorf
(
"AccessModes does not contain %s"
,
v1
.
ReadWriteOnce
)
}
}
...
...
@@ -313,7 +313,7 @@ func TestAllPossibleAccessModes(t *testing.T) {
if
len
(
possibleModes
)
!=
1
{
t
.
Errorf
(
"Expected 1 array of modes that match RWX, but got %v"
,
len
(
possibleModes
))
}
if
!
volume
.
AccessModesContains
(
possibleModes
[
0
],
v1
.
ReadWriteMany
)
{
if
!
util
.
AccessModesContains
(
possibleModes
[
0
],
v1
.
ReadWriteMany
)
{
t
.
Errorf
(
"AccessModes does not contain %s"
,
v1
.
ReadWriteOnce
)
}
...
...
pkg/controller/volume/persistentvolume/pv_controller.go
View file @
f737ad62
...
...
@@ -45,7 +45,7 @@ import (
"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
vol
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/
volumehelper
"
"k8s.io/kubernetes/pkg/volume/util/
recyclerclient
"
"github.com/golang/glog"
)
...
...
@@ -1262,7 +1262,7 @@ func (ctrl *PersistentVolumeController) isVolumeUsed(pv *v1.PersistentVolume) ([
return
nil
,
false
,
fmt
.
Errorf
(
"error listing pods: %s"
,
err
)
}
for
_
,
pod
:=
range
pods
{
if
volumehelper
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
if
util
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
continue
}
for
i
:=
range
pod
.
Spec
.
Volumes
{
...
...
@@ -1550,7 +1550,7 @@ func (ctrl *PersistentVolumeController) scheduleOperation(operationName string,
// newRecyclerEventRecorder returns a RecycleEventRecorder that sends all events
// to given volume.
func
(
ctrl
*
PersistentVolumeController
)
newRecyclerEventRecorder
(
volume
*
v1
.
PersistentVolume
)
vol
.
RecycleEventRecorder
{
func
(
ctrl
*
PersistentVolumeController
)
newRecyclerEventRecorder
(
volume
*
v1
.
PersistentVolume
)
recyclerclient
.
RecycleEventRecorder
{
return
func
(
eventtype
,
message
string
)
{
ctrl
.
eventRecorder
.
Eventf
(
volume
,
eventtype
,
events
.
RecyclerPod
,
"Recycler pod: %s"
,
message
)
}
...
...
pkg/controller/volume/pvcprotection/pvc_protection_controller.go
View file @
f737ad62
...
...
@@ -35,7 +35,6 @@ import (
"k8s.io/kubernetes/pkg/util/metrics"
"k8s.io/kubernetes/pkg/util/slice"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// Controller is controller that removes PVCProtectionFinalizer
...
...
@@ -214,7 +213,7 @@ func (c *Controller) isBeingUsed(pvc *v1.PersistentVolumeClaim) (bool, error) {
glog
.
V
(
4
)
.
Infof
(
"Skipping unscheduled pod %s when checking PVC %s/%s"
,
pod
.
Name
,
pvc
.
Namespace
,
pvc
.
Name
)
continue
}
if
volume
helper
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
if
volume
util
.
IsPodTerminated
(
pod
,
pod
.
Status
)
{
// This pod is being unmounted/detached or is already
// unmounted/detached. It does not block the PVC from deletion.
continue
...
...
@@ -270,7 +269,7 @@ func (c *Controller) podAddedDeletedUpdated(obj interface{}, deleted bool) {
}
// Filter out pods that can't help us to remove a finalizer on PVC
if
!
deleted
&&
!
volume
helper
.
IsPodTerminated
(
pod
,
pod
.
Status
)
&&
pod
.
Spec
.
NodeName
!=
""
{
if
!
deleted
&&
!
volume
util
.
IsPodTerminated
(
pod
,
pod
.
Status
)
&&
pod
.
Spec
.
NodeName
!=
""
{
return
}
...
...
pkg/kubelet/kubelet_node_status.go
View file @
f737ad62
...
...
@@ -46,7 +46,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/algorithm"
nodeutil
"k8s.io/kubernetes/pkg/util/node"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/volume/util/volumehelper
"
volutil
"k8s.io/kubernetes/pkg/volume/util
"
)
const
(
...
...
@@ -190,8 +190,8 @@ func (kl *Kubelet) updateDefaultLabels(initialNode, existingNode *v1.Node) bool
// whether the existing node must be updated.
func
(
kl
*
Kubelet
)
reconcileCMADAnnotationWithExistingNode
(
node
,
existingNode
*
v1
.
Node
)
bool
{
var
(
existingCMAAnnotation
=
existingNode
.
Annotations
[
volu
mehelper
.
ControllerManagedAttachAnnotation
]
newCMAAnnotation
,
newSet
=
node
.
Annotations
[
volu
mehelper
.
ControllerManagedAttachAnnotation
]
existingCMAAnnotation
=
existingNode
.
Annotations
[
volu
til
.
ControllerManagedAttachAnnotation
]
newCMAAnnotation
,
newSet
=
node
.
Annotations
[
volu
til
.
ControllerManagedAttachAnnotation
]
)
if
newCMAAnnotation
==
existingCMAAnnotation
{
...
...
@@ -203,13 +203,13 @@ func (kl *Kubelet) reconcileCMADAnnotationWithExistingNode(node, existingNode *v
// the correct value of the annotation.
if
!
newSet
{
glog
.
Info
(
"Controller attach-detach setting changed to false; updating existing Node"
)
delete
(
existingNode
.
Annotations
,
volu
mehelper
.
ControllerManagedAttachAnnotation
)
delete
(
existingNode
.
Annotations
,
volu
til
.
ControllerManagedAttachAnnotation
)
}
else
{
glog
.
Info
(
"Controller attach-detach setting changed to true; updating existing Node"
)
if
existingNode
.
Annotations
==
nil
{
existingNode
.
Annotations
=
make
(
map
[
string
]
string
)
}
existingNode
.
Annotations
[
volu
mehelper
.
ControllerManagedAttachAnnotation
]
=
newCMAAnnotation
existingNode
.
Annotations
[
volu
til
.
ControllerManagedAttachAnnotation
]
=
newCMAAnnotation
}
return
true
...
...
@@ -270,7 +270,7 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
}
glog
.
Infof
(
"Setting node annotation to enable volume controller attach/detach"
)
node
.
Annotations
[
volu
mehelper
.
ControllerManagedAttachAnnotation
]
=
"true"
node
.
Annotations
[
volu
til
.
ControllerManagedAttachAnnotation
]
=
"true"
}
else
{
glog
.
Infof
(
"Controller attach/detach is disabled for this node; Kubelet will attach and detach volumes"
)
}
...
...
@@ -280,7 +280,7 @@ func (kl *Kubelet) initialNode() (*v1.Node, error) {
node
.
Annotations
=
make
(
map
[
string
]
string
)
}
glog
.
Infof
(
"Setting node annotation to keep pod volumes of terminated pods attached to the node"
)
node
.
Annotations
[
volu
mehelper
.
KeepTerminatedPodVolumesAnnotation
]
=
"true"
node
.
Annotations
[
volu
til
.
KeepTerminatedPodVolumesAnnotation
]
=
"true"
}
// @question: should this be place after the call to the cloud provider? which also applies labels
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
f737ad62
...
...
@@ -53,7 +53,7 @@ import (
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
const
(
...
...
@@ -937,7 +937,7 @@ func TestTryRegisterWithApiServer(t *testing.T) {
if
cmad
{
node
.
Annotations
=
make
(
map
[
string
]
string
)
node
.
Annotations
[
volumehelper
.
ControllerManagedAttachAnnotation
]
=
"true"
node
.
Annotations
[
util
.
ControllerManagedAttachAnnotation
]
=
"true"
}
return
node
...
...
@@ -1089,7 +1089,7 @@ func TestTryRegisterWithApiServer(t *testing.T) {
require
.
NoError
(
t
,
err
)
}
actualCMAD
,
_
:=
strconv
.
ParseBool
(
savedNode
.
Annotations
[
volumehelper
.
ControllerManagedAttachAnnotation
])
actualCMAD
,
_
:=
strconv
.
ParseBool
(
savedNode
.
Annotations
[
util
.
ControllerManagedAttachAnnotation
])
assert
.
Equal
(
t
,
tc
.
savedNodeCMAD
,
actualCMAD
,
"test [%s]"
,
tc
.
name
)
}
}
...
...
pkg/kubelet/kubelet_pods.go
View file @
f737ad62
...
...
@@ -61,9 +61,8 @@ import (
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
utilfile
"k8s.io/kubernetes/pkg/util/file"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
volumevalidation
"k8s.io/kubernetes/pkg/volume/validation"
"k8s.io/kubernetes/third_party/forked/golang/expansion"
)
...
...
@@ -129,7 +128,7 @@ func makeAbsolutePath(goos, path string) string {
// makeBlockVolumes maps the raw block devices specified in the path of the container
// Experimental
func
(
kl
*
Kubelet
)
makeBlockVolumes
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
,
podVolumes
kubecontainer
.
VolumeMap
,
blkutil
volume
util
.
BlockVolumePathHandler
)
([]
kubecontainer
.
DeviceInfo
,
error
)
{
func
(
kl
*
Kubelet
)
makeBlockVolumes
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
,
podVolumes
kubecontainer
.
VolumeMap
,
blkutil
volume
pathhandler
.
BlockVolumePathHandler
)
([]
kubecontainer
.
DeviceInfo
,
error
)
{
var
devices
[]
kubecontainer
.
DeviceInfo
for
_
,
device
:=
range
container
.
VolumeDevices
{
// check path is absolute
...
...
@@ -188,7 +187,7 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
vol
.
SELinuxLabeled
=
true
relabelVolume
=
true
}
hostPath
,
err
:=
volume
.
GetPath
(
vol
.
Mounter
)
hostPath
,
err
:=
volume
util
.
GetPath
(
vol
.
Mounter
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -451,7 +450,7 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Contai
return
nil
,
err
}
opts
.
Hostname
=
hostname
podName
:=
volume
helper
.
GetUniquePodName
(
pod
)
podName
:=
volume
util
.
GetUniquePodName
(
pod
)
volumes
:=
kl
.
volumeManager
.
GetMountedVolumesForPod
(
podName
)
opts
.
PortMappings
=
kubecontainer
.
MakePortMappings
(
container
)
...
...
@@ -464,7 +463,7 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *v1.Pod, container *v1.Contai
// TODO: remove feature gate check after no longer needed
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
blkutil
:=
volume
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volume
pathhandler
.
NewBlockVolumePathHandler
()
blkVolumes
,
err
:=
kl
.
makeBlockVolumes
(
pod
,
container
,
volumes
,
blkutil
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/kubelet/kubelet_test.go
View file @
f737ad62
...
...
@@ -73,7 +73,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
_
"k8s.io/kubernetes/pkg/volume/host_path"
volumetest
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
func
init
()
{
...
...
@@ -2134,7 +2134,7 @@ func waitForVolumeUnmount(
func
()
(
bool
,
error
)
{
// Verify volumes detached
podVolumes
=
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
if
len
(
podVolumes
)
!=
0
{
return
false
,
nil
...
...
pkg/kubelet/kubelet_volumes_test.go
View file @
f737ad62
...
...
@@ -28,7 +28,7 @@ import (
core
"k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/volume"
volumetest
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
func
TestListVolumesForPod
(
t
*
testing
.
T
)
{
...
...
@@ -64,7 +64,7 @@ func TestListVolumesForPod(t *testing.T) {
err
:=
kubelet
.
volumeManager
.
WaitForAttachAndMount
(
pod
)
assert
.
NoError
(
t
,
err
)
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
volumesToReturn
,
volumeExsit
:=
kubelet
.
ListVolumesForPod
(
types
.
UID
(
podName
))
assert
.
True
(
t
,
volumeExsit
,
"expected to find volumes for pod %q"
,
podName
)
...
...
@@ -180,7 +180,7 @@ func TestVolumeAttachAndMountControllerDisabled(t *testing.T) {
assert
.
NoError
(
t
,
err
)
podVolumes
:=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
expectedPodVolumes
:=
[]
string
{
"vol1"
}
assert
.
Len
(
t
,
podVolumes
,
len
(
expectedPodVolumes
),
"Volumes for pod %+v"
,
pod
)
...
...
@@ -227,7 +227,7 @@ func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) {
assert
.
NoError
(
t
,
err
)
podVolumes
:=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
expectedPodVolumes
:=
[]
string
{
"vol1"
}
assert
.
Len
(
t
,
podVolumes
,
len
(
expectedPodVolumes
),
"Volumes for pod %+v"
,
pod
)
...
...
@@ -252,7 +252,7 @@ func TestVolumeUnmountAndDetachControllerDisabled(t *testing.T) {
// Verify volumes unmounted
podVolumes
=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
assert
.
Len
(
t
,
podVolumes
,
0
,
"Expected volumes to be unmounted and detached. But some volumes are still mounted: %#v"
,
podVolumes
)
...
...
@@ -317,7 +317,7 @@ func TestVolumeAttachAndMountControllerEnabled(t *testing.T) {
assert
.
NoError
(
t
,
kubelet
.
volumeManager
.
WaitForAttachAndMount
(
pod
))
podVolumes
:=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
expectedPodVolumes
:=
[]
string
{
"vol1"
}
assert
.
Len
(
t
,
podVolumes
,
len
(
expectedPodVolumes
),
"Volumes for pod %+v"
,
pod
)
...
...
@@ -386,7 +386,7 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
assert
.
NoError
(
t
,
kubelet
.
volumeManager
.
WaitForAttachAndMount
(
pod
))
podVolumes
:=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
expectedPodVolumes
:=
[]
string
{
"vol1"
}
assert
.
Len
(
t
,
podVolumes
,
len
(
expectedPodVolumes
),
"Volumes for pod %+v"
,
pod
)
...
...
@@ -410,7 +410,7 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
// Verify volumes unmounted
podVolumes
=
kubelet
.
volumeManager
.
GetMountedVolumesForPod
(
volumehelper
.
GetUniquePodName
(
pod
))
util
.
GetUniquePodName
(
pod
))
assert
.
Len
(
t
,
podVolumes
,
0
,
"Expected volumes to be unmounted and detached. But some volumes are still mounted: %#v"
,
podVolumes
)
...
...
pkg/kubelet/volume_host.go
View file @
f737ad62
...
...
@@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/util/io"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// NewInitializedVolumePluginMgr returns a new instance of
...
...
@@ -94,7 +95,7 @@ func (kvh *kubeletVolumeHost) GetVolumeDevicePluginDir(pluginName string) string
func
(
kvh
*
kubeletVolumeHost
)
GetPodVolumeDir
(
podUID
types
.
UID
,
pluginName
string
,
volumeName
string
)
string
{
dir
:=
kvh
.
kubelet
.
getPodVolumeDir
(
podUID
,
pluginName
,
volumeName
)
if
runtime
.
GOOS
==
"windows"
{
dir
=
volume
.
GetWindowsPath
(
dir
)
dir
=
util
.
GetWindowsPath
(
dir
)
}
return
dir
}
...
...
pkg/kubelet/volumemanager/cache/actual_state_of_world.go
View file @
f737ad62
...
...
@@ -29,9 +29,9 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// ActualStateOfWorld defines a set of thread-safe operations for the kubelet
...
...
@@ -358,7 +358,7 @@ func (asw *actualStateOfWorld) addVolume(
}
if
len
(
volumeName
)
==
0
{
volumeName
,
err
=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
volumePlugin
,
volumeSpec
)
volumeName
,
err
=
util
.
GetUniqueVolumeNameFromSpec
(
volumePlugin
,
volumeSpec
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to GetUniqueVolumeNameFromSpec for volumeSpec %q using volume plugin %q err=%v"
,
...
...
pkg/kubelet/volumemanager/cache/actual_state_of_world_test.go
View file @
f737ad62
...
...
@@ -23,8 +23,8 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume"
volumetesting
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
var
emptyVolumeName
=
v1
.
UniqueVolumeName
(
""
)
...
...
@@ -56,7 +56,7 @@ func Test_MarkVolumeAsAttached_Positive_NewVolume(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
devicePath
:=
"fake/device/path"
generatedVolumeName
,
_
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
generatedVolumeName
,
_
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
// Act
err
:=
asw
.
MarkVolumeAsAttached
(
emptyVolumeName
,
volumeSpec
,
""
/* nodeName */
,
devicePath
)
...
...
@@ -143,7 +143,7 @@ func Test_MarkVolumeAsAttached_Positive_ExistingVolume(t *testing.T) {
},
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
generatedVolumeName
,
_
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
generatedVolumeName
,
_
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
err
:=
asw
.
MarkVolumeAsAttached
(
emptyVolumeName
,
volumeSpec
,
""
/* nodeName */
,
devicePath
)
if
err
!=
nil
{
...
...
@@ -191,13 +191,13 @@ func Test_AddPodToVolume_Positive_ExistingVolumeNewNode(t *testing.T) {
},
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
generatedVolumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
generatedVolumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
err
=
asw
.
MarkVolumeAsAttached
(
emptyVolumeName
,
volumeSpec
,
""
/* nodeName */
,
devicePath
)
if
err
!=
nil
{
t
.
Fatalf
(
"MarkVolumeAsAttached failed. Expected: <no error> Actual: <%v>"
,
err
)
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
mounter
,
err
:=
plugin
.
NewMounter
(
volumeSpec
,
pod
,
volume
.
VolumeOptions
{})
if
err
!=
nil
{
...
...
@@ -255,14 +255,14 @@ func Test_AddPodToVolume_Positive_ExistingVolumeExistingNode(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
generatedVolumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
generatedVolumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
err
=
asw
.
MarkVolumeAsAttached
(
emptyVolumeName
,
volumeSpec
,
""
/* nodeName */
,
devicePath
)
if
err
!=
nil
{
t
.
Fatalf
(
"MarkVolumeAsAttached failed. Expected: <no error> Actual: <%v>"
,
err
)
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
mounter
,
err
:=
plugin
.
NewMounter
(
volumeSpec
,
pod
,
volume
.
VolumeOptions
{})
if
err
!=
nil
{
...
...
@@ -339,10 +339,10 @@ func Test_AddPodToVolume_Negative_VolumeDoesntExist(t *testing.T) {
err
)
}
volumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
volumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
mounter
,
err
:=
plugin
.
NewMounter
(
volumeSpec
,
pod
,
volume
.
VolumeOptions
{})
if
err
!=
nil
{
...
...
@@ -404,7 +404,7 @@ func Test_MarkDeviceAsMounted_Positive_NewVolume(t *testing.T) {
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
devicePath
:=
"fake/device/path"
deviceMountPath
:=
"fake/device/mount/path"
generatedVolumeName
,
err
:=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
generatedVolumeName
,
err
:=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
err
=
asw
.
MarkVolumeAsAttached
(
emptyVolumeName
,
volumeSpec
,
""
/* nodeName */
,
devicePath
)
if
err
!=
nil
{
...
...
pkg/kubelet/volumemanager/cache/desired_state_of_world.go
View file @
f737ad62
...
...
@@ -26,9 +26,9 @@ import (
"k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// DesiredStateOfWorld defines a set of thread-safe operations for the kubelet
...
...
@@ -206,7 +206,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
// For attachable volumes, use the unique volume name as reported by
// the plugin.
volumeName
,
err
=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
volumePlugin
,
volumeSpec
)
util
.
GetUniqueVolumeNameFromSpec
(
volumePlugin
,
volumeSpec
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to GetUniqueVolumeNameFromSpec for volumeSpec %q using volume plugin %q err=%v"
,
...
...
@@ -217,7 +217,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
}
else
{
// For non-attachable volumes, generate a unique name based on the pod
// namespace and name and the name of the volume within the pod.
volumeName
=
volumehelper
.
GetUniqueVolumeNameForNonAttachableVolume
(
podName
,
volumePlugin
,
volumeSpec
)
volumeName
=
util
.
GetUniqueVolumeNameForNonAttachableVolume
(
podName
,
volumePlugin
,
volumeSpec
)
}
volumeObj
,
volumeExists
:=
dsw
.
volumesToMount
[
volumeName
]
...
...
pkg/kubelet/volumemanager/cache/desired_state_of_world_test.go
View file @
f737ad62
...
...
@@ -23,8 +23,8 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume"
volumetesting
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// Calls AddPodToVolume() to add new pod to new volume
...
...
@@ -54,7 +54,7 @@ func Test_AddPodToVolume_Positive_NewPodNewVolume(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
// Act
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
...
...
@@ -99,7 +99,7 @@ func Test_AddPodToVolume_Positive_ExistingPodExistingVolume(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
// Act
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
...
...
@@ -144,7 +144,7 @@ func Test_DeletePodFromVolume_Positive_PodExistsVolumeExists(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
if
err
!=
nil
{
...
...
@@ -197,7 +197,7 @@ func Test_MarkVolumesReportedInUse_Positive_NewPodNewVolume(t *testing.T) {
}
volume1Spec
:=
&
volume
.
Spec
{
Volume
:
&
pod1
.
Spec
.
Volumes
[
0
]}
pod1Name
:=
volumehelper
.
GetUniquePodName
(
pod1
)
pod1Name
:=
util
.
GetUniquePodName
(
pod1
)
pod2
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -219,7 +219,7 @@ func Test_MarkVolumesReportedInUse_Positive_NewPodNewVolume(t *testing.T) {
}
volume2Spec
:=
&
volume
.
Spec
{
Volume
:
&
pod2
.
Spec
.
Volumes
[
0
]}
pod2Name
:=
volumehelper
.
GetUniquePodName
(
pod2
)
pod2Name
:=
util
.
GetUniquePodName
(
pod2
)
pod3
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -241,7 +241,7 @@ func Test_MarkVolumesReportedInUse_Positive_NewPodNewVolume(t *testing.T) {
}
volume3Spec
:=
&
volume
.
Spec
{
Volume
:
&
pod3
.
Spec
.
Volumes
[
0
]}
pod3Name
:=
volumehelper
.
GetUniquePodName
(
pod3
)
pod3Name
:=
util
.
GetUniquePodName
(
pod3
)
generatedVolume1Name
,
err
:=
dsw
.
AddPodToVolume
(
pod1Name
,
pod1
,
volume1Spec
,
volume1Spec
.
Name
(),
""
/* volumeGidValue */
)
...
...
pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go
View file @
f737ad62
...
...
@@ -41,8 +41,8 @@ import (
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// DesiredStateOfWorldPopulator periodically loops through the list of active
...
...
@@ -176,7 +176,7 @@ func (dswp *desiredStateOfWorldPopulator) isPodTerminated(pod *v1.Pod) bool {
if
!
found
{
podStatus
=
pod
.
Status
}
return
volumehelper
.
IsPodTerminated
(
pod
,
podStatus
)
return
util
.
IsPodTerminated
(
pod
,
podStatus
)
}
// Iterate through all pods and add to desired state of world if they don't
...
...
@@ -260,7 +260,7 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(pod *v1.Pod) {
return
}
uniquePodName
:=
volumehelper
.
GetUniquePodName
(
pod
)
uniquePodName
:=
util
.
GetUniquePodName
(
pod
)
if
dswp
.
podPreviouslyProcessed
(
uniquePodName
)
{
return
}
...
...
@@ -393,7 +393,7 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
// TODO: remove feature gate check after no longer needed
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
volumeMode
,
err
:=
volumehelper
.
GetVolumeMode
(
volumeSpec
)
volumeMode
,
err
:=
util
.
GetVolumeMode
(
volumeSpec
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
...
...
@@ -525,7 +525,7 @@ func (dswp *desiredStateOfWorldPopulator) makeVolumeMap(containers []v1.Containe
}
func
getPVVolumeGidAnnotationValue
(
pv
*
v1
.
PersistentVolume
)
string
{
if
volumeGid
,
ok
:=
pv
.
Annotations
[
volumehelper
.
VolumeGidAnnotationKey
];
ok
{
if
volumeGid
,
ok
:=
pv
.
Annotations
[
util
.
VolumeGidAnnotationKey
];
ok
{
return
volumeGid
}
...
...
pkg/kubelet/volumemanager/populator/desired_state_of_world_populator_test.go
View file @
f737ad62
...
...
@@ -35,8 +35,8 @@ import (
statustest
"k8s.io/kubernetes/pkg/kubelet/status/testing"
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
volumetesting
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
func
TestFindAndAddNewPods_FindAndRemoveDeletedPods
(
t
*
testing
.
T
)
{
...
...
@@ -74,7 +74,7 @@ func TestFindAndAddNewPods_FindAndRemoveDeletedPods(t *testing.T) {
fakePodManager
.
AddPod
(
pod
)
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
:=
"fake-plugin/"
+
pod
.
Spec
.
Volumes
[
0
]
.
Name
...
...
@@ -184,7 +184,7 @@ func TestFindAndAddNewPods_FindAndRemoveDeletedPods_Valid_Block_VolumeDevices(t
fakePodManager
.
AddPod
(
pod
)
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
:=
"fake-plugin/"
+
pod
.
Spec
.
Volumes
[
0
]
.
Name
...
...
pkg/kubelet/volumemanager/reconciler/reconciler.go
View file @
f737ad62
...
...
@@ -41,10 +41,10 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
volumepkg
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/nestedpendingoperations"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// Reconciler runs a periodic loop to reconcile the desired state of the world
...
...
@@ -445,12 +445,12 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (*reconstructedVolume,
var
uniqueVolumeName
v1
.
UniqueVolumeName
if
attachablePlugin
!=
nil
{
uniqueVolumeName
,
err
=
volumehelper
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
uniqueVolumeName
,
err
=
util
.
GetUniqueVolumeNameFromSpec
(
plugin
,
volumeSpec
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
uniqueVolumeName
=
volumehelper
.
GetUniqueVolumeNameForNonAttachableVolume
(
volume
.
podName
,
plugin
,
volumeSpec
)
uniqueVolumeName
=
util
.
GetUniqueVolumeNameForNonAttachableVolume
(
volume
.
podName
,
plugin
,
volumeSpec
)
}
// Check existence of mount point for filesystem volume or symbolic link for block volume
isExist
,
checkErr
:=
rc
.
operationExecutor
.
CheckVolumeExistenceOperation
(
volumeSpec
,
volume
.
mountPath
,
volumeSpec
.
Name
(),
rc
.
mounter
,
uniqueVolumeName
,
volume
.
podName
,
pod
.
UID
,
attachablePlugin
)
...
...
pkg/kubelet/volumemanager/reconciler/reconciler_test.go
View file @
f737ad62
...
...
@@ -36,8 +36,8 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumetesting
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
const
(
...
...
@@ -149,7 +149,7 @@ func Test_Run_Positive_VolumeAttachAndMount(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
@@ -227,7 +227,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabled(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
dsw
.
MarkVolumesReportedInUse
([]
v1
.
UniqueVolumeName
{
generatedVolumeName
})
...
...
@@ -306,7 +306,7 @@ func Test_Run_Positive_VolumeAttachMountUnmountDetach(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
@@ -396,7 +396,7 @@ func Test_Run_Positive_VolumeUnmountControllerAttachEnabled(t *testing.T) {
}
volumeSpec
:=
&
volume
.
Spec
{
Volume
:
&
pod
.
Spec
.
Volumes
[
0
]}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
@@ -491,7 +491,7 @@ func Test_Run_Positive_VolumeAttachAndMap(t *testing.T) {
volumeSpec
:=
&
volume
.
Spec
{
PersistentVolume
:
gcepv
,
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
@@ -582,7 +582,7 @@ func Test_Run_Positive_BlockVolumeMapControllerAttachEnabled(t *testing.T) {
volumeSpec
:=
&
volume
.
Spec
{
PersistentVolume
:
gcepv
,
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
dsw
.
MarkVolumesReportedInUse
([]
v1
.
UniqueVolumeName
{
generatedVolumeName
})
...
...
@@ -674,7 +674,7 @@ func Test_Run_Positive_BlockVolumeAttachMapUnmapDetach(t *testing.T) {
volumeSpec
:=
&
volume
.
Spec
{
PersistentVolume
:
gcepv
,
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
@@ -776,7 +776,7 @@ func Test_Run_Positive_VolumeUnmapControllerAttachEnabled(t *testing.T) {
volumeSpec
:=
&
volume
.
Spec
{
PersistentVolume
:
gcepv
,
}
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
generatedVolumeName
,
err
:=
dsw
.
AddPodToVolume
(
podName
,
pod
,
volumeSpec
,
volumeSpec
.
Name
(),
""
/* volumeGidValue */
)
...
...
pkg/kubelet/volumemanager/volume_manager.go
View file @
f737ad62
...
...
@@ -43,7 +43,7 @@ import (
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/operationexecutor"
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
const
(
...
...
@@ -169,7 +169,7 @@ func NewVolumeManager(
volumePluginMgr
,
recorder
,
checkNodeCapabilitiesBeforeMount
,
util
.
NewBlockVolumePathHandler
())),
volumepathhandler
.
NewBlockVolumePathHandler
())),
}
vm
.
desiredStateOfWorldPopulator
=
populator
.
NewDesiredStateOfWorldPopulator
(
...
...
@@ -264,7 +264,7 @@ func (vm *volumeManager) GetMountedVolumesForPod(podName types.UniquePodName) co
}
func
(
vm
*
volumeManager
)
GetExtraSupplementalGroupsForPod
(
pod
*
v1
.
Pod
)
[]
int64
{
podName
:=
volumehelper
.
GetUniquePodName
(
pod
)
podName
:=
util
.
GetUniquePodName
(
pod
)
supplementalGroups
:=
sets
.
NewString
()
for
_
,
mountedVolume
:=
range
vm
.
actualStateOfWorld
.
GetMountedVolumesForPod
(
podName
)
{
...
...
@@ -340,7 +340,7 @@ func (vm *volumeManager) WaitForAttachAndMount(pod *v1.Pod) error {
}
glog
.
V
(
3
)
.
Infof
(
"Waiting for volumes to attach and mount for pod %q"
,
format
.
Pod
(
pod
))
uniquePodName
:=
volumehelper
.
GetUniquePodName
(
pod
)
uniquePodName
:=
util
.
GetUniquePodName
(
pod
)
// Some pods expect to have Setup called over and over again to update.
// Remount plugins for which this is true. (Atomically updating volumes,
...
...
pkg/kubelet/volumemanager/volume_manager_test.go
View file @
f737ad62
...
...
@@ -41,8 +41,8 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumetest
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
const
(
...
...
@@ -168,7 +168,7 @@ func TestGetExtraSupplementalGroupsForPod(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pvA"
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeGidAnnotationKey
:
tc
.
gidAnnotation
,
util
.
VolumeGidAnnotationKey
:
tc
.
gidAnnotation
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/aws_ebs/attacher.go
View file @
f737ad62
...
...
@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
awsElasticBlockStoreAttacher
struct
{
...
...
@@ -219,8 +218,8 @@ func (attacher *awsElasticBlockStoreAttacher) MountDevice(spec *volume.Spec, dev
options
=
append
(
options
,
"ro"
)
}
if
notMnt
{
diskMounter
:=
volume
helper
.
NewSafeFormatAndMountFromHost
(
awsElasticBlockStorePluginName
,
attacher
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
diskMounter
:=
volume
util
.
NewSafeFormatAndMountFromHost
(
awsElasticBlockStorePluginName
,
attacher
.
host
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/aws_ebs/aws_ebs.go
View file @
f737ad62
...
...
@@ -34,7 +34,6 @@ import (
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -134,7 +133,7 @@ func (plugin *awsElasticBlockStorePlugin) newMounterInternal(spec *volume.Spec,
},
fsType
:
fsType
,
readOnly
:
readOnly
,
diskMounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
diskMounter
:
util
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
}
func
(
plugin
*
awsElasticBlockStorePlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -456,7 +455,7 @@ type awsElasticBlockStoreProvisioner struct {
var
_
volume
.
Provisioner
=
&
awsElasticBlockStoreProvisioner
{}
func
(
c
*
awsElasticBlockStoreProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -475,7 +474,7 @@ func (c *awsElasticBlockStoreProvisioner) Provision() (*v1.PersistentVolume, err
Name
:
c
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"aws-ebs-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"aws-ebs-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/aws_ebs/aws_ebs_block.go
View file @
f737ad62
...
...
@@ -30,7 +30,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util
/volumepathhandler
"
)
var
_
volume
.
VolumePlugin
=
&
awsElasticBlockStorePlugin
{}
...
...
@@ -41,7 +41,7 @@ var _ volume.ProvisionableVolumePlugin = &awsElasticBlockStorePlugin{}
func
(
plugin
*
awsElasticBlockStorePlugin
)
ConstructBlockVolumeSpec
(
podUID
types
.
UID
,
volumeName
,
mapPath
string
)
(
*
volume
.
Spec
,
error
)
{
pluginDir
:=
plugin
.
host
.
GetVolumeDevicePluginDir
(
awsElasticBlockStorePluginName
)
blkutil
:=
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
globalMapPathUUID
,
err
:=
blkutil
.
FindGlobalMapPathUUIDFromPod
(
pluginDir
,
mapPath
,
podUID
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/volume/aws_ebs/aws_util.go
View file @
f737ad62
...
...
@@ -80,12 +80,12 @@ func (util *AWSDiskUtil) CreateVolume(c *awsElasticBlockStoreProvisioner) (aws.K
}
else
{
tags
=
*
c
.
options
.
CloudTags
}
tags
[
"Name"
]
=
volume
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
255
)
// AWS tags can have 255 characters
tags
[
"Name"
]
=
volume
util
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
255
)
// AWS tags can have 255 characters
capacity
:=
c
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestBytes
:=
capacity
.
Value
()
// AWS works with gigabytes, convert to GiB with rounding up
requestGB
:=
int
(
volume
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
requestGB
:=
int
(
volume
util
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
volumeOptions
:=
&
aws
.
VolumeOptions
{
CapacityGB
:
requestGB
,
Tags
:
tags
,
...
...
pkg/volume/azure_dd/attacher.go
View file @
f737ad62
...
...
@@ -36,8 +36,7 @@ import (
"k8s.io/kubernetes/pkg/util/keymutex"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/pkg/volume/util"
)
type
azureDiskDetacher
struct
{
...
...
@@ -249,8 +248,8 @@ func (attacher *azureDiskAttacher) MountDevice(spec *volume.Spec, devicePath str
options
:=
[]
string
{}
if
notMnt
{
diskMounter
:=
volumehelper
.
NewSafeFormatAndMountFromHost
(
azureDataDiskPluginName
,
attacher
.
plugin
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
diskMounter
:=
util
.
NewSafeFormatAndMountFromHost
(
azureDataDiskPluginName
,
attacher
.
plugin
.
host
)
mountOptions
:=
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
*
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
if
cleanErr
:=
os
.
Remove
(
deviceMountPath
);
cleanErr
!=
nil
{
...
...
@@ -295,7 +294,7 @@ func (d *azureDiskDetacher) Detach(diskURI string, nodeName types.NodeName) erro
// UnmountDevice unmounts the volume on the node
func
(
detacher
*
azureDiskDetacher
)
UnmountDevice
(
deviceMountPath
string
)
error
{
err
:=
volume
util
.
UnmountPath
(
deviceMountPath
,
detacher
.
plugin
.
host
.
GetMounter
(
detacher
.
plugin
.
GetPluginName
()))
err
:=
util
.
UnmountPath
(
deviceMountPath
,
detacher
.
plugin
.
host
.
GetMounter
(
detacher
.
plugin
.
GetPluginName
()))
if
err
==
nil
{
glog
.
V
(
4
)
.
Infof
(
"azureDisk - Device %s was unmounted"
,
deviceMountPath
)
}
else
{
...
...
pkg/volume/azure_dd/azure_mounter.go
View file @
f737ad62
...
...
@@ -116,7 +116,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
m
.
options
.
MountOptions
!=
nil
{
options
=
volume
.
JoinMountOptions
(
m
.
options
.
MountOptions
,
options
)
options
=
util
.
JoinMountOptions
(
m
.
options
.
MountOptions
,
options
)
}
glog
.
V
(
4
)
.
Infof
(
"azureDisk - Attempting to mount %s on %s"
,
diskName
,
dir
)
...
...
pkg/volume/azure_dd/azure_provision.go
View file @
f737ad62
...
...
@@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
type
azureDiskProvisioner
struct
{
...
...
@@ -65,7 +66,7 @@ func (d *azureDiskDeleter) Delete() error {
}
func
(
p
*
azureDiskProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
p
.
options
.
PVC
.
Spec
.
AccessModes
,
p
.
plugin
.
GetAccessModes
())
}
supportedModes
:=
p
.
plugin
.
GetAccessModes
()
...
...
@@ -93,10 +94,10 @@ func (p *azureDiskProvisioner) Provision() (*v1.PersistentVolume, error) {
err
error
)
// maxLength = 79 - (4 for ".vhd") = 75
name
:=
volume
.
GenerateVolumeName
(
p
.
options
.
ClusterName
,
p
.
options
.
PVName
,
75
)
name
:=
util
.
GenerateVolumeName
(
p
.
options
.
ClusterName
,
p
.
options
.
PVName
,
75
)
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestBytes
:=
capacity
.
Value
()
requestGB
:=
int
(
volume
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
requestGB
:=
int
(
util
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
for
k
,
v
:=
range
p
.
options
.
Parameters
{
switch
strings
.
ToLower
(
k
)
{
...
...
pkg/volume/azure_file/azure_file.go
View file @
f737ad62
...
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
volutil
"k8s.io/kubernetes/pkg/volume/util"
)
// ProbeVolumePlugins is the primary endpoint for volume plugins
...
...
@@ -122,7 +122,7 @@ func (plugin *azureFilePlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod
secretName
:
secretName
,
shareName
:
share
,
readOnly
:
readOnly
,
mountOptions
:
volu
me
.
MountOptionFromSpec
(
spec
),
mountOptions
:
volu
til
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -168,7 +168,7 @@ func (plugin *azureFilePlugin) ExpandVolumeDevice(
return
oldSize
,
err
}
if
err
:=
azure
.
ResizeFileShare
(
accountName
,
accountKey
,
shareName
,
int
(
volu
me
.
RoundUpToGiB
(
newSize
)));
err
!=
nil
{
if
err
:=
azure
.
ResizeFileShare
(
accountName
,
accountKey
,
shareName
,
int
(
volu
til
.
RoundUpToGiB
(
newSize
)));
err
!=
nil
{
return
oldSize
,
err
}
...
...
@@ -262,7 +262,7 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error {
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
}
mountOptions
=
volu
me
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
=
volu
til
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
=
appendDefaultMountOptions
(
mountOptions
,
fsGroup
)
}
...
...
@@ -306,7 +306,7 @@ func (c *azureFileUnmounter) TearDown() error {
}
func
(
c
*
azureFileUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
return
vol
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
getVolumeSource
(
spec
*
volume
.
Spec
)
(
string
,
bool
,
error
)
{
...
...
pkg/volume/azure_file/azure_provision.go
View file @
f737ad62
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
var
_
volume
.
DeletableVolumePlugin
=
&
azureFilePlugin
{}
...
...
@@ -132,18 +132,18 @@ type azureFileProvisioner struct {
var
_
volume
.
Provisioner
=
&
azureFileProvisioner
{}
func
(
a
*
azureFileProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
a
.
plugin
.
GetAccessModes
(),
a
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
a
.
plugin
.
GetAccessModes
(),
a
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
a
.
options
.
PVC
.
Spec
.
AccessModes
,
a
.
plugin
.
GetAccessModes
())
}
var
sku
,
location
,
account
string
// File share name has a length limit of 63, and it cannot contain two consecutive '-'s.
name
:=
volume
.
GenerateVolumeName
(
a
.
options
.
ClusterName
,
a
.
options
.
PVName
,
63
)
name
:=
util
.
GenerateVolumeName
(
a
.
options
.
ClusterName
,
a
.
options
.
PVName
,
63
)
name
=
strings
.
Replace
(
name
,
"--"
,
"-"
,
-
1
)
capacity
:=
a
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestBytes
:=
capacity
.
Value
()
requestGiB
:=
int
(
volume
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
requestGiB
:=
int
(
util
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
secretNamespace
:=
a
.
options
.
PVC
.
Namespace
// Apply ProvisionerParameters (case-insensitive). We leave validation of
// the values to the cloud provider.
...
...
@@ -182,7 +182,7 @@ func (a *azureFileProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
a
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"azure-file-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"azure-file-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/cephfs/cephfs.go
View file @
f737ad62
...
...
@@ -148,7 +148,7 @@ func (plugin *cephfsPlugin) newMounterInternal(spec *volume.Spec, podUID types.U
readonly
:
readOnly
,
mounter
:
mounter
,
plugin
:
plugin
,
mountOptions
:
volume
.
MountOptionFromSpec
(
spec
),
mountOptions
:
util
.
MountOptionFromSpec
(
spec
),
},
},
nil
}
...
...
@@ -323,7 +323,7 @@ func (cephfsVolume *cephfs) execMount(mountpoint string) error {
}
src
+=
hosts
[
i
]
+
":"
+
cephfsVolume
.
path
mountOptions
:=
volume
.
JoinMountOptions
(
cephfsVolume
.
mountOptions
,
opt
)
mountOptions
:=
util
.
JoinMountOptions
(
cephfsVolume
.
mountOptions
,
opt
)
if
err
:=
cephfsVolume
.
mounter
.
Mount
(
src
,
mountpoint
,
"ceph"
,
mountOptions
);
err
!=
nil
{
return
fmt
.
Errorf
(
"CephFS: mount failed: %v"
,
err
)
}
...
...
pkg/volume/cinder/attacher.go
View file @
f737ad62
...
...
@@ -31,7 +31,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
cinderDiskAttacher
struct
{
...
...
@@ -286,8 +285,8 @@ func (attacher *cinderDiskAttacher) MountDevice(spec *volume.Spec, devicePath st
options
=
append
(
options
,
"ro"
)
}
if
notMnt
{
diskMounter
:=
volume
helper
.
NewSafeFormatAndMountFromHost
(
cinderVolumePluginName
,
attacher
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
diskMounter
:=
volume
util
.
NewSafeFormatAndMountFromHost
(
cinderVolumePluginName
,
attacher
.
host
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/cinder/cinder.go
View file @
f737ad62
...
...
@@ -34,7 +34,6 @@ import (
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
const
(
...
...
@@ -145,7 +144,7 @@ func (plugin *cinderPlugin) newMounterInternal(spec *volume.Spec, podUID types.U
},
fsType
:
fsType
,
readOnly
:
readOnly
,
blockDeviceMounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
blockDeviceMounter
:
util
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
}
func
(
plugin
*
cinderPlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -501,7 +500,7 @@ type cinderVolumeProvisioner struct {
var
_
volume
.
Provisioner
=
&
cinderVolumeProvisioner
{}
func
(
c
*
cinderVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -515,7 +514,7 @@ func (c *cinderVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
c
.
options
.
PVName
,
Labels
:
labels
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"cinder-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"cinder-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/cinder/cinder_util.go
View file @
f737ad62
...
...
@@ -32,6 +32,7 @@ import (
clientset
"k8s.io/client-go/kubernetes"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/utils/exec"
)
...
...
@@ -170,8 +171,8 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
capacity
:=
c
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
volSizeBytes
:=
capacity
.
Value
()
// Cinder works with gigabytes, convert to GiB with rounding up
volSizeGB
:=
int
(
volu
me
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
name
:=
volu
me
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
255
)
// Cinder volume name can have up to 255 characters
volSizeGB
:=
int
(
volu
til
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
name
:=
volu
til
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
255
)
// Cinder volume name can have up to 255 characters
vtype
:=
""
availability
:=
""
// Apply ProvisionerParameters (case-insensitive). We leave validation of
...
...
@@ -203,7 +204,7 @@ func (util *DiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID string,
// if we did not get any zones, lets leave it blank and gophercloud will
// use zone "nova" as default
if
len
(
zones
)
>
0
{
availability
=
volu
me
.
ChooseZoneForVolume
(
zones
,
c
.
options
.
PVC
.
Name
)
availability
=
volu
til
.
ChooseZoneForVolume
(
zones
,
c
.
options
.
PVC
.
Name
)
}
}
...
...
pkg/volume/configmap/configmap.go
View file @
f737ad62
...
...
@@ -313,7 +313,7 @@ func (c *configMapVolumeUnmounter) TearDown() error {
}
func
(
c
*
configMapVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
volume
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
return
volume
util
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
}
func
getVolumeSource
(
spec
*
volume
.
Spec
)
(
*
v1
.
ConfigMapVolumeSource
,
bool
)
{
...
...
pkg/volume/downwardapi/downwardapi.go
View file @
f737ad62
...
...
@@ -283,7 +283,7 @@ func (c *downwardAPIVolumeUnmounter) TearDown() error {
}
func
(
c
*
downwardAPIVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
volume
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
return
volume
util
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
}
func
(
b
*
downwardAPIVolumeMounter
)
getMetaDir
()
string
{
...
...
pkg/volume/fc/attacher.go
View file @
f737ad62
...
...
@@ -31,7 +31,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
fcAttacher
struct
{
...
...
@@ -113,7 +112,7 @@ func (attacher *fcAttacher) MountDevice(spec *volume.Spec, devicePath string, de
}
if
notMnt
{
diskMounter
:=
&
mount
.
SafeFormatAndMount
{
Interface
:
mounter
,
Exec
:
attacher
.
host
.
GetExec
(
fcPluginName
)}
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
@@ -189,7 +188,7 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost) (*fcDiskMoun
}
// TODO: remove feature gate check after no longer needed
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
volumeMode
,
err
:=
volume
helper
.
GetVolumeMode
(
spec
)
volumeMode
,
err
:=
volume
util
.
GetVolumeMode
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -199,7 +198,7 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost) (*fcDiskMoun
fsType
:
fc
.
FSType
,
volumeMode
:
volumeMode
,
readOnly
:
readOnly
,
mounter
:
volume
helper
.
NewSafeFormatAndMountFromHost
(
fcPluginName
,
host
),
mounter
:
volume
util
.
NewSafeFormatAndMountFromHost
(
fcPluginName
,
host
),
deviceUtil
:
volumeutil
.
NewDeviceHandler
(
volumeutil
.
NewIOHandler
()),
},
nil
}
...
...
@@ -207,7 +206,7 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost) (*fcDiskMoun
fcDisk
:
fcDisk
,
fsType
:
fc
.
FSType
,
readOnly
:
readOnly
,
mounter
:
volume
helper
.
NewSafeFormatAndMountFromHost
(
fcPluginName
,
host
),
mounter
:
volume
util
.
NewSafeFormatAndMountFromHost
(
fcPluginName
,
host
),
deviceUtil
:
volumeutil
.
NewDeviceHandler
(
volumeutil
.
NewIOHandler
()),
},
nil
}
...
...
pkg/volume/fc/fc.go
View file @
f737ad62
...
...
@@ -32,7 +32,7 @@ import (
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -133,7 +133,7 @@ func (plugin *fcPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID,
}
// TODO: remove feature gate check after no longer needed
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
volumeMode
,
err
:=
volumehelper
.
GetVolumeMode
(
spec
)
volumeMode
,
err
:=
util
.
GetVolumeMode
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -297,7 +297,7 @@ func (plugin *fcPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volu
// globalMapPathUUID : plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumePluginDependentPath}/{pod uuid}
func
(
plugin
*
fcPlugin
)
ConstructBlockVolumeSpec
(
podUID
types
.
UID
,
volumeName
,
mapPath
string
)
(
*
volume
.
Spec
,
error
)
{
pluginDir
:=
plugin
.
host
.
GetVolumeDevicePluginDir
(
fcPluginName
)
blkutil
:=
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
globalMapPathUUID
,
err
:=
blkutil
.
FindGlobalMapPathUUIDFromPod
(
pluginDir
,
mapPath
,
podUID
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/volume/fc/fc_util.go
View file @
f737ad62
...
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
type
ioHandler
interface
{
...
...
@@ -354,14 +355,14 @@ func (util *FCUtil) DetachBlockFCDisk(c fcDiskUnmapper, mapPath, devicePath stri
// and remove loopback device then it will be remained on kubelet node. To avoid the problem,
// local attach plugins needs to remove loopback device during TearDownDevice().
var
devices
[]
string
blkUtil
:=
volume
util
.
NewBlockVolumePathHandler
()
blkUtil
:=
volume
pathhandler
.
NewBlockVolumePathHandler
()
dm
:=
c
.
deviceUtil
.
FindMultipathDeviceForDevice
(
dstPath
)
if
len
(
dm
)
!=
0
{
dstPath
=
dm
}
loop
,
err
:=
volume
util
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
dstPath
)
loop
,
err
:=
volume
pathhandler
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
dstPath
)
if
err
!=
nil
{
if
err
.
Error
()
!=
volume
util
.
ErrDeviceNotFound
{
if
err
.
Error
()
!=
volume
pathhandler
.
ErrDeviceNotFound
{
return
fmt
.
Errorf
(
"fc: failed to get loopback for destination path: %v, err: %v"
,
dstPath
,
err
)
}
glog
.
Warning
(
"fc: loopback for destination path: %s not found"
,
dstPath
)
...
...
@@ -389,7 +390,7 @@ func (util *FCUtil) DetachBlockFCDisk(c fcDiskUnmapper, mapPath, devicePath stri
}
if
len
(
loop
)
!=
0
{
// The volume was successfully detached from node. We can safely remove the loopback.
err
=
volume
util
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
err
=
volume
pathhandler
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"fc: failed to remove loopback :%v, err: %v"
,
loop
,
err
)
}
...
...
pkg/volume/flexvolume/plugin.go
View file @
f737ad62
...
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/utils/exec"
)
...
...
@@ -103,7 +104,7 @@ func (plugin *flexVolumePlugin) getExecutable() string {
execName
:=
parts
[
len
(
parts
)
-
1
]
execPath
:=
path
.
Join
(
plugin
.
execPath
,
execName
)
if
runtime
.
GOOS
==
"windows"
{
execPath
=
volume
.
GetWindowsPath
(
execPath
)
execPath
=
util
.
GetWindowsPath
(
execPath
)
}
return
execPath
}
...
...
pkg/volume/flocker/flocker_util.go
View file @
f737ad62
...
...
@@ -22,7 +22,8 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
flockerapi
"github.com/clusterhq/flocker-go"
"github.com/golang/glog"
...
...
@@ -73,7 +74,7 @@ func (util *FlockerUtil) CreateVolume(c *flockerVolumeProvisioner) (datasetUUID
capacity
:=
c
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestBytes
:=
capacity
.
Value
()
volumeSizeGB
=
int
(
volu
me
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
volumeSizeGB
=
int
(
volu
til
.
RoundUpSize
(
requestBytes
,
1024
*
1024
*
1024
))
createOptions
:=
&
flockerapi
.
CreateDatasetOptions
{
MaximumSize
:
requestBytes
,
...
...
pkg/volume/flocker/flocker_volume.go
View file @
f737ad62
...
...
@@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
type
volumeManager
interface
{
...
...
@@ -55,7 +55,7 @@ type flockerVolumeProvisioner struct {
var
_
volume
.
Provisioner
=
&
flockerVolumeProvisioner
{}
func
(
c
*
flockerVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -77,7 +77,7 @@ func (c *flockerVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
c
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"flocker-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"flocker-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/gce_pd/attacher.go
View file @
f737ad62
...
...
@@ -32,7 +32,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
gcePersistentDiskAttacher
struct
{
...
...
@@ -209,8 +208,8 @@ func (attacher *gcePersistentDiskAttacher) MountDevice(spec *volume.Spec, device
options
=
append
(
options
,
"ro"
)
}
if
notMnt
{
diskMounter
:=
volume
helper
.
NewSafeFormatAndMountFromHost
(
gcePersistentDiskPluginName
,
attacher
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
diskMounter
:=
volume
util
.
NewSafeFormatAndMountFromHost
(
gcePersistentDiskPluginName
,
attacher
.
host
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
f737ad62
...
...
@@ -31,7 +31,6 @@ import (
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -398,7 +397,7 @@ type gcePersistentDiskProvisioner struct {
var
_
volume
.
Provisioner
=
&
gcePersistentDiskProvisioner
{}
func
(
c
*
gcePersistentDiskProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -416,7 +415,7 @@ func (c *gcePersistentDiskProvisioner) Provision() (*v1.PersistentVolume, error)
Name
:
c
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"gce-pd-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"gce-pd-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/gce_pd/gce_pd_block.go
View file @
f737ad62
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util
/volumepathhandler
"
)
var
_
volume
.
VolumePlugin
=
&
gcePersistentDiskPlugin
{}
...
...
@@ -40,7 +40,7 @@ var _ volume.ExpandableVolumePlugin = &gcePersistentDiskPlugin{}
func
(
plugin
*
gcePersistentDiskPlugin
)
ConstructBlockVolumeSpec
(
podUID
types
.
UID
,
volumeName
,
mapPath
string
)
(
*
volume
.
Spec
,
error
)
{
pluginDir
:=
plugin
.
host
.
GetVolumeDevicePluginDir
(
gcePersistentDiskPluginName
)
blkutil
:=
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
globalMapPathUUID
,
err
:=
blkutil
.
FindGlobalMapPathUUIDFromPod
(
pluginDir
,
mapPath
,
podUID
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/volume/gce_pd/gce_pd_test.go
View file @
f737ad62
...
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumetest
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util"
)
func
TestCanSupport
(
t
*
testing
.
T
)
{
...
...
@@ -176,7 +177,7 @@ func TestPlugin(t *testing.T) {
}
cap
:=
persistentSpec
.
Spec
.
Capacity
[
v1
.
ResourceStorage
]
size
:=
cap
.
Value
()
if
size
!=
100
*
volume
.
GB
{
if
size
!=
100
*
util
.
GB
{
t
.
Errorf
(
"Provision() returned unexpected volume size: %v"
,
size
)
}
...
...
pkg/volume/gce_pd/gce_util.go
View file @
f737ad62
...
...
@@ -82,10 +82,10 @@ func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner) (strin
return
""
,
0
,
nil
,
""
,
err
}
name
:=
volume
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
63
)
// GCE PD name can have up to 63 characters
name
:=
volume
util
.
GenerateVolumeName
(
c
.
options
.
ClusterName
,
c
.
options
.
PVName
,
63
)
// GCE PD name can have up to 63 characters
capacity
:=
c
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
// GCE PDs are allocated in chunks of GBs (not GiBs)
requestGB
:=
volume
.
RoundUpToGB
(
capacity
)
requestGB
:=
volume
util
.
RoundUpToGB
(
capacity
)
// Apply Parameters.
// Values for parameter "replication-type" are canonicalized to lower case.
...
...
@@ -169,13 +169,13 @@ func (gceutil *GCEDiskUtil) CreateVolume(c *gcePersistentDiskProvisioner) (strin
}
else
if
zonePresent
&&
!
zonesPresent
{
// 10 - "zone" specified
// Use specified zone
if
err
:=
volume
.
ValidateZone
(
configuredZone
);
err
!=
nil
{
if
err
:=
volume
util
.
ValidateZone
(
configuredZone
);
err
!=
nil
{
return
""
,
0
,
nil
,
""
,
err
}
zones
=
make
(
sets
.
String
)
zones
.
Insert
(
configuredZone
)
}
zone
:=
volume
.
ChooseZoneForVolume
(
zones
,
c
.
options
.
PVC
.
Name
)
zone
:=
volume
util
.
ChooseZoneForVolume
(
zones
,
c
.
options
.
PVC
.
Name
)
if
err
:=
cloud
.
CreateDisk
(
name
,
...
...
@@ -237,7 +237,7 @@ func createRegionalPD(
selectedReplicaZones
=
replicaZones
}
else
{
// Must randomly select zones
selectedReplicaZones
=
volume
.
ChooseZonesForVolume
(
selectedReplicaZones
=
volume
util
.
ChooseZonesForVolume
(
replicaZones
,
pvcName
,
maxRegionalPDZones
)
}
...
...
pkg/volume/git_repo/git_repo.go
View file @
f737ad62
...
...
@@ -264,7 +264,7 @@ func (c *gitRepoVolumeUnmounter) TearDown() error {
// TearDownAt simply deletes everything in the directory.
func
(
c
*
gitRepoVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
volume
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
return
volume
util
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
}
func
getVolumeSource
(
spec
*
volume
.
Spec
)
(
*
v1
.
GitRepoVolumeSource
,
bool
)
{
...
...
pkg/volume/glusterfs/glusterfs.go
View file @
f737ad62
...
...
@@ -43,7 +43,6 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
...
...
@@ -178,7 +177,7 @@ func (plugin *glusterfsPlugin) newMounterInternal(spec *volume.Spec, ep *v1.Endp
hosts
:
ep
,
path
:
source
.
Path
,
readOnly
:
readOnly
,
mountOptions
:
volu
me
.
MountOptionFromSpec
(
spec
),
mountOptions
:
volu
til
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -328,7 +327,7 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error {
}
options
=
append
(
options
,
"backup-volfile-servers="
+
dstrings
.
Join
(
addrlist
[
:
],
":"
))
mountOptions
:=
volu
me
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
:=
volu
til
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
// with `backup-volfile-servers` mount option in place, it is not required to
// iterate over all the servers in the addrlist. A mount attempt with this option
...
...
@@ -502,7 +501,7 @@ func (plugin *glusterfsPlugin) collectGids(className string, gidTable *MinMaxAll
pvName
:=
pv
.
ObjectMeta
.
Name
gidStr
,
ok
:=
pv
.
Annotations
[
volu
mehelper
.
VolumeGidAnnotationKey
]
gidStr
,
ok
:=
pv
.
Annotations
[
volu
til
.
VolumeGidAnnotationKey
]
if
!
ok
{
glog
.
Warningf
(
"no GID found in pv %v"
,
pvName
)
...
...
@@ -583,7 +582,7 @@ func (plugin *glusterfsPlugin) getGidTable(className string, min int, max int) (
}
func
(
d
*
glusterfsVolumeDeleter
)
getGid
()
(
int
,
bool
,
error
)
{
gidStr
,
ok
:=
d
.
spec
.
Annotations
[
volu
mehelper
.
VolumeGidAnnotationKey
]
gidStr
,
ok
:=
d
.
spec
.
Annotations
[
volu
til
.
VolumeGidAnnotationKey
]
if
!
ok
{
return
0
,
false
,
nil
...
...
@@ -669,7 +668,7 @@ func (d *glusterfsVolumeDeleter) Delete() error {
}
func
(
p
*
glusterfsVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volu
me
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
volu
til
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
p
.
options
.
PVC
.
Spec
.
AccessModes
,
p
.
plugin
.
GetAccessModes
())
}
...
...
@@ -723,12 +722,12 @@ func (p *glusterfsVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
gidStr
:=
strconv
.
FormatInt
(
int64
(
gid
),
10
)
pv
.
Annotations
=
map
[
string
]
string
{
volu
mehelper
.
VolumeGidAnnotationKey
:
gidStr
,
volu
mehelper
.
VolumeDynamicallyCreatedByKey
:
heketiAnn
,
glusterTypeAnn
:
"file"
,
"Description"
:
glusterDescAnn
,
v1
.
MountOptionAnnotation
:
"auto_unmount"
,
heketiVolIDAnn
:
volID
,
volu
til
.
VolumeGidAnnotationKey
:
gidStr
,
volu
til
.
VolumeDynamicallyCreatedByKey
:
heketiAnn
,
glusterTypeAnn
:
"file"
,
"Description"
:
glusterDescAnn
,
v1
.
MountOptionAnnotation
:
"auto_unmount"
,
heketiVolIDAnn
:
volID
,
}
pv
.
Spec
.
Capacity
=
v1
.
ResourceList
{
...
...
@@ -743,8 +742,9 @@ func (p *glusterfsVolumeProvisioner) CreateVolume(gid int) (r *v1.GlusterfsVolum
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
// GlusterFS/heketi creates volumes in units of GiB.
sz
:=
int
(
volu
me
.
RoundUpToGiB
(
capacity
))
sz
:=
int
(
volu
til
.
RoundUpToGiB
(
capacity
))
glog
.
V
(
2
)
.
Infof
(
"create volume of size %dGiB"
,
sz
)
if
p
.
url
==
""
{
glog
.
Errorf
(
"REST server endpoint is empty"
)
return
nil
,
0
,
""
,
fmt
.
Errorf
(
"failed to create glusterfs REST client, REST URL is empty"
)
...
...
@@ -1126,10 +1126,10 @@ func (plugin *glusterfsPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize res
// Find out delta size
expansionSize
:=
(
newSize
.
Value
()
-
oldSize
.
Value
())
expansionSizeGiB
:=
int
(
volu
me
.
RoundUpSize
(
expansionSize
,
volume
.
GIB
))
expansionSizeGiB
:=
int
(
volu
til
.
RoundUpSize
(
expansionSize
,
volutil
.
GIB
))
// Find out requested Size
requestGiB
:=
volu
me
.
RoundUpToGiB
(
newSize
)
requestGiB
:=
volu
til
.
RoundUpToGiB
(
newSize
)
//Check the existing volume size
currentVolumeInfo
,
err
:=
cli
.
VolumeInfo
(
volumeID
)
...
...
pkg/volume/host_path/host_path.go
View file @
f737ad62
...
...
@@ -27,7 +27,8 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
"k8s.io/kubernetes/pkg/volume/validation"
)
...
...
@@ -129,13 +130,13 @@ func (plugin *hostPathPlugin) NewUnmounter(volName string, podUID types.UID) (vo
// Recycle recycles/scrubs clean a HostPath volume.
// Recycle blocks until the pod has completed or any error occurs.
// HostPath recycling only works in single node clusters and is meant for testing purposes only.
func
(
plugin
*
hostPathPlugin
)
Recycle
(
pvName
string
,
spec
*
volume
.
Spec
,
eventRecorder
volume
.
RecycleEventRecorder
)
error
{
func
(
plugin
*
hostPathPlugin
)
Recycle
(
pvName
string
,
spec
*
volume
.
Spec
,
eventRecorder
recyclerclient
.
RecycleEventRecorder
)
error
{
if
spec
.
PersistentVolume
==
nil
||
spec
.
PersistentVolume
.
Spec
.
HostPath
==
nil
{
return
fmt
.
Errorf
(
"spec.PersistentVolumeSource.HostPath is nil"
)
}
pod
:=
plugin
.
config
.
RecyclerPodTemplate
timeout
:=
volume
.
CalculateTimeoutForVolume
(
plugin
.
config
.
RecyclerMinimumTimeout
,
plugin
.
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
)
timeout
:=
util
.
CalculateTimeoutForVolume
(
plugin
.
config
.
RecyclerMinimumTimeout
,
plugin
.
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
)
// overrides
pod
.
Spec
.
ActiveDeadlineSeconds
=
&
timeout
pod
.
Spec
.
Volumes
[
0
]
.
VolumeSource
=
v1
.
VolumeSource
{
...
...
@@ -143,7 +144,7 @@ func (plugin *hostPathPlugin) Recycle(pvName string, spec *volume.Spec, eventRec
Path
:
spec
.
PersistentVolume
.
Spec
.
HostPath
.
Path
,
},
}
return
volume
.
RecycleVolumeByWatchingPodUntilCompletion
(
pvName
,
pod
,
plugin
.
host
.
GetKubeClient
(),
eventRecorder
)
return
recyclerclient
.
RecycleVolumeByWatchingPodUntilCompletion
(
pvName
,
pod
,
plugin
.
host
.
GetKubeClient
(),
eventRecorder
)
}
func
(
plugin
*
hostPathPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
...
...
@@ -272,7 +273,7 @@ func (r *hostPathProvisioner) Provision() (*v1.PersistentVolume, error) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
r
.
options
.
PVName
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"hostpath-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"hostpath-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/iscsi/attacher.go
View file @
f737ad62
...
...
@@ -29,7 +29,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
iscsiAttacher
struct
{
...
...
@@ -113,7 +112,7 @@ func (attacher *iscsiAttacher) MountDevice(spec *volume.Spec, devicePath string,
}
if
notMnt
{
diskMounter
:=
&
mount
.
SafeFormatAndMount
{
Interface
:
mounter
,
Exec
:
attacher
.
host
.
GetExec
(
iscsiPluginName
)}
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
fsType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
@@ -184,7 +183,7 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost, pod *v1.Pod)
exec
:=
host
.
GetExec
(
iscsiPluginName
)
// TODO: remove feature gate check after no longer needed
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
volumeMode
,
err
:=
volume
helper
.
GetVolumeMode
(
spec
)
volumeMode
,
err
:=
volume
util
.
GetVolumeMode
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/volume/iscsi/disk_manager.go
View file @
f737ad62
...
...
@@ -22,6 +22,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// Abstract interface to disk operations.
...
...
@@ -63,7 +64,7 @@ func diskSetUp(manager diskManager, b iscsiDiskMounter, volPath string, mounter
b
.
iscsiDisk
.
Iface
=
b
.
iscsiDisk
.
Portals
[
0
]
+
":"
+
b
.
iscsiDisk
.
VolName
}
globalPDPath
:=
manager
.
MakeGlobalPDName
(
*
b
.
iscsiDisk
)
mountOptions
:=
volume
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
:=
util
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
err
=
mounter
.
Mount
(
globalPDPath
,
volPath
,
""
,
mountOptions
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to bind mount: source:%s, target:%s, err:%v"
,
globalPDPath
,
volPath
,
err
)
...
...
pkg/volume/iscsi/iscsi.go
View file @
f737ad62
...
...
@@ -31,6 +31,7 @@ import (
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
ioutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -118,7 +119,7 @@ func (plugin *iscsiPlugin) newMounterInternal(spec *volume.Spec, podUID types.UI
mounter
:
&
mount
.
SafeFormatAndMount
{
Interface
:
mounter
,
Exec
:
exec
},
exec
:
exec
,
deviceUtil
:
ioutil
.
NewDeviceHandler
(
ioutil
.
NewIOHandler
()),
mountOptions
:
volume
.
MountOptionFromSpec
(
spec
),
mountOptions
:
ioutil
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -235,7 +236,7 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
func
(
plugin
*
iscsiPlugin
)
ConstructBlockVolumeSpec
(
podUID
types
.
UID
,
volumeName
,
mapPath
string
)
(
*
volume
.
Spec
,
error
)
{
pluginDir
:=
plugin
.
host
.
GetVolumeDevicePluginDir
(
iscsiPluginName
)
blkutil
:=
ioutil
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
globalMapPathUUID
,
err
:=
blkutil
.
FindGlobalMapPathUUIDFromPod
(
pluginDir
,
mapPath
,
podUID
)
if
err
!=
nil
{
return
nil
,
err
...
...
pkg/volume/iscsi/iscsi_util.go
View file @
f737ad62
...
...
@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
var
(
...
...
@@ -518,10 +519,10 @@ func (util *ISCSIUtil) DetachBlockISCSIDisk(c iscsiDiskUnmapper, mapPath string)
// GenerateUnmapDeviceFunc() in operation_generator. As a result, these plugins fail to get
// and remove loopback device then it will be remained on kubelet node. To avoid the problem,
// local attach plugins needs to remove loopback device during TearDownDevice().
blkUtil
:=
volume
util
.
NewBlockVolumePathHandler
()
loop
,
err
:=
volume
util
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
devicePath
)
blkUtil
:=
volume
pathhandler
.
NewBlockVolumePathHandler
()
loop
,
err
:=
volume
pathhandler
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
devicePath
)
if
err
!=
nil
{
if
err
.
Error
()
!=
volume
util
.
ErrDeviceNotFound
{
if
err
.
Error
()
!=
volume
pathhandler
.
ErrDeviceNotFound
{
return
fmt
.
Errorf
(
"failed to get loopback for device: %v, err: %v"
,
devicePath
,
err
)
}
glog
.
Warning
(
"iscsi: loopback for device: %s not found"
,
device
)
...
...
@@ -533,7 +534,7 @@ func (util *ISCSIUtil) DetachBlockISCSIDisk(c iscsiDiskUnmapper, mapPath string)
}
if
len
(
loop
)
!=
0
{
// The volume was successfully detached from node. We can safely remove the loopback.
err
=
volume
util
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
err
=
volume
pathhandler
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to remove loopback :%v, err: %v"
,
loop
,
err
)
}
...
...
pkg/volume/metrics_du.go
View file @
f737ad62
...
...
@@ -19,7 +19,7 @@ package volume
import
(
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util
/fs
"
)
var
_
MetricsProvider
=
&
metricsDu
{}
...
...
@@ -66,7 +66,7 @@ func (md *metricsDu) GetMetrics() (*Metrics, error) {
// runDu executes the "du" command and writes the results to metrics.Used
func
(
md
*
metricsDu
)
runDu
(
metrics
*
Metrics
)
error
{
used
,
err
:=
util
.
Du
(
md
.
path
)
used
,
err
:=
fs
.
Du
(
md
.
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -76,7 +76,7 @@ func (md *metricsDu) runDu(metrics *Metrics) error {
// runFind executes the "find" command and writes the results to metrics.InodesUsed
func
(
md
*
metricsDu
)
runFind
(
metrics
*
Metrics
)
error
{
inodesUsed
,
err
:=
util
.
Find
(
md
.
path
)
inodesUsed
,
err
:=
fs
.
Find
(
md
.
path
)
if
err
!=
nil
{
return
err
}
...
...
@@ -87,7 +87,7 @@ func (md *metricsDu) runFind(metrics *Metrics) error {
// getFsInfo writes metrics.Capacity and metrics.Available from the filesystem
// info
func
(
md
*
metricsDu
)
getFsInfo
(
metrics
*
Metrics
)
error
{
available
,
capacity
,
_
,
inodes
,
inodesFree
,
_
,
err
:=
util
.
FsInfo
(
md
.
path
)
available
,
capacity
,
_
,
inodes
,
inodesFree
,
_
,
err
:=
fs
.
FsInfo
(
md
.
path
)
if
err
!=
nil
{
return
NewFsInfoFailedError
(
err
)
}
...
...
pkg/volume/metrics_statfs.go
View file @
f737ad62
...
...
@@ -19,7 +19,7 @@ package volume
import
(
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util
/fs
"
)
var
_
MetricsProvider
=
&
metricsStatFS
{}
...
...
@@ -55,7 +55,7 @@ func (md *metricsStatFS) GetMetrics() (*Metrics, error) {
// 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
:=
util
.
FsInfo
(
md
.
path
)
available
,
capacity
,
usage
,
inodes
,
inodesFree
,
inodesUsed
,
err
:=
fs
.
FsInfo
(
md
.
path
)
if
err
!=
nil
{
return
NewFsInfoFailedError
(
err
)
}
...
...
pkg/volume/nfs/nfs.go
View file @
f737ad62
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -123,7 +124,7 @@ func (plugin *nfsPlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod, moun
server
:
source
.
Server
,
exportPath
:
source
.
Path
,
readOnly
:
readOnly
,
mountOptions
:
volume
.
MountOptionFromSpec
(
spec
),
mountOptions
:
util
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -142,13 +143,13 @@ func (plugin *nfsPlugin) newUnmounterInternal(volName string, podUID types.UID,
// Recycle recycles/scrubs clean an NFS volume.
// Recycle blocks until the pod has completed or any error occurs.
func
(
plugin
*
nfsPlugin
)
Recycle
(
pvName
string
,
spec
*
volume
.
Spec
,
eventRecorder
volume
.
RecycleEventRecorder
)
error
{
func
(
plugin
*
nfsPlugin
)
Recycle
(
pvName
string
,
spec
*
volume
.
Spec
,
eventRecorder
recyclerclient
.
RecycleEventRecorder
)
error
{
if
spec
.
PersistentVolume
==
nil
||
spec
.
PersistentVolume
.
Spec
.
NFS
==
nil
{
return
fmt
.
Errorf
(
"spec.PersistentVolumeSource.NFS is nil"
)
}
pod
:=
plugin
.
config
.
RecyclerPodTemplate
timeout
:=
volume
.
CalculateTimeoutForVolume
(
plugin
.
config
.
RecyclerMinimumTimeout
,
plugin
.
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
)
timeout
:=
util
.
CalculateTimeoutForVolume
(
plugin
.
config
.
RecyclerMinimumTimeout
,
plugin
.
config
.
RecyclerTimeoutIncrement
,
spec
.
PersistentVolume
)
// overrides
pod
.
Spec
.
ActiveDeadlineSeconds
=
&
timeout
pod
.
GenerateName
=
"pv-recycler-nfs-"
...
...
@@ -158,7 +159,7 @@ func (plugin *nfsPlugin) Recycle(pvName string, spec *volume.Spec, eventRecorder
Path
:
spec
.
PersistentVolume
.
Spec
.
NFS
.
Path
,
},
}
return
volume
.
RecycleVolumeByWatchingPodUntilCompletion
(
pvName
,
pod
,
plugin
.
host
.
GetKubeClient
(),
eventRecorder
)
return
recyclerclient
.
RecycleVolumeByWatchingPodUntilCompletion
(
pvName
,
pod
,
plugin
.
host
.
GetKubeClient
(),
eventRecorder
)
}
func
(
plugin
*
nfsPlugin
)
ConstructVolumeSpec
(
volumeName
,
mountPath
string
)
(
*
volume
.
Spec
,
error
)
{
...
...
@@ -249,7 +250,7 @@ func (b *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
}
mountOptions
:=
volume
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
:=
util
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
err
=
b
.
mounter
.
Mount
(
source
,
dir
,
"nfs"
,
mountOptions
)
if
err
!=
nil
{
notMnt
,
mntErr
:=
b
.
mounter
.
IsNotMountPoint
(
dir
)
...
...
pkg/volume/photon_pd/attacher.go
View file @
f737ad62
...
...
@@ -32,7 +32,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
photonPersistentDiskAttacher
struct
{
...
...
@@ -211,8 +210,8 @@ func (attacher *photonPersistentDiskAttacher) MountDevice(spec *volume.Spec, dev
options
:=
[]
string
{}
if
notMnt
{
diskMounter
:=
volume
helper
.
NewSafeFormatAndMountFromHost
(
photonPersistentDiskPluginName
,
attacher
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
)
diskMounter
:=
volume
util
.
NewSafeFormatAndMountFromHost
(
photonPersistentDiskPluginName
,
attacher
.
host
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/photon_pd/photon_pd.go
View file @
f737ad62
...
...
@@ -30,7 +30,6 @@ import (
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -115,7 +114,7 @@ func (plugin *photonPersistentDiskPlugin) newMounterInternal(spec *volume.Spec,
plugin
:
plugin
,
},
fsType
:
fsType
,
diskMounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
diskMounter
:
util
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
}
func
(
plugin
*
photonPersistentDiskPlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
pdManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -342,7 +341,7 @@ func (plugin *photonPersistentDiskPlugin) newProvisionerInternal(options volume.
}
func
(
p
*
photonPersistentDiskProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
p
.
plugin
.
GetAccessModes
(),
p
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
p
.
options
.
PVC
.
Spec
.
AccessModes
,
p
.
plugin
.
GetAccessModes
())
}
...
...
@@ -360,7 +359,7 @@ func (p *photonPersistentDiskProvisioner) Provision() (*v1.PersistentVolume, err
Name
:
p
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"photon-volume-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"photon-volume-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/photon_pd/photon_util.go
View file @
f737ad62
...
...
@@ -90,8 +90,8 @@ func (util *PhotonDiskUtil) CreateVolume(p *photonPersistentDiskProvisioner) (pd
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
(
volume
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
name
:=
volume
.
GenerateVolumeName
(
p
.
options
.
ClusterName
,
p
.
options
.
PVName
,
255
)
volSizeGB
:=
int
(
volume
util
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
*
1024
))
name
:=
volume
util
.
GenerateVolumeName
(
p
.
options
.
ClusterName
,
p
.
options
.
PVName
,
255
)
volumeOptions
:=
&
photon
.
VolumeOptions
{
CapacityGB
:
volSizeGB
,
Tags
:
*
p
.
options
.
CloudTags
,
...
...
pkg/volume/plugins.go
View file @
f737ad62
...
...
@@ -33,6 +33,7 @@ import (
"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
(
...
...
@@ -161,7 +162,7 @@ type RecyclableVolumePlugin interface {
// 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
RecycleEventRecorder
)
error
Recycle
(
pvName
string
,
spec
*
Spec
,
eventRecorder
recyclerclient
.
RecycleEventRecorder
)
error
}
// DeletableVolumePlugin is an extended interface of VolumePlugin and is used
...
...
pkg/volume/portworx/portworx.go
View file @
f737ad62
...
...
@@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
)
const
(
...
...
@@ -119,7 +119,7 @@ func (plugin *portworxVolumePlugin) newMounterInternal(spec *volume.Spec, podUID
},
fsType
:
fsType
,
readOnly
:
readOnly
,
diskMounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
diskMounter
:
util
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
}
func
(
plugin
*
portworxVolumePlugin
)
NewUnmounter
(
volName
string
,
podUID
types
.
UID
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -358,7 +358,7 @@ type portworxVolumeProvisioner struct {
var
_
volume
.
Provisioner
=
&
portworxVolumeProvisioner
{}
func
(
c
*
portworxVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -372,7 +372,7 @@ func (c *portworxVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
c
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"portworx-volume-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"portworx-volume-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/portworx/portworx_util.go
View file @
f737ad62
...
...
@@ -27,6 +27,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
)
const
(
...
...
@@ -55,7 +56,7 @@ func (util *PortworxVolumeUtil) CreateVolume(p *portworxVolumeProvisioner) (stri
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
// Portworx Volumes are specified in GB
requestGB
:=
int
(
volu
me
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
requestGB
:=
int
(
volu
til
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
// Perform a best-effort parsing of parameters. Portworx 1.2.9 and later parses volume parameters from
// spec.VolumeLabels. So even if below SpecFromOpts() fails to parse certain parameters or
...
...
pkg/volume/quobyte/quobyte.go
View file @
f737ad62
...
...
@@ -32,7 +32,6 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
...
...
@@ -176,7 +175,7 @@ func (plugin *quobytePlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod,
},
registry
:
source
.
Registry
,
readOnly
:
readOnly
,
mountOptions
:
volume
.
MountOptionFromSpec
(
spec
),
mountOptions
:
util
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -256,7 +255,7 @@ func (mounter *quobyteMounter) SetUpAt(dir string, fsGroup *int64) error {
}
//if a trailing slash is missing we add it here
mountOptions
:=
volume
.
JoinMountOptions
(
mounter
.
mountOptions
,
options
)
mountOptions
:=
util
.
JoinMountOptions
(
mounter
.
mountOptions
,
options
)
if
err
:=
mounter
.
mounter
.
Mount
(
mounter
.
correctTraillingSlash
(
mounter
.
registry
),
dir
,
"quobyte"
,
mountOptions
);
err
!=
nil
{
return
fmt
.
Errorf
(
"quobyte: mount failed: %v"
,
err
)
}
...
...
@@ -356,7 +355,7 @@ type quobyteVolumeProvisioner struct {
}
func
(
provisioner
*
quobyteVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
provisioner
.
plugin
.
GetAccessModes
(),
provisioner
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
provisioner
.
plugin
.
GetAccessModes
(),
provisioner
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
provisioner
.
options
.
PVC
.
Spec
.
AccessModes
,
provisioner
.
plugin
.
GetAccessModes
())
}
...
...
@@ -410,7 +409,7 @@ func (provisioner *quobyteVolumeProvisioner) Provision() (*v1.PersistentVolume,
return
nil
,
err
}
pv
:=
new
(
v1
.
PersistentVolume
)
metav1
.
SetMetaDataAnnotation
(
&
pv
.
ObjectMeta
,
volumehelper
.
VolumeDynamicallyCreatedByKey
,
"quobyte-dynamic-provisioner"
)
metav1
.
SetMetaDataAnnotation
(
&
pv
.
ObjectMeta
,
util
.
VolumeDynamicallyCreatedByKey
,
"quobyte-dynamic-provisioner"
)
pv
.
Spec
.
PersistentVolumeSource
.
Quobyte
=
vol
pv
.
Spec
.
PersistentVolumeReclaimPolicy
=
provisioner
.
options
.
PersistentVolumeReclaimPolicy
pv
.
Spec
.
AccessModes
=
provisioner
.
options
.
PVC
.
Spec
.
AccessModes
...
...
pkg/volume/quobyte/quobyte_util.go
View file @
f737ad62
...
...
@@ -22,7 +22,7 @@ import (
"strings"
"k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume
/util
"
"github.com/golang/glog"
quobyteapi
"github.com/quobyte/api"
...
...
@@ -34,7 +34,7 @@ type quobyteVolumeManager struct {
func
(
manager
*
quobyteVolumeManager
)
createVolume
(
provisioner
*
quobyteVolumeProvisioner
,
createQuota
bool
)
(
quobyte
*
v1
.
QuobyteVolumeSource
,
size
int
,
err
error
)
{
capacity
:=
provisioner
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
volumeSize
:=
int
(
volume
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
volumeSize
:=
int
(
util
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
// Quobyte has the concept of Volumes which doen't have a specific size (they can grow unlimited)
// to simulate a size constraint we set here a Quota for logical space
volumeRequest
:=
&
quobyteapi
.
CreateVolumeRequest
{
...
...
pkg/volume/rbd/attacher.go
View file @
f737ad62
...
...
@@ -27,7 +27,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// NewAttacher implements AttachableVolumePlugin.NewAttacher.
...
...
@@ -39,7 +38,7 @@ func (plugin *rbdPlugin) newAttacherInternal(manager diskManager) (volume.Attach
return
&
rbdAttacher
{
plugin
:
plugin
,
manager
:
manager
,
mounter
:
volu
mehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
mounter
:
volu
til
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
},
nil
}
...
...
@@ -52,7 +51,7 @@ func (plugin *rbdPlugin) newDetacherInternal(manager diskManager) (volume.Detach
return
&
rbdDetacher
{
plugin
:
plugin
,
manager
:
manager
,
mounter
:
volu
mehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
mounter
:
volu
til
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
},
nil
}
...
...
@@ -154,7 +153,7 @@ func (attacher *rbdAttacher) MountDevice(spec *volume.Spec, devicePath string, d
if
ro
{
options
=
append
(
options
,
"ro"
)
}
mountOptions
:=
volu
me
.
MountOptionFromSpec
(
spec
,
options
...
)
mountOptions
:=
volu
til
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
attacher
.
mounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
fstype
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/rbd/disk_manager.go
View file @
f737ad62
...
...
@@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// Abstract interface to disk operations.
...
...
@@ -85,7 +86,7 @@ func diskSetUp(manager diskManager, b rbdMounter, volPath string, mounter mount.
if
(
&
b
)
.
GetAttributes
()
.
ReadOnly
{
options
=
append
(
options
,
"ro"
)
}
mountOptions
:=
volume
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
:=
util
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
err
=
mounter
.
Mount
(
globalPDPath
,
volPath
,
""
,
mountOptions
)
if
err
!=
nil
{
glog
.
Errorf
(
"failed to bind mount:%s"
,
globalPDPath
)
...
...
pkg/volume/rbd/rbd.go
View file @
f737ad62
...
...
@@ -35,7 +35,7 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
volutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
var
(
...
...
@@ -327,7 +327,7 @@ func (plugin *rbdPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID,
Keyring
:
keyring
,
Secret
:
secret
,
fsType
:
fstype
,
mountOptions
:
volu
me
.
MountOptionFromSpec
(
spec
),
mountOptions
:
volu
til
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -389,7 +389,7 @@ func (plugin *rbdPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*vol
func
(
plugin
*
rbdPlugin
)
ConstructBlockVolumeSpec
(
podUID
types
.
UID
,
volumeName
,
mapPath
string
)
(
*
volume
.
Spec
,
error
)
{
pluginDir
:=
plugin
.
host
.
GetVolumeDevicePluginDir
(
rbdPluginName
)
blkutil
:=
volu
til
.
NewBlockVolumePathHandler
()
blkutil
:=
volu
mepathhandler
.
NewBlockVolumePathHandler
()
globalMapPathUUID
,
err
:=
blkutil
.
FindGlobalMapPathUUIDFromPod
(
pluginDir
,
mapPath
,
podUID
)
if
err
!=
nil
{
...
...
@@ -569,7 +569,7 @@ type rbdVolumeProvisioner struct {
var
_
volume
.
Provisioner
=
&
rbdVolumeProvisioner
{}
func
(
r
*
rbdVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volu
me
.
AccessModesContainedInAll
(
r
.
plugin
.
GetAccessModes
(),
r
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
volu
til
.
AccessModesContainedInAll
(
r
.
plugin
.
GetAccessModes
(),
r
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
r
.
options
.
PVC
.
Spec
.
AccessModes
,
r
.
plugin
.
GetAccessModes
())
}
...
...
@@ -665,7 +665,7 @@ func (r *rbdVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
}
glog
.
Infof
(
"successfully created rbd image %q"
,
image
)
pv
:=
new
(
v1
.
PersistentVolume
)
metav1
.
SetMetaDataAnnotation
(
&
pv
.
ObjectMeta
,
volu
mehelper
.
VolumeDynamicallyCreatedByKey
,
"rbd-dynamic-provisioner"
)
metav1
.
SetMetaDataAnnotation
(
&
pv
.
ObjectMeta
,
volu
til
.
VolumeDynamicallyCreatedByKey
,
"rbd-dynamic-provisioner"
)
if
secretName
!=
""
{
rbd
.
SecretRef
=
new
(
v1
.
SecretReference
)
...
...
@@ -741,7 +741,7 @@ func newRBD(podUID types.UID, volName string, image string, pool string, readOnl
Pool
:
pool
,
ReadOnly
:
readOnly
,
plugin
:
plugin
,
mounter
:
volu
mehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
mounter
:
volu
til
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
),
exec
:
plugin
.
host
.
GetExec
(
plugin
.
GetPluginName
()),
manager
:
manager
,
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
volName
,
plugin
.
host
)),
...
...
@@ -937,13 +937,13 @@ func (rbd *rbdDiskUnmapper) TearDownDevice(mapPath, _ string) error {
// GenerateUnmapDeviceFunc() in operation_generator. As a result, these plugins fail to get
// and remove loopback device then it will be remained on kubelet node. To avoid the problem,
// local attach plugins needs to remove loopback device during TearDownDevice().
blkUtil
:=
volu
til
.
NewBlockVolumePathHandler
()
loop
,
err
:=
volu
til
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
device
)
blkUtil
:=
volu
mepathhandler
.
NewBlockVolumePathHandler
()
loop
,
err
:=
volu
mepathhandler
.
BlockVolumePathHandler
.
GetLoopDevice
(
blkUtil
,
device
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rbd: failed to get loopback for device: %v, err: %v"
,
device
,
err
)
}
// Remove loop device before detaching volume since volume detach operation gets busy if volume is opened by loopback.
err
=
volu
til
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
err
=
volu
mepathhandler
.
BlockVolumePathHandler
.
RemoveLoopDevice
(
blkUtil
,
loop
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"rbd: failed to remove loopback :%v, err: %v"
,
loop
,
err
)
}
...
...
pkg/volume/rbd/rbd_util.go
View file @
f737ad62
...
...
@@ -563,7 +563,7 @@ func (util *RBDUtil) CreateImage(p *rbdVolumeProvisioner) (r *v1.RBDPersistentVo
capacity
:=
p
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
volSizeBytes
:=
capacity
.
Value
()
// Convert to MB that rbd defaults on.
sz
:=
int
(
volu
me
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
))
sz
:=
int
(
volu
til
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
))
volSz
:=
fmt
.
Sprintf
(
"%d"
,
sz
)
mon
:=
util
.
kernelRBDMonitorsOpt
(
p
.
Mon
)
if
p
.
rbdMounter
.
imageFormat
==
rbdImageFormat2
{
...
...
@@ -621,7 +621,7 @@ func (util *RBDUtil) ExpandImage(rbdExpander *rbdVolumeExpander, oldSize resourc
var
err
error
volSizeBytes
:=
newSize
.
Value
()
// Convert to MB that rbd defaults on.
sz
:=
int
(
volu
me
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
))
sz
:=
int
(
volu
til
.
RoundUpSize
(
volSizeBytes
,
1024
*
1024
))
newVolSz
:=
fmt
.
Sprintf
(
"%d"
,
sz
)
newSizeQuant
:=
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dMi"
,
sz
))
...
...
pkg/volume/scaleio/sio_volume.go
View file @
f737ad62
...
...
@@ -33,7 +33,6 @@ import (
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
sioVolume
struct
{
...
...
@@ -142,7 +141,7 @@ func (v *sioVolume) SetUpAt(dir string, fsGroup *int64) error {
}
glog
.
V
(
4
)
.
Info
(
log
(
"setup created mount point directory %s"
,
dir
))
diskMounter
:=
volumehelper
.
NewSafeFormatAndMountFromHost
(
v
.
plugin
.
GetPluginName
(),
v
.
plugin
.
host
)
diskMounter
:=
util
.
NewSafeFormatAndMountFromHost
(
v
.
plugin
.
GetPluginName
(),
v
.
plugin
.
host
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
dir
,
v
.
fsType
,
options
)
if
err
!=
nil
{
...
...
@@ -256,7 +255,7 @@ var _ volume.Provisioner = &sioVolume{}
func
(
v
*
sioVolume
)
Provision
()
(
*
api
.
PersistentVolume
,
error
)
{
glog
.
V
(
4
)
.
Info
(
log
(
"attempting to dynamically provision pvc %v"
,
v
.
options
.
PVC
.
Name
))
if
!
volume
.
AccessModesContainedInAll
(
v
.
plugin
.
GetAccessModes
(),
v
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
v
.
plugin
.
GetAccessModes
(),
v
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
v
.
options
.
PVC
.
Spec
.
AccessModes
,
v
.
plugin
.
GetAccessModes
())
}
...
...
@@ -267,14 +266,14 @@ func (v *sioVolume) Provision() (*api.PersistentVolume, error) {
capacity
:=
v
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
api
.
ResourceName
(
api
.
ResourceStorage
)]
volSizeBytes
:=
capacity
.
Value
()
volSizeGB
:=
int64
(
volume
.
RoundUpSize
(
volSizeBytes
,
oneGig
))
volSizeGB
:=
int64
(
util
.
RoundUpSize
(
volSizeBytes
,
oneGig
))
if
volSizeBytes
==
0
{
return
nil
,
fmt
.
Errorf
(
"invalid volume size of 0 specified"
)
}
if
volSizeBytes
<
eightGig
{
volSizeGB
=
int64
(
volume
.
RoundUpSize
(
eightGig
,
oneGig
))
volSizeGB
=
int64
(
util
.
RoundUpSize
(
eightGig
,
oneGig
))
glog
.
V
(
4
)
.
Info
(
log
(
"capacity less than 8Gi found, adjusted to %dGi"
,
volSizeGB
))
}
...
...
@@ -314,7 +313,7 @@ func (v *sioVolume) Provision() (*api.PersistentVolume, error) {
Namespace
:
v
.
options
.
PVC
.
Namespace
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"scaleio-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"scaleio-dynamic-provisioner"
,
},
},
Spec
:
api
.
PersistentVolumeSpec
{
...
...
pkg/volume/secret/secret.go
View file @
f737ad62
...
...
@@ -303,7 +303,7 @@ func (c *secretVolumeUnmounter) TearDown() error {
}
func
(
c
*
secretVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
volume
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
return
volume
util
.
UnmountViaEmptyDir
(
dir
,
c
.
plugin
.
host
,
c
.
volName
,
wrappedVolumeSpec
(),
c
.
podUID
)
}
func
getVolumeSource
(
spec
*
volume
.
Spec
)
(
*
v1
.
SecretVolumeSource
,
bool
)
{
...
...
pkg/volume/storageos/storageos.go
View file @
f737ad62
...
...
@@ -35,7 +35,6 @@ import (
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// ProbeVolumePlugins is the primary entrypoint for volume plugins.
...
...
@@ -137,7 +136,7 @@ func (plugin *storageosPlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
pod
.
UID
,
volNamespace
,
volName
,
spec
.
Name
(),
plugin
.
host
)),
},
diskMounter
:
&
mount
.
SafeFormatAndMount
{
Interface
:
mounter
,
Exec
:
exec
},
mountOptions
:
volume
.
MountOptionFromSpec
(
spec
),
mountOptions
:
util
.
MountOptionFromSpec
(
spec
),
},
nil
}
...
...
@@ -389,7 +388,7 @@ func (b *storageosMounter) SetUpAt(dir string, fsGroup *int64) error {
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
}
mountOptions
:=
volume
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
:=
util
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
globalPDPath
:=
makeGlobalPDName
(
b
.
plugin
.
host
,
b
.
pvName
,
b
.
volNamespace
,
b
.
volName
)
glog
.
V
(
4
)
.
Infof
(
"Attempting to bind mount to pod volume at %s"
,
dir
)
...
...
@@ -562,7 +561,7 @@ type storageosProvisioner struct {
var
_
volume
.
Provisioner
=
&
storageosProvisioner
{}
func
(
c
*
storageosProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
c
.
plugin
.
GetAccessModes
(),
c
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
c
.
options
.
PVC
.
Spec
.
AccessModes
,
c
.
plugin
.
GetAccessModes
())
}
...
...
@@ -600,7 +599,7 @@ func (c *storageosProvisioner) Provision() (*v1.PersistentVolume, error) {
c
.
labels
[
k
]
=
v
}
capacity
:=
c
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
c
.
sizeGB
=
int
(
volume
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
c
.
sizeGB
=
int
(
util
.
RoundUpSize
(
capacity
.
Value
(),
1024
*
1024
*
1024
))
apiCfg
,
err
:=
parsePVSecret
(
adminSecretNamespace
,
adminSecretName
,
c
.
plugin
.
host
.
GetKubeClient
())
if
err
!=
nil
{
...
...
@@ -622,7 +621,7 @@ func (c *storageosProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
vol
.
Name
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"storageos-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"storageos-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/testing/testing.go
View file @
f737ad62
...
...
@@ -40,7 +40,8 @@ import (
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
.
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/pkg/volume/util/recyclerclient"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
// fakeVolumeHost is useful for testing volume plugins.
...
...
@@ -379,7 +380,7 @@ func (plugin *FakeVolumePlugin) GetNewDetacherCallCount() int {
return
plugin
.
NewDetacherCallCount
}
func
(
plugin
*
FakeVolumePlugin
)
Recycle
(
pvName
string
,
spec
*
Spec
,
eventRecorder
RecycleEventRecorder
)
error
{
func
(
plugin
*
FakeVolumePlugin
)
Recycle
(
pvName
string
,
spec
*
Spec
,
eventRecorder
recyclerclient
.
RecycleEventRecorder
)
error
{
return
nil
}
...
...
@@ -711,7 +712,7 @@ func (fc *FakeProvisioner) Provision() (*v1.PersistentVolume, error) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
fc
.
Options
.
PVName
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"fakeplugin-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"fakeplugin-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
@@ -731,10 +732,10 @@ func (fc *FakeProvisioner) Provision() (*v1.PersistentVolume, error) {
return
pv
,
nil
}
var
_
util
.
BlockVolumePathHandler
=
&
FakeVolumePathHandler
{}
var
_
volumepathhandler
.
BlockVolumePathHandler
=
&
FakeVolumePathHandler
{}
//NewDeviceHandler Create a new IoHandler implementation
func
NewBlockVolumePathHandler
()
util
.
BlockVolumePathHandler
{
func
NewBlockVolumePathHandler
()
volumepathhandler
.
BlockVolumePathHandler
{
return
&
FakeVolumePathHandler
{}
}
...
...
pkg/volume/util/operationexecutor/operation_executor.go
View file @
f737ad62
...
...
@@ -34,7 +34,7 @@ import (
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/nestedpendingoperations"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
// OperationExecutor defines a set of operations for attaching, detaching,
...
...
@@ -708,7 +708,7 @@ func (oe *operationExecutor) MountVolume(
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
error
{
fsVolume
,
err
:=
volumehelper
.
CheckVolumeModeFilesystem
(
volumeToMount
.
VolumeSpec
)
fsVolume
,
err
:=
util
.
CheckVolumeModeFilesystem
(
volumeToMount
.
VolumeSpec
)
if
err
!=
nil
{
return
err
}
...
...
@@ -736,7 +736,7 @@ func (oe *operationExecutor) MountVolume(
if
!
volumeToMount
.
PluginIsAttachable
{
// Non-attachable volume plugins can execute mount for multiple pods
// referencing the same volume in parallel
podName
=
volumehelper
.
GetUniquePodName
(
volumeToMount
.
Pod
)
podName
=
util
.
GetUniquePodName
(
volumeToMount
.
Pod
)
}
// TODO mount_device
...
...
@@ -747,7 +747,7 @@ func (oe *operationExecutor) MountVolume(
func
(
oe
*
operationExecutor
)
UnmountVolume
(
volumeToUnmount
MountedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
)
error
{
fsVolume
,
err
:=
volumehelper
.
CheckVolumeModeFilesystem
(
volumeToUnmount
.
VolumeSpec
)
fsVolume
,
err
:=
util
.
CheckVolumeModeFilesystem
(
volumeToUnmount
.
VolumeSpec
)
if
err
!=
nil
{
return
err
}
...
...
@@ -778,7 +778,7 @@ func (oe *operationExecutor) UnmountDevice(
deviceToDetach
AttachedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
mounter
mount
.
Interface
)
error
{
fsVolume
,
err
:=
volumehelper
.
CheckVolumeModeFilesystem
(
deviceToDetach
.
VolumeSpec
)
fsVolume
,
err
:=
util
.
CheckVolumeModeFilesystem
(
deviceToDetach
.
VolumeSpec
)
if
err
!=
nil
{
return
err
}
...
...
@@ -881,7 +881,7 @@ func (oe *operationExecutor) CheckVolumeExistenceOperation(
podName
volumetypes
.
UniquePodName
,
podUID
types
.
UID
,
attachable
volume
.
AttachableVolumePlugin
)
(
bool
,
error
)
{
fsVolume
,
err
:=
volumehelper
.
CheckVolumeModeFilesystem
(
volumeSpec
)
fsVolume
,
err
:=
util
.
CheckVolumeModeFilesystem
(
volumeSpec
)
if
err
!=
nil
{
return
false
,
err
}
...
...
@@ -913,7 +913,7 @@ func (oe *operationExecutor) CheckVolumeExistenceOperation(
// is there. Either plugin is attachable or non-attachable, the plugin should
// have symbolic link associated to raw block device under pod device map
// if volume exists.
blkutil
:=
util
.
NewBlockVolumePathHandler
()
blkutil
:=
volumepathhandler
.
NewBlockVolumePathHandler
()
var
islinkExist
bool
var
checkErr
error
if
islinkExist
,
checkErr
=
blkutil
.
IsSymlinkExist
(
mountPath
);
checkErr
!=
nil
{
...
...
pkg/volume/util/operationexecutor/operation_generator.go
View file @
f737ad62
...
...
@@ -37,7 +37,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
volumetypes
"k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/kubernetes/pkg/volume/util/volume
help
er"
"k8s.io/kubernetes/pkg/volume/util/volume
pathhandl
er"
)
var
_
OperationGenerator
=
&
operationGenerator
{}
...
...
@@ -60,7 +60,7 @@ type operationGenerator struct {
checkNodeCapabilitiesBeforeMount
bool
// blkUtil provides volume path related operations for block volume
blkUtil
util
.
BlockVolumePathHandler
blkUtil
volumepathhandler
.
BlockVolumePathHandler
}
// NewOperationGenerator is returns instance of operationGenerator
...
...
@@ -68,7 +68,7 @@ func NewOperationGenerator(kubeClient clientset.Interface,
volumePluginMgr
*
volume
.
VolumePluginMgr
,
recorder
record
.
EventRecorder
,
checkNodeCapabilitiesBeforeMount
bool
,
blkUtil
util
.
BlockVolumePathHandler
)
OperationGenerator
{
blkUtil
volumepathhandler
.
BlockVolumePathHandler
)
OperationGenerator
{
return
&
operationGenerator
{
kubeClient
:
kubeClient
,
...
...
@@ -378,7 +378,7 @@ func (og *operationGenerator) GenerateDetachVolumeFunc(
// Get attacher plugin and the volumeName by splitting the volume unique name in case
// there's no VolumeSpec: this happens only on attach/detach controller crash recovery
// when a pod has been deleted during the controller downtime
pluginName
,
volumeName
,
err
=
volumehelper
.
SplitUniqueName
(
volumeToDetach
.
VolumeName
)
pluginName
,
volumeName
,
err
=
util
.
SplitUniqueName
(
volumeToDetach
.
VolumeName
)
if
err
!=
nil
{
return
volumetypes
.
GeneratedOperations
{},
volumeToDetach
.
GenerateErrorDetailed
(
"DetachVolume.SplitUniqueName failed"
,
err
)
}
...
...
@@ -1290,7 +1290,7 @@ func (og *operationGenerator) GenerateExpandVolumeFunc(
}
func
checkMountOptionSupport
(
og
*
operationGenerator
,
volumeToMount
VolumeToMount
,
plugin
volume
.
VolumePlugin
)
error
{
mountOptions
:=
volume
.
MountOptionFromSpec
(
volumeToMount
.
VolumeSpec
)
mountOptions
:=
util
.
MountOptionFromSpec
(
volumeToMount
.
VolumeSpec
)
if
len
(
mountOptions
)
>
0
&&
!
plugin
.
SupportsMountOption
()
{
return
fmt
.
Errorf
(
"Mount options are not supported for this volume type"
)
...
...
pkg/volume/util/volumepathhandler/volume_path_handler.go
View file @
f737ad62
...
...
@@ -101,7 +101,7 @@ func (v VolumePathHandler) MapDevice(devicePath string, mapPath string, linkName
}
// Remove old symbolic link(or file) then create new one.
// This should be done because current symbolic link is
// stale ac
c
ross node reboot.
// stale across node reboot.
linkPath
:=
path
.
Join
(
mapPath
,
string
(
linkName
))
if
err
=
os
.
Remove
(
linkPath
);
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
err
...
...
pkg/volume/vsphere_volume/attacher.go
View file @
f737ad62
...
...
@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
type
vsphereVMDKAttacher
struct
{
...
...
@@ -219,8 +218,8 @@ func (attacher *vsphereVMDKAttacher) MountDevice(spec *volume.Spec, devicePath s
options
:=
[]
string
{}
if
notMnt
{
diskMounter
:=
volume
helper
.
NewSafeFormatAndMountFromHost
(
vsphereVolumePluginName
,
attacher
.
host
)
mountOptions
:=
volume
.
MountOptionFromSpec
(
spec
,
options
...
)
diskMounter
:=
volume
util
.
NewSafeFormatAndMountFromHost
(
vsphereVolumePluginName
,
attacher
.
host
)
mountOptions
:=
volume
util
.
MountOptionFromSpec
(
spec
,
options
...
)
err
=
diskMounter
.
FormatAndMount
(
devicePath
,
deviceMountPath
,
volumeSource
.
FSType
,
mountOptions
)
if
err
!=
nil
{
os
.
Remove
(
deviceMountPath
)
...
...
pkg/volume/vsphere_volume/vsphere_volume.go
View file @
f737ad62
...
...
@@ -31,7 +31,6 @@ import (
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -120,7 +119,7 @@ func (plugin *vsphereVolumePlugin) newMounterInternal(spec *volume.Spec, podUID
MetricsProvider
:
volume
.
NewMetricsStatFS
(
getPath
(
podUID
,
spec
.
Name
(),
plugin
.
host
)),
},
fsType
:
fsType
,
diskMounter
:
volumehelper
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
diskMounter
:
util
.
NewSafeFormatAndMountFromHost
(
plugin
.
GetPluginName
(),
plugin
.
host
)},
nil
}
func
(
plugin
*
vsphereVolumePlugin
)
newUnmounterInternal
(
volName
string
,
podUID
types
.
UID
,
manager
vdManager
,
mounter
mount
.
Interface
)
(
volume
.
Unmounter
,
error
)
{
...
...
@@ -350,7 +349,7 @@ func (plugin *vsphereVolumePlugin) newProvisionerInternal(options volume.VolumeO
}
func
(
v
*
vsphereVolumeProvisioner
)
Provision
()
(
*
v1
.
PersistentVolume
,
error
)
{
if
!
volume
.
AccessModesContainedInAll
(
v
.
plugin
.
GetAccessModes
(),
v
.
options
.
PVC
.
Spec
.
AccessModes
)
{
if
!
util
.
AccessModesContainedInAll
(
v
.
plugin
.
GetAccessModes
(),
v
.
options
.
PVC
.
Spec
.
AccessModes
)
{
return
nil
,
fmt
.
Errorf
(
"invalid AccessModes %v: only AccessModes %v are supported"
,
v
.
options
.
PVC
.
Spec
.
AccessModes
,
v
.
plugin
.
GetAccessModes
())
}
...
...
@@ -368,7 +367,7 @@ func (v *vsphereVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
Name
:
v
.
options
.
PVName
,
Labels
:
map
[
string
]
string
{},
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeDynamicallyCreatedByKey
:
"vsphere-volume-dynamic-provisioner"
,
util
.
VolumeDynamicallyCreatedByKey
:
"vsphere-volume-dynamic-provisioner"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
pkg/volume/vsphere_volume/vsphere_volume_util.go
View file @
f737ad62
...
...
@@ -93,8 +93,8 @@ func (util *VsphereDiskUtil) CreateVolume(v *vsphereVolumeProvisioner) (volSpec
capacity
:=
v
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
volSizeBytes
:=
capacity
.
Value
()
// vSphere works with kilobytes, convert to KiB with rounding up
volSizeKB
:=
int
(
volume
.
RoundUpSize
(
volSizeBytes
,
1024
))
name
:=
volume
.
GenerateVolumeName
(
v
.
options
.
ClusterName
,
v
.
options
.
PVName
,
255
)
volSizeKB
:=
int
(
volume
util
.
RoundUpSize
(
volSizeBytes
,
1024
))
name
:=
volume
util
.
GenerateVolumeName
(
v
.
options
.
ClusterName
,
v
.
options
.
PVName
,
255
)
volumeOptions
:=
&
vclib
.
VolumeOptions
{
CapacityKB
:
volSizeKB
,
Tags
:
*
v
.
options
.
CloudTags
,
...
...
test/e2e/framework/pv_util.go
View file @
f737ad62
...
...
@@ -38,7 +38,7 @@ import (
"k8s.io/kubernetes/pkg/api/testapi"
awscloud
"k8s.io/kubernetes/pkg/cloudprovider/providers/aws"
gcecloud
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
imageutils
"k8s.io/kubernetes/test/utils/image"
)
...
...
@@ -588,7 +588,7 @@ func MakePersistentVolume(pvConfig PersistentVolumeConfig) *v1.PersistentVolume
GenerateName
:
pvConfig
.
NamePrefix
,
Labels
:
pvConfig
.
Labels
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeGidAnnotationKey
:
"777"
,
util
.
VolumeGidAnnotationKey
:
"777"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
test/e2e/storage/vsphere/vsphere_utils.go
View file @
f737ad62
...
...
@@ -37,7 +37,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/storage/utils"
...
...
@@ -175,7 +175,7 @@ func getVSpherePersistentVolumeSpec(volumePath string, persistentVolumeReclaimPo
ObjectMeta
:
metav1
.
ObjectMeta
{
GenerateName
:
pvConfig
.
NamePrefix
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
VolumeGidAnnotationKey
:
"777"
,
util
.
VolumeGidAnnotationKey
:
"777"
,
},
},
Spec
:
v1
.
PersistentVolumeSpec
{
...
...
test/integration/volume/attach_detach_test.go
View file @
f737ad62
...
...
@@ -34,7 +34,7 @@ import (
volumecache
"k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache"
"k8s.io/kubernetes/pkg/volume"
volumetest
"k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util
/volumehelper
"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/test/integration/framework"
)
...
...
@@ -86,7 +86,7 @@ func TestPodDeletionWithDswp(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node-sandbox"
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
ControllerManagedAttachAnnotation
:
"true"
,
util
.
ControllerManagedAttachAnnotation
:
"true"
,
},
},
}
...
...
@@ -152,7 +152,7 @@ func TestPodUpdateWithWithADC(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node-sandbox"
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
ControllerManagedAttachAnnotation
:
"true"
,
util
.
ControllerManagedAttachAnnotation
:
"true"
,
},
},
}
...
...
@@ -219,8 +219,8 @@ func TestPodUpdateWithKeepTerminatedPodVolumes(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node-sandbox"
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
ControllerManagedAttachAnnotation
:
"true"
,
volumehelper
.
KeepTerminatedPodVolumesAnnotation
:
"true"
,
util
.
ControllerManagedAttachAnnotation
:
"true"
,
util
.
KeepTerminatedPodVolumesAnnotation
:
"true"
,
},
},
}
...
...
@@ -383,7 +383,7 @@ func TestPodAddedByDswp(t *testing.T) {
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"node-sandbox"
,
Annotations
:
map
[
string
]
string
{
volumehelper
.
ControllerManagedAttachAnnotation
:
"true"
,
util
.
ControllerManagedAttachAnnotation
:
"true"
,
},
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment