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
Łukasz Nowak
slapos.core
Commits
edc9d216
Commit
edc9d216
authored
May 05, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[slapos.grid] Place instance logs on instance side.
parent
e468b364
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
54 deletions
+74
-54
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+74
-54
No files found.
slapos/grid/slapgrid.py
View file @
edc9d216
...
@@ -39,6 +39,7 @@ import tempfile
...
@@ -39,6 +39,7 @@ import tempfile
import
time
import
time
import
traceback
import
traceback
import
warnings
import
warnings
import
logging
if
sys
.
version_info
<
(
2
,
6
):
if
sys
.
version_info
<
(
2
,
6
):
warnings
.
warn
(
'Used python version (%s) is old and has problems with'
warnings
.
warn
(
'Used python version (%s) is old and has problems with'
...
@@ -48,6 +49,7 @@ from lxml import etree
...
@@ -48,6 +49,7 @@ from lxml import etree
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
NotFoundError
from
slapos.slap.slap
import
ServerError
from
slapos.slap.slap
import
ServerError
from
slapos.util
import
mkdir_p
,
chownDirectory
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.SlapObject
import
Software
,
Partition
from
slapos.grid.SlapObject
import
Software
,
Partition
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.svcbackend
import
launchSupervisord
...
@@ -606,63 +608,81 @@ class Slapgrid(object):
...
@@ -606,63 +608,81 @@ class Slapgrid(object):
os
.
remove
(
timestamp_path
)
os
.
remove
(
timestamp_path
)
self
.
logger
.
exception
(
''
)
self
.
logger
.
exception
(
''
)
self
.
logger
.
info
(
'Processing Computer Partition %s.'
%
computer_partition_id
)
# Include Partition Logging
self
.
logger
.
info
(
' Software URL: %s'
%
software_url
)
log_folder_path
=
"%s/.slapgrid/log"
%
instance_path
self
.
logger
.
info
(
' Software path: %s'
%
software_path
)
mkdir_p
(
log_folder_path
)
self
.
logger
.
info
(
' Instance path: %s'
%
instance_path
)
partition_file_handler
=
logging
.
FileHandler
(
filename
=
"%s/instance.log"
%
(
log_folder_path
)
local_partition
=
Partition
(
)
software_path
=
software_path
,
stat_info
=
os
.
stat
(
instance_path
)
instance_path
=
instance_path
,
chownDirectory
(
"%s/.slapgrid"
%
instance_path
,
supervisord_partition_configuration_path
=
os
.
path
.
join
(
uid
=
stat_info
.
st_uid
,
self
.
supervisord_configuration_directory
,
'%s.conf'
%
gid
=
stat_info
.
st_gid
)
computer_partition_id
),
supervisord_socket
=
self
.
supervisord_socket
,
formatter
=
logging
.
Formatter
(
computer_partition
=
computer_partition
,
'[%(asctime)s] %(levelname)-8s %(name)s %(message)s'
)
computer_id
=
self
.
computer_id
,
partition_file_handler
.
setFormatter
(
formatter
)
partition_id
=
computer_partition_id
,
self
.
logger
.
addHandler
(
partition_file_handler
)
server_url
=
self
.
master_url
,
software_release_url
=
software_url
,
try
:
certificate_repository_path
=
self
.
certificate_repository_path
,
self
.
logger
.
info
(
'Processing Computer Partition %s.'
%
computer_partition_id
)
buildout
=
self
.
buildout
,
self
.
logger
.
info
(
' Software URL: %s'
%
software_url
)
logger
=
self
.
logger
)
self
.
logger
.
info
(
' Software path: %s'
%
software_path
)
self
.
logger
.
info
(
' Instance path: %s'
%
instance_path
)
computer_partition_state
=
computer_partition
.
getState
()
local_partition
=
Partition
(
# XXX this line breaks 37 tests
software_path
=
software_path
,
# self.logger.info(' Instance type: %s' % computer_partition.getType())
instance_path
=
instance_path
,
self
.
logger
.
info
(
' Instance status: %s'
%
computer_partition_state
)
supervisord_partition_configuration_path
=
os
.
path
.
join
(
self
.
supervisord_configuration_directory
,
'%s.conf'
%
if
computer_partition_state
==
COMPUTER_PARTITION_STARTED_STATE
:
computer_partition_id
),
local_partition
.
install
()
supervisord_socket
=
self
.
supervisord_socket
,
computer_partition
.
available
()
computer_partition
=
computer_partition
,
local_partition
.
start
()
computer_id
=
self
.
computer_id
,
self
.
_checkPromises
(
computer_partition
)
partition_id
=
computer_partition_id
,
computer_partition
.
started
()
server_url
=
self
.
master_url
,
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
software_release_url
=
software_url
,
try
:
certificate_repository_path
=
self
.
certificate_repository_path
,
# We want to process the partition, even if stopped, because it should
buildout
=
self
.
buildout
,
# propagate the state to children if any.
logger
=
self
.
logger
)
computer_partition_state
=
computer_partition
.
getState
()
# XXX this line breaks 37 tests
# self.logger.info(' Instance type: %s' % computer_partition.getType())
self
.
logger
.
info
(
' Instance status: %s'
%
computer_partition_state
)
if
computer_partition_state
==
COMPUTER_PARTITION_STARTED_STATE
:
local_partition
.
install
()
local_partition
.
install
()
computer_partition
.
available
()
computer_partition
.
available
()
finally
:
local_partition
.
start
()
# Instance has to be stopped even if buildout/reporting is wrong.
self
.
_checkPromises
(
computer_partition
)
local_partition
.
stop
()
computer_partition
.
started
()
computer_partition
.
stopped
()
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
elif
computer_partition_state
==
COMPUTER_PARTITION_DESTROYED_STATE
:
try
:
local_partition
.
stop
()
# We want to process the partition, even if stopped, because it should
try
:
# propagate the state to children if any.
local_partition
.
install
()
computer_partition
.
available
()
finally
:
# Instance has to be stopped even if buildout/reporting is wrong.
local_partition
.
stop
()
computer_partition
.
stopped
()
computer_partition
.
stopped
()
except
(
SystemExit
,
KeyboardInterrupt
):
elif
computer_partition_state
==
COMPUTER_PARTITION_DESTROYED_STATE
:
computer_partition
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
local_partition
.
stop
()
raise
try
:
except
Exception
:
computer_partition
.
stopped
()
pass
except
(
SystemExit
,
KeyboardInterrupt
):
else
:
computer_partition
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
error_string
=
"Computer Partition %r has unsupported state: %s"
%
\
raise
(
computer_partition_id
,
computer_partition_state
)
except
Exception
:
computer_partition
.
error
(
error_string
,
logger
=
self
.
logger
)
pass
raise
NotImplementedError
(
error_string
)
else
:
error_string
=
"Computer Partition %r has unsupported state: %s"
%
\
(
computer_partition_id
,
computer_partition_state
)
computer_partition
.
error
(
error_string
,
logger
=
self
.
logger
)
raise
NotImplementedError
(
error_string
)
finally
:
self
.
logger
.
removeHandler
(
partition_file_handler
)
# If partition has been successfully processed, write timestamp
# If partition has been successfully processed, write timestamp
if
timestamp
:
if
timestamp
:
...
...
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