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
9b60fb0c
Commit
9b60fb0c
authored
Nov 05, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16536 from rootfs/fix-mkfs
Auto commit by PR queue bot
parents
cdbb4611
a31d23ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
mount.go
pkg/util/mount/mount.go
+4
-1
safe_format_and_mount_test.go
pkg/util/mount/safe_format_and_mount_test.go
+15
-5
No files found.
pkg/util/mount/mount.go
View file @
9b60fb0c
...
...
@@ -78,12 +78,15 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
// It is possible that this disk is not formatted. Double check using diskLooksUnformatted
notFormatted
,
err
:=
mounter
.
diskLooksUnformatted
(
source
)
if
err
==
nil
&&
notFormatted
{
args
:=
[]
string
{
source
}
// Disk is unformatted so format it.
// Use 'ext4' as the default
if
len
(
fstype
)
==
0
{
fstype
=
"ext4"
}
args
:=
[]
string
{
"-E"
,
"lazy_itable_init=0,lazy_journal_init=0"
,
"-F"
,
source
}
if
fstype
==
"ext4"
||
fstype
==
"ext3"
{
args
=
[]
string
{
"-E"
,
"lazy_itable_init=0,lazy_journal_init=0"
,
"-F"
,
source
}
}
cmd
:=
mounter
.
Runner
.
Command
(
"mkfs."
+
fstype
,
args
...
)
_
,
err
:=
cmd
.
CombinedOutput
()
if
err
==
nil
{
...
...
pkg/util/mount/safe_format_and_mount_test.go
View file @
9b60fb0c
...
...
@@ -61,7 +61,7 @@ func TestSafeFormatAndMount(t *testing.T) {
fstype
:
"ext4"
,
},
{
// Test that '
file
' is called and fails
{
// Test that '
lsblk
' is called and fails
fstype
:
"ext4"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
)},
execScripts
:
[]
ExecArgs
{
...
...
@@ -69,7 +69,7 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expectedError
:
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
),
},
{
// Test that '
file
' is called and confirms unformatted disk, format fails
{
// Test that '
lsblk
' is called and confirms unformatted disk, format fails
fstype
:
"ext4"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
)},
execScripts
:
[]
ExecArgs
{
...
...
@@ -78,7 +78,7 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expectedError
:
fmt
.
Errorf
(
"formatting failed"
),
},
{
// Test that '
file
' is called and confirms unformatted disk, format passes, second mount fails
{
// Test that '
lsblk
' is called and confirms unformatted disk, format passes, second mount fails
fstype
:
"ext4"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
),
fmt
.
Errorf
(
"Still cannot mount"
)},
execScripts
:
[]
ExecArgs
{
...
...
@@ -87,7 +87,7 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expectedError
:
fmt
.
Errorf
(
"Still cannot mount"
),
},
{
// Test that '
file
' is called and confirms unformatted disk, format passes, second mount passes
{
// Test that '
lsblk
' is called and confirms unformatted disk, format passes, second mount passes
fstype
:
"ext4"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
),
nil
},
execScripts
:
[]
ExecArgs
{
...
...
@@ -96,7 +96,7 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expectedError
:
nil
,
},
{
// Test that '
file
' is called and confirms unformatted disk, format passes, second mount passes with ext3
{
// Test that '
lsblk
' is called and confirms unformatted disk, format passes, second mount passes with ext3
fstype
:
"ext3"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
),
nil
},
execScripts
:
[]
ExecArgs
{
...
...
@@ -105,6 +105,16 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expectedError
:
nil
,
},
{
// Test that 'lsblk' is called and confirms unformatted disk, format passes, second mount passes
// test that none ext4 fs does not get called with ext4 options.
fstype
:
"xfs"
,
mountErrs
:
[]
error
{
fmt
.
Errorf
(
"unknown filesystem type '(null)'"
),
nil
},
execScripts
:
[]
ExecArgs
{
{
"lsblk"
,
[]
string
{
"-nd"
,
"-o"
,
"FSTYPE"
,
"/dev/foo"
},
""
,
nil
},
{
"mkfs.xfs"
,
[]
string
{
"/dev/foo"
},
""
,
nil
},
},
expectedError
:
nil
,
},
}
for
_
,
test
:=
range
tests
{
...
...
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