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
13b0fd3c
Commit
13b0fd3c
authored
Dec 03, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16942 from swagiaal/distinguish-format-and-mount
Auto commit by PR queue bot
parents
51c5e66e
66c905d6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
42 additions
and
32 deletions
+42
-32
mount.go
pkg/util/mount/mount.go
+9
-5
safe_format_and_mount_test.go
pkg/util/mount/safe_format_and_mount_test.go
+1
-1
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+1
-1
aws_util.go
pkg/volume/aws_ebs/aws_util.go
+1
-1
fc.go
pkg/volume/fc/fc.go
+12
-9
fc_util.go
pkg/volume/fc/fc_util.go
+1
-1
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+1
-1
gce_util.go
pkg/volume/gce_pd/gce_util.go
+1
-1
iscsi.go
pkg/volume/iscsi/iscsi.go
+11
-8
iscsi_util.go
pkg/volume/iscsi/iscsi_util.go
+1
-1
rbd.go
pkg/volume/rbd/rbd.go
+2
-2
rbd_util.go
pkg/volume/rbd/rbd_util.go
+1
-1
No files found.
pkg/util/mount/mount.go
View file @
13b0fd3c
...
...
@@ -49,16 +49,20 @@ type MountPoint struct {
Pass
int
}
// SafeFormatAndMount probes a device to see if it is formatted. If
// so it mounts it otherwise it formats it and mounts it
// SafeFormatAndMount probes a device to see if it is formatted.
// Namely it checks to see if a file system is present. If so it
// mounts it otherwise the device is formatted first then mounted.
type
SafeFormatAndMount
struct
{
Interface
Runner
exec
.
Interface
}
// Mount mounts the given disk. If the disk is not formatted and the disk is not being mounted as read only
// it will format the disk first then mount it.
func
(
mounter
*
SafeFormatAndMount
)
Mount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
// FormatAndMount formats the given disk, if needed, and mounts it.
// That is if the disk is not formatted and it is not being mounted as
// read-only it will format it first then mount it. Otherwise, if the
// disk is already formatted or it is being mounted as read-only, it
// will be mounted without formatting.
func
(
mounter
*
SafeFormatAndMount
)
FormatAndMount
(
source
string
,
target
string
,
fstype
string
,
options
[]
string
)
error
{
// Don't attempt to format if mounting as readonly. Go straight to mounting.
for
_
,
option
:=
range
options
{
if
option
==
"ro"
{
...
...
pkg/util/mount/safe_format_and_mount_test.go
View file @
13b0fd3c
...
...
@@ -156,7 +156,7 @@ func TestSafeFormatAndMount(t *testing.T) {
device
:=
"/dev/foo"
dest
:=
"/mnt/bar"
err
:=
mounter
.
Mount
(
device
,
dest
,
test
.
fstype
,
test
.
mountOptions
)
err
:=
mounter
.
FormatAnd
Mount
(
device
,
dest
,
test
.
fstype
,
test
.
mountOptions
)
if
test
.
expectedError
==
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected non-error: %v"
,
err
)
...
...
pkg/volume/aws_ebs/aws_ebs.go
View file @
13b0fd3c
...
...
@@ -172,7 +172,7 @@ type awsElasticBlockStoreBuilder struct {
// Specifies whether the disk will be attached as read-only.
readOnly
bool
// diskMounter provides the interface that is used to mount the actual block device.
diskMounter
mount
.
Interface
diskMounter
*
mount
.
SafeFormatAndMount
}
var
_
volume
.
Builder
=
&
awsElasticBlockStoreBuilder
{}
...
...
pkg/volume/aws_ebs/aws_util.go
View file @
13b0fd3c
...
...
@@ -74,7 +74,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, glob
options
=
append
(
options
,
"ro"
)
}
if
notMnt
{
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
err
=
b
.
diskMounter
.
FormatAnd
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
if
err
!=
nil
{
os
.
Remove
(
globalPDPath
)
return
err
...
...
pkg/volume/fc/fc.go
View file @
13b0fd3c
...
...
@@ -107,11 +107,11 @@ func (plugin *fcPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UID,
wwns
:
fc
.
TargetWWNs
,
lun
:
lun
,
manager
:
manager
,
mounter
:
&
mount
.
SafeFormatAndMount
{
mounter
,
exec
.
New
()},
io
:
&
osIOHandler
{},
plugin
:
plugin
},
fsType
:
fc
.
FSType
,
readOnly
:
readOnly
,
mounter
:
&
mount
.
SafeFormatAndMount
{
mounter
,
exec
.
New
()},
},
nil
}
...
...
@@ -121,14 +121,16 @@ func (plugin *fcPlugin) NewCleaner(volName string, podUID types.UID) (volume.Cle
}
func
(
plugin
*
fcPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
return
&
fcDiskCleaner
{
&
fcDisk
{
podUID
:
podUID
,
volName
:
volName
,
manager
:
manager
,
return
&
fcDiskCleaner
{
fcDisk
:
&
fcDisk
{
podUID
:
podUID
,
volName
:
volName
,
manager
:
manager
,
plugin
:
plugin
,
io
:
&
osIOHandler
{},
},
mounter
:
mounter
,
plugin
:
plugin
,
io
:
&
osIOHandler
{},
}},
nil
},
nil
}
func
(
plugin
*
fcPlugin
)
execCommand
(
command
string
,
args
[]
string
)
([]
byte
,
error
)
{
...
...
@@ -143,7 +145,6 @@ type fcDisk struct {
wwns
[]
string
lun
string
plugin
*
fcPlugin
mounter
mount
.
Interface
// Utility interface that provides API calls to the provider to attach/detach disks.
manager
diskManager
// io handler interface
...
...
@@ -160,6 +161,7 @@ type fcDiskBuilder struct {
*
fcDisk
readOnly
bool
fsType
string
mounter
*
mount
.
SafeFormatAndMount
}
var
_
volume
.
Builder
=
&
fcDiskBuilder
{}
...
...
@@ -187,6 +189,7 @@ func (b *fcDiskBuilder) SetUpAt(dir string) error {
type
fcDiskCleaner
struct
{
*
fcDisk
mounter
mount
.
Interface
}
var
_
volume
.
Cleaner
=
&
fcDiskCleaner
{}
...
...
pkg/volume/fc/fc_util.go
View file @
13b0fd3c
...
...
@@ -184,7 +184,7 @@ func (util *FCUtil) AttachDisk(b fcDiskBuilder) error {
return
fmt
.
Errorf
(
"fc: failed to mkdir %s, error"
,
globalPDPath
)
}
err
=
b
.
mounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
)
err
=
b
.
mounter
.
FormatAnd
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"fc: failed to mount fc volume %s [%s] to %s, error %v"
,
devicePath
,
b
.
fsType
,
globalPDPath
,
err
)
}
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
13b0fd3c
...
...
@@ -160,7 +160,7 @@ type gcePersistentDiskBuilder struct {
// Specifies whether the disk will be attached as read-only.
readOnly
bool
// diskMounter provides the interface that is used to mount the actual block device.
diskMounter
mount
.
Interface
diskMounter
*
mount
.
SafeFormatAndMount
}
var
_
volume
.
Builder
=
&
gcePersistentDiskBuilder
{}
...
...
pkg/volume/gce_pd/gce_util.go
View file @
13b0fd3c
...
...
@@ -90,7 +90,7 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
options
=
append
(
options
,
"ro"
)
}
if
notMnt
{
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
err
=
b
.
diskMounter
.
FormatAnd
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
if
err
!=
nil
{
os
.
Remove
(
globalPDPath
)
return
err
...
...
pkg/volume/iscsi/iscsi.go
View file @
13b0fd3c
...
...
@@ -105,10 +105,10 @@ func (plugin *iscsiPlugin) newBuilderInternal(spec *volume.Spec, podUID types.UI
iqn
:
iscsi
.
IQN
,
lun
:
lun
,
manager
:
manager
,
mounter
:
&
mount
.
SafeFormatAndMount
{
mounter
,
exec
.
New
()},
plugin
:
plugin
},
fsType
:
iscsi
.
FSType
,
readOnly
:
readOnly
,
mounter
:
&
mount
.
SafeFormatAndMount
{
mounter
,
exec
.
New
()},
},
nil
}
...
...
@@ -118,13 +118,15 @@ func (plugin *iscsiPlugin) NewCleaner(volName string, podUID types.UID) (volume.
}
func
(
plugin
*
iscsiPlugin
)
newCleanerInternal
(
volName
string
,
podUID
types
.
UID
,
manager
diskManager
,
mounter
mount
.
Interface
)
(
volume
.
Cleaner
,
error
)
{
return
&
iscsiDiskCleaner
{
&
iscsiDisk
{
podUID
:
podUID
,
volName
:
volName
,
manager
:
manager
,
return
&
iscsiDiskCleaner
{
iscsiDisk
:
&
iscsiDisk
{
podUID
:
podUID
,
volName
:
volName
,
manager
:
manager
,
plugin
:
plugin
,
},
mounter
:
mounter
,
plugin
:
plugin
,
}},
nil
},
nil
}
func
(
plugin
*
iscsiPlugin
)
execCommand
(
command
string
,
args
[]
string
)
([]
byte
,
error
)
{
...
...
@@ -139,7 +141,6 @@ type iscsiDisk struct {
iqn
string
lun
string
plugin
*
iscsiPlugin
mounter
mount
.
Interface
// Utility interface that provides API calls to the provider to attach/detach disks.
manager
diskManager
}
...
...
@@ -154,6 +155,7 @@ type iscsiDiskBuilder struct {
*
iscsiDisk
readOnly
bool
fsType
string
mounter
*
mount
.
SafeFormatAndMount
}
var
_
volume
.
Builder
=
&
iscsiDiskBuilder
{}
...
...
@@ -182,6 +184,7 @@ func (b *iscsiDiskBuilder) SetUpAt(dir string) error {
type
iscsiDiskCleaner
struct
{
*
iscsiDisk
mounter
mount
.
Interface
}
var
_
volume
.
Cleaner
=
&
iscsiDiskCleaner
{}
...
...
pkg/volume/iscsi/iscsi_util.go
View file @
13b0fd3c
...
...
@@ -113,7 +113,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskBuilder) error {
return
err
}
err
=
b
.
mounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
)
err
=
b
.
mounter
.
FormatAnd
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
)
if
err
!=
nil
{
glog
.
Errorf
(
"iscsi: failed to mount iscsi volume %s [%s] to %s, error %v"
,
devicePath
,
b
.
fsType
,
globalPDPath
,
err
)
}
...
...
pkg/volume/rbd/rbd.go
View file @
13b0fd3c
...
...
@@ -154,7 +154,7 @@ func (plugin *rbdPlugin) newCleanerInternal(volName string, podUID types.UID, ma
podUID
:
podUID
,
volName
:
volName
,
manager
:
manager
,
mounter
:
mounter
,
mounter
:
&
mount
.
SafeFormatAndMount
{
mounter
,
exec
.
New
()}
,
plugin
:
plugin
,
},
Mon
:
make
([]
string
,
0
),
...
...
@@ -169,7 +169,7 @@ type rbd struct {
Image
string
ReadOnly
bool
plugin
*
rbdPlugin
mounter
mount
.
Interface
mounter
*
mount
.
SafeFormatAndMount
// Utility interface that provides API calls to the provider to attach/detach disks.
manager
diskManager
}
...
...
pkg/volume/rbd/rbd_util.go
View file @
13b0fd3c
...
...
@@ -273,7 +273,7 @@ func (util *RBDUtil) AttachDisk(b rbdBuilder) error {
// the json file remains invisible during rbd mount and thus won't be removed accidentally.
util
.
persistRBD
(
b
,
globalPDPath
)
if
err
=
b
.
mounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
);
err
!=
nil
{
if
err
=
b
.
mounter
.
FormatAnd
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
nil
);
err
!=
nil
{
err
=
fmt
.
Errorf
(
"rbd: failed to mount rbd volume %s [%s] to %s, error %v"
,
devicePath
,
b
.
fsType
,
globalPDPath
,
err
)
}
return
err
...
...
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