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
Ivan Tyagov
slapos.core
Commits
bd68b88c
Commit
bd68b88c
authored
Sep 21, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to stabilize partition checks.
Fix
77bc6c75
parent
dfc788b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
28 deletions
+40
-28
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+40
-28
No files found.
slapos/grid/slapgrid.py
View file @
bd68b88c
...
@@ -68,6 +68,7 @@ MANDATORY_PARAMETER_LIST = [
...
@@ -68,6 +68,7 @@ MANDATORY_PARAMETER_LIST = [
'software_root'
,
'software_root'
,
]
]
COMPUTER_PARTITION_DESTROYED_STATE
=
'destroyed'
def
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
):
def
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
):
"""Parses arguments either from command line, from method parameters or from
"""Parses arguments either from command line, from method parameters or from
...
@@ -618,7 +619,6 @@ class Slapgrid(object):
...
@@ -618,7 +619,6 @@ class Slapgrid(object):
logger
=
logging
.
getLogger
(
'ComputerPartitionProcessing'
)
logger
=
logging
.
getLogger
(
'ComputerPartitionProcessing'
)
computer_partition_id
=
computer_partition
.
getId
()
computer_partition_id
=
computer_partition
.
getId
()
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
logger
.
info
(
'Processing Computer Partition %s...'
%
computer_partition_id
)
logger
.
info
(
'Processing Computer Partition %s...'
%
computer_partition_id
)
...
@@ -626,8 +626,6 @@ class Slapgrid(object):
...
@@ -626,8 +626,6 @@ class Slapgrid(object):
# Those values should not be None or empty string or any falsy value
# Those values should not be None or empty string or any falsy value
if
not
computer_partition_id
:
if
not
computer_partition_id
:
raise
ValueError
(
'Computer Partition id is empty.'
)
raise
ValueError
(
'Computer Partition id is empty.'
)
if
not
software_url
:
raise
ValueError
(
'Software Release URL of Computer Partition is empty.'
)
# Check if we defined explicit list of partitions to process.
# Check if we defined explicit list of partitions to process.
# If so, if current partition not in this list, skip.
# If so, if current partition not in this list, skip.
...
@@ -645,9 +643,21 @@ class Slapgrid(object):
...
@@ -645,9 +643,21 @@ class Slapgrid(object):
else
:
else
:
timestamp
=
None
timestamp
=
None
try
:
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
except
NotFoundError
:
# Problem with instance: SR URI not set.
# Try to process it anyway, it may need to be deleted.
software_url
=
None
try
:
software_path
=
os
.
path
.
join
(
self
.
software_root
,
software_path
=
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
software_url
))
getSoftwareUrlHash
(
software_url
))
except
TypeError
:
# Problem with instance: SR URI not set.
# Try to process it anyway, it may need to be deleted.
software_path
=
None
if
software_path
:
# Get periodicity from periodicity file if not forced
# Get periodicity from periodicity file if not forced
if
not
self
.
force_periodicity
:
if
not
self
.
force_periodicity
:
periodicity_path
=
os
.
path
.
join
(
software_path
,
'periodicity'
)
periodicity_path
=
os
.
path
.
join
(
software_path
,
'periodicity'
)
...
@@ -677,9 +687,6 @@ class Slapgrid(object):
...
@@ -677,9 +687,6 @@ class Slapgrid(object):
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
logger
.
error
(
exception
)
logger
.
error
(
exception
)
software_path
=
os
.
path
.
join
(
self
.
software_root
,
getSoftwareUrlHash
(
software_url
))
local_partition
=
Partition
(
local_partition
=
Partition
(
software_path
=
software_path
,
software_path
=
software_path
,
instance_path
=
instance_path
,
instance_path
=
instance_path
,
...
@@ -707,7 +714,7 @@ class Slapgrid(object):
...
@@ -707,7 +714,7 @@ class Slapgrid(object):
computer_partition
.
available
()
computer_partition
.
available
()
local_partition
.
stop
()
local_partition
.
stop
()
computer_partition
.
stopped
()
computer_partition
.
stopped
()
elif
computer_partition_state
==
"destroyed"
:
elif
computer_partition_state
==
COMPUTER_PARTITION_DESTROYED_STATE
:
local_partition
.
stop
()
local_partition
.
stop
()
try
:
try
:
computer_partition
.
stopped
()
computer_partition
.
stopped
()
...
@@ -744,14 +751,19 @@ class Slapgrid(object):
...
@@ -744,14 +751,19 @@ class Slapgrid(object):
# even if something is terribly wrong while processing an instance, it
# even if something is terribly wrong while processing an instance, it
# won't prevent processing other ones.
# won't prevent processing other ones.
try
:
try
:
# If id or URL is not defined, then it is an empty partition.
computer_partition_path
=
os
.
path
.
join
(
self
.
instance_root
,
try
:
computer_partition
.
getId
())
computer_partition
.
getId
()
if
not
os
.
path
.
exists
(
computer_partition_path
):
computer_partition
.
getSoftwareRelease
().
getURI
()
raise
NotFoundError
(
'Partition directory %s does not exist.'
%
# XXX should test status as well. But getState() returns default
computer_partition_path
)
# value.
# Check state of partition. If it is in "destroyed" state, check if it
except
NotFoundError
:
# partition is actually installed in the Computer or if it is "free"
# No Software Release information: skip.
# partition
# XXX-Cedric: Temporary AND ugly solution to check if an instance
# is in the partition. Dangerous because not 100% sure it is empty
computer_partition_state
=
computer_partition
.
getState
()
if
computer_partition_state
==
COMPUTER_PARTITION_DESTROYED_STATE
and
\
os
.
listdir
(
computer_partition_path
)
==
[]:
continue
continue
# Process the partition itself
# Process the partition itself
...
@@ -1040,7 +1052,7 @@ class Slapgrid(object):
...
@@ -1040,7 +1052,7 @@ class Slapgrid(object):
report_usage_issue_cp_list
.
append
(
computer_partition_id
)
report_usage_issue_cp_list
.
append
(
computer_partition_id
)
for
computer_partition
in
computer_partition_list
:
for
computer_partition
in
computer_partition_list
:
if
computer_partition
.
getState
()
==
"destroyed"
:
if
computer_partition
.
getState
()
==
COMPUTER_PARTITION_DESTROYED_STATE
:
try
:
try
:
computer_partition_id
=
computer_partition
.
getId
()
computer_partition_id
=
computer_partition
.
getId
()
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
software_url
=
computer_partition
.
getSoftwareRelease
().
getURI
()
...
...
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