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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Lorenzo Martinico
slapos
Commits
fdffce00
Commit
fdffce00
authored
Dec 09, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch pbs promise timeout to sigterm catch.
parent
a48250ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
9 deletions
+32
-9
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+32
-9
No files found.
slapos/recipe/pbs.py
View file @
fdffce00
...
@@ -30,7 +30,8 @@ from urlparse import urlparse
...
@@ -30,7 +30,8 @@ from urlparse import urlparse
import
os
import
os
import
subprocess
import
subprocess
import
sys
import
sys
import
time
import
signal
import
inspect
from
slapos.recipe.librecipe
import
GenericSlapRecipe
from
slapos.recipe.librecipe
import
GenericSlapRecipe
from
slapos.recipe.dropbear
import
KnownHostsFile
from
slapos.recipe.dropbear
import
KnownHostsFile
...
@@ -40,9 +41,37 @@ from slapos import slap as slapmodule
...
@@ -40,9 +41,37 @@ from slapos import slap as slapmodule
def
promise
(
args
):
def
promise
(
args
):
def
sigterm_handler
(
signum
,
frame
):
# Walk up in the stack to get promise local
# variables
ssh
=
None
for
upper_frame
in
inspect
.
getouterframes
(
frame
):
# Use promise.func_name insteand of 'promise' in order to be
# detected by editor if promise func name change.
# Else, it's hard to debug this kind of error.
if
upper_frame
[
3
]
==
promise
.
func_name
:
try
:
partition
=
upper_frame
[
0
].
f_locals
[
'partition'
]
ssh
=
upper_frame
[
0
].
f_locals
[
'ssh'
]
except
KeyError
:
raise
SystemExit
(
"SIGTERM Send too soon."
)
break
# If ever promise function wasn't found in the stack.
if
ssh
is
None
:
raise
SystemExit
# Bad python 2 syntax, looking forward python 3 to have print(file=)
print
>>
sys
.
stderr
,
"SSH Connection failed"
ssh
.
terminate
()
partition
.
bang
(
"SSH Connection failed. rdiff-backup is unusable."
)
signal
.
signal
(
signal
.
SIGTERM
,
sigterm_handler
)
slap
=
slapmodule
.
slap
()
slap
=
slapmodule
.
slap
()
slap
.
initializeConnection
(
args
[
'server_url'
],
slap
.
initializeConnection
(
args
[
'server_url'
],
key_file
=
args
.
get
(
'key_file'
),
cert_file
=
args
.
get
(
'cert_file'
))
key_file
=
args
.
get
(
'key_file'
),
cert_file
=
args
.
get
(
'cert_file'
))
# This is used in sigterm_handler, it get it from the frame.
partition
=
slap
.
registerComputerPartition
(
args
[
'computer_id'
],
partition
=
slap
.
registerComputerPartition
(
args
[
'computer_id'
],
args
[
'partition_id'
])
args
[
'partition_id'
])
...
@@ -55,16 +84,10 @@ def promise(args):
...
@@ -55,16 +84,10 @@ def promise(args):
ssh
.
stdin
.
write
(
quitcommand
)
ssh
.
stdin
.
write
(
quitcommand
)
ssh
.
stdin
.
flush
()
ssh
.
stdin
.
flush
()
ssh
.
stdin
.
close
()
ssh
.
stdin
.
close
()
ssh
.
wait
()
time
.
sleep
(
2
)
if
ssh
.
poll
()
is
None
:
if
ssh
.
poll
()
is
None
:
ssh
.
kill
()
return
1
if
ssh
.
wait
()
!=
0
:
# Bad python 2 syntax, looking forward python 3 to have print(file=)
print
>>
sys
.
stderr
,
"SSH Connection failed"
partition
.
bang
(
"SSH Connection failed. rdiff-backup is unusable."
)
return
ssh
.
returncode
return
ssh
.
returncode
...
...
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