Commit c37434ae authored by Yusei Tahara's avatar Yusei Tahara

Change parameters. Add `serious_services` and `autostart_services`.

parent 95a2a43e
...@@ -17,10 +17,14 @@ part_id = os.getenv('OCF_RESKEY_part_id') ...@@ -17,10 +17,14 @@ part_id = os.getenv('OCF_RESKEY_part_id')
slappart = 'slappart%s' % part_id slappart = 'slappart%s' % part_id
slappart_b = slappart.encode('utf8') slappart_b = slappart.encode('utf8')
slapuser = 'slapuser%s' % part_id slapuser = 'slapuser%s' % part_id
service_list = [] serious_service_list = []
services_text = os.getenv('OCF_RESKEY_services', None) serious_services_text = os.getenv('OCF_RESKEY_serious_services', None)
if services_text: if serious_services_text:
service_list = services_text.split(',') serious_service_list = serious_services_text.split(',')
autostart_service_list = []
autostart_services_text = os.getenv('OCF_RESKEY_autostart_services', None)
if autostart_services_text:
autostart_service_list = autostart_services_text.split(',')
#kumofs_gateway,kumofs_manager,kumofs_server,mariadb,zeo,zope,haproxy #kumofs_gateway,kumofs_manager,kumofs_server,mariadb,zeo,zope,haproxy
...@@ -61,27 +65,25 @@ def checkAppStatus(target_status): ...@@ -61,27 +65,25 @@ def checkAppStatus(target_status):
return True return True
else: else:
return False return False
error_list = [] service_data_list = []
service_status_dict = {}
for service in service_list:
service_status_dict[service] = []
for line in completed_process.stdout.split(b'\n'): for line in completed_process.stdout.split(b'\n'):
if not line: if not line:
continue continue
split_line = splitLine(line) split_line = splitLine(line)
if split_line[0].decode('utf8') == 'watchdog': if split_line[0].decode('utf8') == 'watchdog':
continue continue
service_id = split_line[0].decode('utf8')
service_name = split_line[0].split(b':')[1].split(b'-')[0].decode('utf8') service_name = split_line[0].split(b':')[1].split(b'-')[0].decode('utf8')
current_status = split_line[1].decode('utf8') current_status = split_line[1].decode('utf8')
if service_name in service_status_dict: service_data_list.append((service_id, service_name, current_status))
service_status_dict[service_name].append(current_status) for service_id, service_name, current_status in service_data_list:
if service_name in serious_service_list:
if current_status != target_status: if current_status != target_status:
error_list.append(line)
if error_list:
return False
for service in service_status_dict:
if set(service_status_dict[service]) != set([target_status]):
return False return False
if target_status == 'RUNNING' and autostart_service_list:
for service_id, service_name, current_status in service_data_list:
if current_status == 'EXITED' and service_name in autostart_service_list:
runSlapOSInTheia('node', 'start', service_id)
return True return True
def isAppRunning(): def isAppRunning():
...@@ -157,11 +159,21 @@ Computer Partition ID, slappartX ...@@ -157,11 +159,21 @@ Computer Partition ID, slappartX
<shortdesc>Partition ID</shortdesc> <shortdesc>Partition ID</shortdesc>
<content type="integer"/> <content type="integer"/>
</parameter> </parameter>
<parameter name="services" unique="0" required="1"> <parameter name="serious_services" unique="0" required="0">
<longdesc>
Serious service names separated by comma
If serious service fails, then this resource is considered as failed.
</longdesc>
<shortdesc>Serious service names</shortdesc>
<content type="string"/>
</parameter>
<parameter name="autostart_services" unique="0" required="0">
<longdesc> <longdesc>
Service names separated by comma Auto-start service names separated by comma
If auto-start service becomes `EXITED`, then `slapos node start` is executed
automatically and it is not considered as failed.
</longdesc> </longdesc>
<shortdesc>Service names</shortdesc> <shortdesc>Auto-start service names</shortdesc>
<content type="string"/> <content type="string"/>
</parameter> </parameter>
</parameters> </parameters>
...@@ -169,7 +181,7 @@ Service names separated by comma ...@@ -169,7 +181,7 @@ Service names separated by comma
<actions> <actions>
<action name="start" timeout="60s" /> <action name="start" timeout="60s" />
<action name="stop" timeout="60s" /> <action name="stop" timeout="60s" />
<action name="monitor" depth="0" timeout="20s" interval="60s" /> <action name="monitor" depth="0" timeout="30s" interval="60s" />
<action name="meta-data" timeout="5s" /> <action name="meta-data" timeout="5s" />
</actions> </actions>
</resource-agent> </resource-agent>
......
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