Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
2db79998
Commit
2db79998
authored
4 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Changed partitions test to handle system with /var mount point | refs
#32112
parent
1424ec35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_partitions.py
+40
-15
40 additions, 15 deletions
tests/test_partitions.py
with
40 additions
and
15 deletions
tests/test_partitions.py
+
40
−
15
View file @
2db79998
...
...
@@ -18,11 +18,27 @@ DEF = '\033[0m'
PATHS
=
[
{
'
mount_point
'
:
'
/
'
,
'
condition
'
:
'
/var
'
,
# ignore this mount point check if /var is on the same device
'
recommended_types
'
:
(
'
ext4
'
,
'
zfs
'
,
'
xfs
'
),
'
min_size_gbytes
'
:
6
,
'
reco_size_gbytes
'
:
9
,
'
min_available_gbytes
'
:
2
,
},
{
'
mount_point
'
:
'
/
'
,
'
condition
'
:
'
!/var
'
,
# ignore this mount point check if /var is not on the same device
'
recommended_types
'
:
(
'
ext4
'
,
'
zfs
'
,
'
xfs
'
),
'
min_size_gbytes
'
:
9
,
'
reco_size_gbytes
'
:
14
,
'
min_available_gbytes
'
:
4
,
},
{
'
mount_point
'
:
'
/var
'
,
'
recommended_types
'
:
(
'
ext4
'
,
'
zfs
'
,
'
xfs
'
),
'
min_size_gbytes
'
:
2
,
'
reco_size_gbytes
'
:
4
,
'
min_available_gbytes
'
:
0.5
,
},
{
'
mount_point
'
:
'
/home/msuser/msinstance
'
,
'
recommended_types
'
:
(
'
ext4
'
,
'
zfs
'
,
'
nfs
'
,
'
nfs4
'
,
'
xfs
'
),
...
...
@@ -64,7 +80,7 @@ def get_memory_gbytes():
return
memory_gbytes
def
get_path
(
path
):
def
get_path
_fs
(
path
):
# Filesystem Type 1B-blocks Used Available
# /dev/loop2 ext4 52710469632 38253940736 11755397120
status
,
output
=
subprocess
.
getstatusoutput
(
'
df --output=
"
source,fstype,size,avail
"
-B 1 %s | tail -n 1
'
%
path
)
...
...
@@ -107,40 +123,49 @@ def check_allocation(dev):
if
__name__
==
'
__main__
'
:
error
=
False
warning
=
False
for
p
in
PATHS
:
for
p
art_info
in
PATHS
:
psize
=
None
if
p
.
get
(
'
mount_point
'
):
mount_point
=
p
[
'
mount_point
'
]
if
p
art_info
.
get
(
'
mount_point
'
):
mount_point
=
p
art_info
[
'
mount_point
'
]
if
os
.
path
.
exists
(
mount_point
):
mount_point
=
os
.
path
.
realpath
(
mount_point
)
name
=
'
Partition of %s
'
%
mount_point
dev
,
fstype
,
psize
,
available
=
get_path
(
mount_point
)
if
fstype
not
in
p
.
get
(
'
recommended_types
'
):
print
(
'
Warning: %s fs type not recommended %s(current: %s, recommended: %s)%s.
'
%
(
name
,
YELLOW
,
fstype
,
p
[
'
recommended_types
'
],
DEF
))
dev
,
fstype
,
psize
,
available
=
get_path_fs
(
mount_point
)
condition
=
part_info
.
get
(
'
condition
'
)
if
condition
:
subdev
=
get_path_fs
(
condition
.
strip
(
'
!
'
))[
0
]
if
subdev
==
dev
and
not
condition
.
startswith
(
'
!
'
):
print
(
'
Skipping check of %s with condition %s.
'
%
(
mount_point
,
condition
))
continue
elif
subdev
!=
dev
and
condition
.
startswith
(
'
!
'
):
print
(
'
Skipping check of %s with condition %s.
'
%
(
mount_point
,
condition
))
continue
if
fstype
not
in
part_info
.
get
(
'
recommended_types
'
):
print
(
'
Warning: %s fs type not recommended %s(current: %s, recommended: %s)%s.
'
%
(
name
,
YELLOW
,
fstype
,
part_info
[
'
recommended_types
'
],
DEF
))
warning
=
True
if
'
nfs
'
not
in
fstype
:
warning
=
not
check_allocation
(
dev
)
min_available_gbytes
=
p
.
get
(
'
min_available_gbytes
'
)
min_available_gbytes
=
p
art_info
.
get
(
'
min_available_gbytes
'
)
if
min_available_gbytes
and
available
<
min_available_gbytes
:
print
(
'
%s has less than %s GB available %s(%s GB available)%s.
'
%
(
name
,
min_available_gbytes
,
RED
,
available
,
DEF
))
error
=
True
else
:
print
(
'
%s has %s GB available.
'
%
(
name
,
available
))
print
(
'
%s has
more than
%s GB available
%s(%s GB available)%s
.
'
%
(
name
,
min_
available
_gbytes
,
GREEN
,
available
,
DEF
))
else
:
print
(
'
%s not found, cannot check.
'
%
mount_point
)
elif
p
.
get
(
'
type
'
)
==
'
memory
'
:
elif
p
art_info
.
get
(
'
type
'
)
==
'
memory
'
:
name
=
'
Memory
'
psize
=
get_memory_gbytes
()
if
psize
:
if
psize
<
p
[
'
min_size_gbytes
'
]:
print
(
'
%s is smaller than the minimum required size %s(%s GB < %s GB)%s.
'
%
(
name
,
RED
,
psize
,
p
[
'
min_size_gbytes
'
],
DEF
))
if
psize
<
p
art_info
[
'
min_size_gbytes
'
]:
print
(
'
%s is smaller than the minimum required size %s(%s GB < %s GB)%s.
'
%
(
name
,
RED
,
psize
,
p
art_info
[
'
min_size_gbytes
'
],
DEF
))
error
=
True
elif
psize
<
p
[
'
reco_size_gbytes
'
]:
print
(
'
%s is smaller than the recommended size %s(%s GB < %s GB)%s.
'
%
(
name
,
YELLOW
,
psize
,
p
[
'
reco_size_gbytes
'
],
DEF
))
elif
psize
<
p
art_info
[
'
reco_size_gbytes
'
]:
print
(
'
%s is smaller than the recommended size %s(%s GB < %s GB)%s.
'
%
(
name
,
YELLOW
,
psize
,
p
art_info
[
'
reco_size_gbytes
'
],
DEF
))
warning
=
True
else
:
print
(
'
%s is bigger than recommended size %s(%s GB >= %s GB)%s.
'
%
(
name
,
GREEN
,
psize
,
p
[
'
reco_size_gbytes
'
],
DEF
))
print
(
'
%s is bigger than recommended size %s(%s GB >= %s GB)%s.
'
%
(
name
,
GREEN
,
psize
,
p
art_info
[
'
reco_size_gbytes
'
],
DEF
))
if
error
:
print
(
'
Errors found.
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment