Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Nicolas Wavrant
slapos.core
Commits
9a5824ad
Commit
9a5824ad
authored
Jan 10, 2017
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SlapObject: when destroying a partition, no processes should be remaining
parent
aaa098a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+16
-1
No files found.
slapos/grid/SlapObject.py
View file @
9a5824ad
...
...
@@ -30,6 +30,7 @@
import
os
import
pkg_resources
import
psutil
import
pwd
import
shutil
import
stat
...
...
@@ -673,11 +674,12 @@ class Partition(object):
if
not
self
.
checkRetentionIsAuthorized
():
return
False
uid
,
gid
=
self
.
getUserGroupId
()
# Launches "destroy" binary if exists
destroy_executable_location
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'destroy'
)
if
os
.
path
.
exists
(
destroy_executable_location
):
uid
,
gid
=
self
.
getUserGroupId
()
self
.
logger
.
debug
(
'Invoking %r'
%
destroy_executable_location
)
process_handler
=
SlapPopen
([
destroy_executable_location
],
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
,
logger
=
self
.
logger
),
...
...
@@ -726,6 +728,19 @@ class Partition(object):
except
IOError
as
exc
:
raise
IOError
(
"I/O error while freeing partition (%s): %s"
%
(
self
.
instance_path
,
exc
))
# Kill remaining processes
try
:
current_pid
=
os
.
getpid
()
[
x
.
terminate
()
for
x
in
psutil
.
process_iter
()
if
uid
in
x
.
uids
()
and
x
.
pid
!=
current_pid
]
except
(
psutil
.
NoSuchProcess
,
psutil
.
AccessDenied
)
as
e
:
self
.
logger
.
info
(
"Process finished before being "
"killed when freeing partition %s"
%
self
.
instance_path
)
except
psutil
.
TimeoutExpired
as
e
:
self
.
logger
.
error
(
"Couldn't kill process %s of destroyed partition %s"
%
self
.
instance_path
)
return
True
def
cleanupFolder
(
self
,
folder_path
):
...
...
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