Commit 91335049 authored by Xavier Thompson's avatar Xavier Thompson Committed by Thomas Gambier

SlapObject: Fix supervisord config generation

Previous code matched way too many files as belonging to the current
partition and wrongly removed them as obsolete: e.g. when processing
slappart1, all the configuration files belonging to slappart10 would
systematically be deleted, as if they belonged to slappart1 and were
now out-of-date. Same for all partitions starting with 'slappart1',
such as slappart11, slappart12, etc.

This resulted in all services in slappart1X being stopped and started
repeatedly and very often: stopped during processing of slappart1 and
started during processing of slappart1X, with potentially several
minutes of downtime, and a high percentage of downtime.

This is a fixup of db98a521.
parent 7510f81d
...@@ -721,14 +721,18 @@ class Partition(object): ...@@ -721,14 +721,18 @@ class Partition(object):
self.addServicesToGroup( self.addServicesToGroup(
service_list, self.service_path, extension=WATCHDOG_MARK) service_list, self.service_path, extension=WATCHDOG_MARK)
def getSupervisorConfigurationFiles(self):
for f in os.listdir(self.supervisord_partition_configuration_dir):
if os.path.splitext(f)[0] == self.partition_id: # partition
yield f
elif f.startswith(self.partition_id + '-'): # manager
yield f
def writeSupervisorConfigurationFiles(self): def writeSupervisorConfigurationFiles(self):
""" """
Write supervisord configuration files and update supervisord Write supervisord configuration files and update supervisord
""" """
remaining = set( remaining = set(self.getSupervisorConfigurationFiles())
f for f in os.listdir(self.supervisord_partition_configuration_dir)
if f.startswith(self.partition_id)
)
for group, programs in self.supervisor_conf.items(): for group, programs in self.supervisor_conf.items():
filename = '%s.conf' % group filename = '%s.conf' % group
filepath = os.path.join( filepath = os.path.join(
...@@ -765,10 +769,7 @@ class Partition(object): ...@@ -765,10 +769,7 @@ class Partition(object):
""" """
Remove supervisord configuration files if any exist and update supervisord Remove supervisord configuration files if any exist and update supervisord
""" """
filenames = [ filenames = list(self.getSupervisorConfigurationFiles())
f for f in os.listdir(self.supervisord_partition_configuration_dir)
if f.startswith(self.partition_id)
]
for filename in filenames: for filename in filenames:
filepath = os.path.join( filepath = os.path.join(
self.supervisord_partition_configuration_dir, filename) self.supervisord_partition_configuration_dir, filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment