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
288a1e55
Unverified
Commit
288a1e55
authored
Jan 05, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72161 from saad-ali/automated-cherry-pick-of-#71581-upstream-release-1.13
Automated Cherry Pick of #71581 to release-1.13
parents
042f324c
6804ad6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
50 deletions
+54
-50
operation_executor.go
pkg/volume/util/operationexecutor/operation_executor.go
+1
-1
operation_executor_test.go
pkg/volume/util/operationexecutor/operation_executor_test.go
+2
-2
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+51
-47
No files found.
pkg/volume/util/operationexecutor/operation_executor.go
View file @
288a1e55
...
@@ -725,7 +725,7 @@ func (oe *operationExecutor) MountVolume(
...
@@ -725,7 +725,7 @@ func (oe *operationExecutor) MountVolume(
if
fsVolume
{
if
fsVolume
{
// Filesystem volume case
// Filesystem volume case
// Mount/remount a volume when a volume is attached
// Mount/remount a volume when a volume is attached
generatedOperations
,
err
=
oe
.
operationGenerator
.
GenerateMountVolumeFunc
(
generatedOperations
=
oe
.
operationGenerator
.
GenerateMountVolumeFunc
(
waitForAttachTimeout
,
volumeToMount
,
actualStateOfWorld
,
isRemount
)
waitForAttachTimeout
,
volumeToMount
,
actualStateOfWorld
,
isRemount
)
}
else
{
}
else
{
...
...
pkg/volume/util/operationexecutor/operation_executor_test.go
View file @
288a1e55
...
@@ -389,14 +389,14 @@ func newFakeOperationGenerator(ch chan interface{}, quit chan interface{}) Opera
...
@@ -389,14 +389,14 @@ func newFakeOperationGenerator(ch chan interface{}, quit chan interface{}) Opera
}
}
}
}
func
(
fopg
*
fakeOperationGenerator
)
GenerateMountVolumeFunc
(
waitForAttachTimeout
time
.
Duration
,
volumeToMount
VolumeToMount
,
actualStateOfWorldMounterUpdater
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
func
(
fopg
*
fakeOperationGenerator
)
GenerateMountVolumeFunc
(
waitForAttachTimeout
time
.
Duration
,
volumeToMount
VolumeToMount
,
actualStateOfWorldMounterUpdater
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
volumetypes
.
GeneratedOperations
{
opFunc
:=
func
()
(
error
,
error
)
{
opFunc
:=
func
()
(
error
,
error
)
{
startOperationAndBlock
(
fopg
.
ch
,
fopg
.
quit
)
startOperationAndBlock
(
fopg
.
ch
,
fopg
.
quit
)
return
nil
,
nil
return
nil
,
nil
}
}
return
volumetypes
.
GeneratedOperations
{
return
volumetypes
.
GeneratedOperations
{
OperationFunc
:
opFunc
,
OperationFunc
:
opFunc
,
}
,
nil
}
}
}
func
(
fopg
*
fakeOperationGenerator
)
GenerateUnmountVolumeFunc
(
volumeToUnmount
MountedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
podsDir
string
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
func
(
fopg
*
fakeOperationGenerator
)
GenerateUnmountVolumeFunc
(
volumeToUnmount
MountedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
podsDir
string
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
opFunc
:=
func
()
(
error
,
error
)
{
opFunc
:=
func
()
(
error
,
error
)
{
...
...
pkg/volume/util/operationexecutor/operation_generator.go
View file @
288a1e55
...
@@ -40,6 +40,10 @@ import (
...
@@ -40,6 +40,10 @@ import (
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
)
const
(
unknownVolumePlugin
string
=
"UnknownVolumePlugin"
)
var
_
OperationGenerator
=
&
operationGenerator
{}
var
_
OperationGenerator
=
&
operationGenerator
{}
type
operationGenerator
struct
{
type
operationGenerator
struct
{
...
@@ -82,7 +86,7 @@ func NewOperationGenerator(kubeClient clientset.Interface,
...
@@ -82,7 +86,7 @@ func NewOperationGenerator(kubeClient clientset.Interface,
// OperationGenerator interface that extracts out the functions from operation_executor to make it dependency injectable
// OperationGenerator interface that extracts out the functions from operation_executor to make it dependency injectable
type
OperationGenerator
interface
{
type
OperationGenerator
interface
{
// Generates the MountVolume function needed to perform the mount of a volume plugin
// Generates the MountVolume function needed to perform the mount of a volume plugin
GenerateMountVolumeFunc
(
waitForAttachTimeout
time
.
Duration
,
volumeToMount
VolumeToMount
,
actualStateOfWorldMounterUpdater
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
(
volumetypes
.
GeneratedOperations
,
error
)
GenerateMountVolumeFunc
(
waitForAttachTimeout
time
.
Duration
,
volumeToMount
VolumeToMount
,
actualStateOfWorldMounterUpdater
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
volumetypes
.
GeneratedOperations
// Generates the UnmountVolume function needed to perform the unmount of a volume plugin
// Generates the UnmountVolume function needed to perform the unmount of a volume plugin
GenerateUnmountVolumeFunc
(
volumeToUnmount
MountedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
podsDir
string
)
(
volumetypes
.
GeneratedOperations
,
error
)
GenerateUnmountVolumeFunc
(
volumeToUnmount
MountedVolume
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
podsDir
string
)
(
volumetypes
.
GeneratedOperations
,
error
)
...
@@ -436,61 +440,61 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
...
@@ -436,61 +440,61 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
waitForAttachTimeout
time
.
Duration
,
waitForAttachTimeout
time
.
Duration
,
volumeToMount
VolumeToMount
,
volumeToMount
VolumeToMount
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
actualStateOfWorld
ActualStateOfWorldMounterUpdater
,
isRemount
bool
)
(
volumetypes
.
GeneratedOperations
,
error
)
{
isRemount
bool
)
volumetypes
.
GeneratedOperations
{
// Get mounter plugin
// Get mounter plugin
volumePluginName
:=
unknownVolumePlugin
volumePlugin
,
err
:=
volumePlugin
,
err
:=
og
.
volumePluginMgr
.
FindPluginBySpec
(
volumeToMount
.
VolumeSpec
)
og
.
volumePluginMgr
.
FindPluginBySpec
(
volumeToMount
.
VolumeSpec
)
if
err
!=
nil
||
volumePlugin
=
=
nil
{
if
err
==
nil
&&
volumePlugin
!
=
nil
{
return
volumetypes
.
GeneratedOperations
{},
volumeToMount
.
GenerateErrorDetailed
(
"MountVolume.FindPluginBySpec failed"
,
err
)
volumePluginName
=
volumePlugin
.
GetPluginName
(
)
}
}
affinityErr
:=
checkNodeAffinity
(
og
,
volumeToMount
,
volumePlugin
)
mountVolumeFunc
:=
func
()
(
error
,
error
)
{
if
affinityErr
!=
nil
{
if
err
!=
nil
||
volumePlugin
==
nil
{
eventErr
,
detailedErr
:=
volumeToMount
.
GenerateError
(
"MountVolume.NodeAffinity check failed"
,
affinityErr
)
return
volumeToMount
.
GenerateError
(
"MountVolume.FindPluginBySpec failed"
,
err
)
og
.
recorder
.
Eventf
(
volumeToMount
.
Pod
,
v1
.
EventTypeWarning
,
kevents
.
FailedMountVolume
,
eventErr
.
Error
())
}
return
volumetypes
.
GeneratedOperations
{},
detailedErr
}
volumeMounter
,
newMounterErr
:=
volumePlugin
.
NewMounter
(
affinityErr
:=
checkNodeAffinity
(
og
,
volumeToMount
,
volumePlugin
)
volumeToMount
.
VolumeSpec
,
if
affinityErr
!=
nil
{
volumeToMount
.
Pod
,
return
volumeToMount
.
GenerateError
(
"MountVolume.NodeAffinity check failed"
,
affinityErr
)
volume
.
VolumeOptions
{})
}
if
newMounterErr
!=
nil
{
eventErr
,
detailedErr
:=
volumeToMount
.
GenerateError
(
"MountVolume.NewMounter initialization failed"
,
newMounterErr
)
og
.
recorder
.
Eventf
(
volumeToMount
.
Pod
,
v1
.
EventTypeWarning
,
kevents
.
FailedMountVolume
,
eventErr
.
Error
())
return
volumetypes
.
GeneratedOperations
{},
detailedErr
}
mountCheckError
:=
checkMountOptionSupport
(
og
,
volumeToMount
,
volumePlugin
)
volumeMounter
,
newMounterErr
:=
volumePlugin
.
NewMounter
(
volumeToMount
.
VolumeSpec
,
volumeToMount
.
Pod
,
volume
.
VolumeOptions
{})
if
newMounterErr
!=
nil
{
return
volumeToMount
.
GenerateError
(
"MountVolume.NewMounter initialization failed"
,
newMounterErr
)
if
mountCheckError
!=
nil
{
}
eventErr
,
detailedErr
:=
volumeToMount
.
GenerateError
(
"MountVolume.MountOptionSupport check failed"
,
mountCheckError
)
og
.
recorder
.
Eventf
(
volumeToMount
.
Pod
,
v1
.
EventTypeWarning
,
kevents
.
UnsupportedMountOption
,
eventErr
.
Error
())
return
volumetypes
.
GeneratedOperations
{},
detailedErr
}
// Get attacher, if possible
mountCheckError
:=
checkMountOptionSupport
(
og
,
volumeToMount
,
volumePlugin
)
attachableVolumePlugin
,
_
:=
og
.
volumePluginMgr
.
FindAttachablePluginBySpec
(
volumeToMount
.
VolumeSpec
)
var
volumeAttacher
volume
.
Attacher
if
attachableVolumePlugin
!=
nil
{
volumeAttacher
,
_
=
attachableVolumePlugin
.
NewAttacher
()
}
// get deviceMounter, if possible
if
mountCheckError
!=
nil
{
deviceMountableVolumePlugin
,
_
:=
og
.
volumePluginMgr
.
FindDeviceMountablePluginBySpec
(
volumeToMount
.
VolumeSpec
)
return
volumeToMount
.
GenerateError
(
"MountVolume.MountOptionSupport check failed"
,
mountCheckError
)
var
volumeDeviceMounter
volume
.
DeviceMounter
}
if
deviceMountableVolumePlugin
!=
nil
{
volumeDeviceMounter
,
_
=
deviceMountableVolumePlugin
.
NewDeviceMounter
()
}
var
fsGroup
*
int64
// Get attacher, if possible
if
volumeToMount
.
Pod
.
Spec
.
SecurityContext
!=
nil
&&
attachableVolumePlugin
,
_
:=
volumeToMount
.
Pod
.
Spec
.
SecurityContext
.
FSGroup
!=
nil
{
og
.
volumePluginMgr
.
FindAttachablePluginBySpec
(
volumeToMount
.
VolumeSpec
)
fsGroup
=
volumeToMount
.
Pod
.
Spec
.
SecurityContext
.
FSGroup
var
volumeAttacher
volume
.
Attacher
}
if
attachableVolumePlugin
!=
nil
{
volumeAttacher
,
_
=
attachableVolumePlugin
.
NewAttacher
()
}
// get deviceMounter, if possible
deviceMountableVolumePlugin
,
_
:=
og
.
volumePluginMgr
.
FindDeviceMountablePluginBySpec
(
volumeToMount
.
VolumeSpec
)
var
volumeDeviceMounter
volume
.
DeviceMounter
if
deviceMountableVolumePlugin
!=
nil
{
volumeDeviceMounter
,
_
=
deviceMountableVolumePlugin
.
NewDeviceMounter
()
}
var
fsGroup
*
int64
if
volumeToMount
.
Pod
.
Spec
.
SecurityContext
!=
nil
&&
volumeToMount
.
Pod
.
Spec
.
SecurityContext
.
FSGroup
!=
nil
{
fsGroup
=
volumeToMount
.
Pod
.
Spec
.
SecurityContext
.
FSGroup
}
mountVolumeFunc
:=
func
()
(
error
,
error
)
{
devicePath
:=
volumeToMount
.
DevicePath
devicePath
:=
volumeToMount
.
DevicePath
if
volumeAttacher
!=
nil
{
if
volumeAttacher
!=
nil
{
// Wait for attachable volumes to finish attaching
// Wait for attachable volumes to finish attaching
...
@@ -536,7 +540,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
...
@@ -536,7 +540,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
// resizeFileSystem will resize the file system if user has requested a resize of
// resizeFileSystem will resize the file system if user has requested a resize of
// underlying persistent volume and is allowed to do so.
// underlying persistent volume and is allowed to do so.
resizeSimpleError
,
resizeDetailedError
:=
og
.
resizeFileSystem
(
volumeToMount
,
devicePath
,
deviceMountPath
,
volumePlugin
.
GetPluginName
()
)
resizeSimpleError
,
resizeDetailedError
:=
og
.
resizeFileSystem
(
volumeToMount
,
devicePath
,
deviceMountPath
,
volumePlugin
Name
)
if
resizeSimpleError
!=
nil
||
resizeDetailedError
!=
nil
{
if
resizeSimpleError
!=
nil
||
resizeDetailedError
!=
nil
{
return
resizeSimpleError
,
resizeDetailedError
return
resizeSimpleError
,
resizeDetailedError
...
@@ -593,8 +597,8 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
...
@@ -593,8 +597,8 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
return
volumetypes
.
GeneratedOperations
{
return
volumetypes
.
GeneratedOperations
{
OperationFunc
:
mountVolumeFunc
,
OperationFunc
:
mountVolumeFunc
,
EventRecorderFunc
:
eventRecorderFunc
,
EventRecorderFunc
:
eventRecorderFunc
,
CompleteFunc
:
util
.
OperationCompleteHook
(
util
.
GetFullQualifiedPluginNameForVolume
(
volumePlugin
.
GetPluginName
()
,
volumeToMount
.
VolumeSpec
),
"volume_mount"
),
CompleteFunc
:
util
.
OperationCompleteHook
(
util
.
GetFullQualifiedPluginNameForVolume
(
volumePlugin
Name
,
volumeToMount
.
VolumeSpec
),
"volume_mount"
),
}
,
nil
}
}
}
func
(
og
*
operationGenerator
)
resizeFileSystem
(
volumeToMount
VolumeToMount
,
devicePath
,
deviceMountPath
,
pluginName
string
)
(
simpleErr
,
detailedErr
error
)
{
func
(
og
*
operationGenerator
)
resizeFileSystem
(
volumeToMount
VolumeToMount
,
devicePath
,
deviceMountPath
,
pluginName
string
)
(
simpleErr
,
detailedErr
error
)
{
...
...
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