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
Xavier Thompson
slapos.core
Commits
2a49396e
Commit
2a49396e
authored
Mar 22, 2023
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SlapObject: Refactor supervisord config handling
parent
139173b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+16
-7
slapos/tests/test_object.py
slapos/tests/test_object.py
+7
-7
No files found.
slapos/grid/SlapObject.py
View file @
2a49396e
...
@@ -708,7 +708,7 @@ class Partition(object):
...
@@ -708,7 +708,7 @@ class Partition(object):
logger
=
self
.
logger
,
logger
=
self
.
logger
,
debug
=
self
.
buildout_debug
,
debug
=
self
.
buildout_debug
,
timeout
=
self
.
partition_timeout
)
timeout
=
self
.
partition_timeout
)
self
.
generateSupervisorConfigurationFile
()
self
.
updateSupervisorConfiguration
()
self
.
createRetentionLockDelay
()
self
.
createRetentionLockDelay
()
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
self
.
instance_python
=
getPythonExecutableFromSoftwarePath
(
self
.
software_path
)
...
@@ -734,8 +734,6 @@ class Partition(object):
...
@@ -734,8 +734,6 @@ class Partition(object):
if
len
(
runner_list
)
==
0
and
len
(
service_list
)
==
0
:
if
len
(
runner_list
)
==
0
and
len
(
service_list
)
==
0
:
self
.
logger
.
warning
(
'No runners nor services found for partition %r'
%
self
.
logger
.
warning
(
'No runners nor services found for partition %r'
%
self
.
partition_id
)
self
.
partition_id
)
if
os
.
path
.
exists
(
self
.
supervisord_partition_configuration_path
):
os
.
unlink
(
self
.
supervisord_partition_configuration_path
)
else
:
else
:
partition_id
=
self
.
computer_partition
.
getId
()
partition_id
=
self
.
computer_partition
.
getId
()
group_partition_template
=
bytes2str
(
pkg_resources
.
resource_string
(
__name__
,
group_partition_template
=
bytes2str
(
pkg_resources
.
resource_string
(
__name__
,
...
@@ -759,9 +757,22 @@ class Partition(object):
...
@@ -759,9 +757,22 @@ class Partition(object):
updateFile
(
self
.
supervisord_partition_configuration_path
,
updateFile
(
self
.
supervisord_partition_configuration_path
,
self
.
supervisor_configuration_group
+
self
.
supervisor_configuration_group
+
self
.
partition_supervisor_configuration
)
self
.
partition_supervisor_configuration
)
self
.
updateSupervisor
()
else
:
self
.
removeSupervisorConfigurationFile
()
def
removeSupervisorConfigurationFile
(
self
):
"""
Remove supervisord configuration file if it exists and update supervisord
"""
try
:
os
.
unlink
(
self
.
supervisord_partition_configuration_path
)
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
self
.
updateSupervisor
()
self
.
updateSupervisor
()
def
generateSupervisorConfigurationFile
(
self
):
def
updateSupervisorConfiguration
(
self
):
"""
"""
update supervisord with new processes
update supervisord with new processes
"""
"""
...
@@ -856,9 +867,7 @@ class Partition(object):
...
@@ -856,9 +867,7 @@ class Partition(object):
# Cleanup all Data storage location of this partition
# Cleanup all Data storage location of this partition
if
os
.
path
.
exists
(
self
.
supervisord_partition_configuration_path
):
self
.
removeSupervisorConfigurationFile
()
os
.
remove
(
self
.
supervisord_partition_configuration_path
)
self
.
updateSupervisor
()
except
IOError
as
exc
:
except
IOError
as
exc
:
raise
IOError
(
"I/O error while freeing partition (%s): %s"
%
(
self
.
instance_path
,
exc
))
raise
IOError
(
"I/O error while freeing partition (%s): %s"
%
(
self
.
instance_path
,
exc
))
...
...
slapos/tests/test_object.py
View file @
2a49396e
...
@@ -87,7 +87,7 @@ original_upload_network_cached = networkcache.upload_network_cached
...
@@ -87,7 +87,7 @@ original_upload_network_cached = networkcache.upload_network_cached
originalBootstrapBuildout
=
utils
.
bootstrapBuildout
originalBootstrapBuildout
=
utils
.
bootstrapBuildout
originalLaunchBuildout
=
utils
.
launchBuildout
originalLaunchBuildout
=
utils
.
launchBuildout
originalUploadSoftwareRelease
=
Software
.
uploadSoftwareRelease
originalUploadSoftwareRelease
=
Software
.
uploadSoftwareRelease
originalPartition
GenerateSupervisorConfigurationFile
=
Partition
.
generateSupervisorConfigurationFile
originalPartition
UpdateSupervisorConfiguration
=
Partition
.
updateSupervisorConfiguration
class
MasterMixin
(
BasicMixin
,
unittest
.
TestCase
):
class
MasterMixin
(
BasicMixin
,
unittest
.
TestCase
):
"""
"""
...
@@ -378,14 +378,14 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
...
@@ -378,14 +378,14 @@ class TestPartitionSlapObject(MasterMixin, unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
MasterMixin
.
setUp
(
self
)
MasterMixin
.
setUp
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
FakeCallAndNoop
()
Partition
.
updateSupervisorConfiguration
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
launchBuildout
=
FakeCallAndStore
()
utils
.
launchBuildout
=
FakeCallAndStore
()
def
tearDown
(
self
):
def
tearDown
(
self
):
MasterMixin
.
tearDown
(
self
)
MasterMixin
.
tearDown
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
originalPartitionGenerateSupervisorConfigurationFile
Partition
.
updateSupervisorConfiguration
=
originalPartitionUpdateSupervisorConfiguration
def
test_partition_timeout_default
(
self
):
def
test_partition_timeout_default
(
self
):
software
=
self
.
createSoftware
()
software
=
self
.
createSoftware
()
...
@@ -544,13 +544,13 @@ class TestPartitionSupervisorConfig(MasterMixin, unittest.TestCase):
...
@@ -544,13 +544,13 @@ class TestPartitionSupervisorConfig(MasterMixin, unittest.TestCase):
class
TestPartitionDestructionLock
(
MasterMixin
,
unittest
.
TestCase
):
class
TestPartitionDestructionLock
(
MasterMixin
,
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
MasterMixin
.
setUp
(
self
)
MasterMixin
.
setUp
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
FakeCallAndNoop
()
Partition
.
updateSupervisorConfiguration
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
launchBuildout
=
FakeCallAndStore
()
utils
.
launchBuildout
=
FakeCallAndStore
()
def
tearDown
(
self
):
def
tearDown
(
self
):
MasterMixin
.
tearDown
(
self
)
MasterMixin
.
tearDown
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
originalPartitionGenerateSupervisorConfigurationFile
Partition
.
updateSupervisorConfiguration
=
originalPartitionUpdateSupervisorConfiguration
def
test_retention_lock_delay_creation
(
self
):
def
test_retention_lock_delay_creation
(
self
):
delay
=
42
delay
=
42
...
@@ -640,13 +640,13 @@ class TestPartitionDestructionLock(MasterMixin, unittest.TestCase):
...
@@ -640,13 +640,13 @@ class TestPartitionDestructionLock(MasterMixin, unittest.TestCase):
class
TestPartitionDestructionUnwritable
(
MasterMixin
,
unittest
.
TestCase
):
class
TestPartitionDestructionUnwritable
(
MasterMixin
,
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
MasterMixin
.
setUp
(
self
)
MasterMixin
.
setUp
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
FakeCallAndNoop
()
Partition
.
updateSupervisorConfiguration
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
bootstrapBuildout
=
FakeCallAndNoop
()
utils
.
launchBuildout
=
FakeCallAndStore
()
utils
.
launchBuildout
=
FakeCallAndStore
()
def
tearDown
(
self
):
def
tearDown
(
self
):
MasterMixin
.
tearDown
(
self
)
MasterMixin
.
tearDown
(
self
)
Partition
.
generateSupervisorConfigurationFile
=
originalPartitionGenerateSupervisorConfigurationFile
Partition
.
updateSupervisorConfiguration
=
originalPartitionUpdateSupervisorConfiguration
def
test
(
self
):
def
test
(
self
):
software
=
self
.
createSoftware
()
software
=
self
.
createSoftware
()
...
...
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