Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos
Commits
0983f1ca
Commit
0983f1ca
authored
Apr 19, 2021
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kvm: Fix disk wipe if many disks are used
parent
43b029e1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
21 deletions
+51
-21
software/kvm/buildout.hash.cfg
software/kvm/buildout.hash.cfg
+1
-1
software/kvm/instance-kvm.cfg.jinja2
software/kvm/instance-kvm.cfg.jinja2
+7
-5
software/kvm/test/test.py
software/kvm/test/test.py
+43
-15
No files found.
software/kvm/buildout.hash.cfg
View file @
0983f1ca
...
@@ -19,7 +19,7 @@ md5sum = 0d34ff81779115bf899f7bc752877b70
...
@@ -19,7 +19,7 @@ md5sum = 0d34ff81779115bf899f7bc752877b70
[template-kvm]
[template-kvm]
filename = instance-kvm.cfg.jinja2
filename = instance-kvm.cfg.jinja2
md5sum =
4c5d8c723b6adb96fcac9690c0c900f7
md5sum =
9d0980144f91d10d8a5cee041f385d34
[template-kvm-cluster]
[template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in
filename = instance-kvm-cluster.cfg.jinja2.in
...
...
software/kvm/instance-kvm.cfg.jinja2
View file @
0983f1ca
...
@@ -1031,11 +1031,13 @@ context =
...
@@ -1031,11 +1031,13 @@ context =
{% do part_list.append('wipe-disk-device-wrapper') -%}
{% do part_list.append('wipe-disk-device-wrapper') -%}
[wipe-disk-device-wrapper]
[wipe-disk-device-wrapper]
recipe = slapos.cookbook:wrapper
recipe = slapos.recipe.template:jinja2
wrapper-path = ${directory:prerm}/slapos_wipe_device_disk
template = inline:
command-line =
{%- for disk_device in disk_device_path.split() %}
dd if=/dev/zero of={{disk_device_path}} bs=4096 count=500k
dd if=/dev/zero of={{ disk_device }} bs=4096 count=500k
{%- endfor %}
rendered = ${directory:prerm}/slapos_wipe_device_disk
mode = 0700
{% endif -%}
{% endif -%}
{% do part_list.append('whitelist-firewall') -%}
{% do part_list.append('whitelist-firewall') -%}
...
...
software/kvm/test/test.py
View file @
0983f1ca
...
@@ -127,6 +127,20 @@ class KvmMixin(object):
...
@@ -127,6 +127,20 @@ class KvmMixin(object):
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
if
q
[
'name'
]
!=
'watchdog'
and
q
[
'group'
]
!=
'watchdog'
]))
return
running_process_info
.
replace
(
hash_value
,
'{hash}'
)
return
running_process_info
.
replace
(
hash_value
,
'{hash}'
)
def
raising_waitForInstance
(
self
,
max_retry
):
with
self
.
assertRaises
(
SlapOSNodeCommandError
):
self
.
slap
.
waitForInstance
(
max_retry
=
max_retry
)
def
rerequestInstance
(
self
,
parameter_dict
,
state
=
'started'
):
software_url
=
self
.
getSoftwareURL
()
software_type
=
self
.
getInstanceSoftwareType
()
return
self
.
slap
.
request
(
software_release
=
software_url
,
software_type
=
software_type
,
partition_reference
=
self
.
default_partition_reference
,
partition_parameter_kw
=
parameter_dict
,
state
=
state
)
@
skipUnlessKvm
@
skipUnlessKvm
class
TestInstance
(
InstanceTestCase
,
KvmMixin
):
class
TestInstance
(
InstanceTestCase
,
KvmMixin
):
...
@@ -582,17 +596,7 @@ class FakeImageHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -582,17 +596,7 @@ class FakeImageHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
return
return
class
FakeImageServerMixin
(
object
):
class
FakeImageServerMixin
(
KvmMixin
):
def
rerequestInstance
(
self
,
parameter_dict
,
state
=
'started'
):
software_url
=
self
.
getSoftwareURL
()
software_type
=
self
.
getInstanceSoftwareType
()
return
self
.
slap
.
request
(
software_release
=
software_url
,
software_type
=
software_type
,
partition_reference
=
self
.
default_partition_reference
,
partition_parameter_kw
=
parameter_dict
,
state
=
state
)
def
startImageHttpServer
(
self
):
def
startImageHttpServer
(
self
):
self
.
image_source_directory
=
tempfile
.
mkdtemp
()
self
.
image_source_directory
=
tempfile
.
mkdtemp
()
server
=
SocketServer
.
TCPServer
(
server
=
SocketServer
.
TCPServer
(
...
@@ -689,10 +693,6 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
...
@@ -689,10 +693,6 @@ class TestBootImageUrlList(InstanceTestCase, FakeImageServerMixin):
self
.
stopImageHttpServer
()
self
.
stopImageHttpServer
()
super
(
InstanceTestCase
,
self
).
tearDown
()
super
(
InstanceTestCase
,
self
).
tearDown
()
def
raising_waitForInstance
(
self
,
max_retry
):
with
self
.
assertRaises
(
SlapOSNodeCommandError
):
self
.
slap
.
waitForInstance
(
max_retry
=
max_retry
)
def
test
(
self
):
def
test
(
self
):
partition_parameter_kw
=
{
partition_parameter_kw
=
{
self
.
key
:
self
.
test_input
%
(
self
.
key
:
self
.
test_input
%
(
...
@@ -1270,3 +1270,31 @@ class TestWhitelistFirewallRequestCluster(TestWhitelistFirewallRequest):
...
@@ -1270,3 +1270,31 @@ class TestWhitelistFirewallRequestCluster(TestWhitelistFirewallRequest):
}
}
}
}
})}
})}
@
skipUnlessKvm
class
TestDiskDevicePathWipeDiskOndestroy
(
InstanceTestCase
,
KvmMixin
):
__partition_reference__
=
'ddpwdo'
kvm_instance_partition_reference
=
'ddpwdo0'
def
test
(
self
):
self
.
rerequestInstance
({
'disk-device-path'
:
'/dev/virt0 /dev/virt1'
,
'wipe-disk-ondestroy'
:
True
})
self
.
slap
.
waitForInstance
(
max_retry
=
2
)
instance_path
=
os
.
path
.
join
(
self
.
slap
.
instance_directory
,
self
.
kvm_instance_partition_reference
)
slapos_wipe_device_disk
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'prerm'
,
'slapos_wipe_device_disk'
)
# check prerm script, it's trusted that prerm manager really works
self
.
assertTrue
(
os
.
path
.
exists
(
slapos_wipe_device_disk
))
with
open
(
slapos_wipe_device_disk
)
as
fh
:
self
.
assertEqual
(
fh
.
read
().
strip
(),
r"""dd if=/dev/zero of=/dev/virt0 bs=4096 count=500k
dd if=/dev/zero of=/dev/virt1 bs=4096 count=500k"""
)
self
.
assertTrue
(
os
.
access
(
slapos_wipe_device_disk
,
os
.
X_OK
))
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