resiliency takeover script: create lock file stating that takeover has been done.

It will be used by equeue to prevent to run import scripts if detected.
Reason: if an import script is run AFTER takeover has been done, it may be stopped during its execution while slapgrid is run, causing the new-main instance not to behave correclty.
parent 168b6678
......@@ -28,7 +28,7 @@ from setuptools import setup, find_packages
import glob
import os
version = '0.94'
version = '0.95-dev0'
name = 'slapos.cookbook'
long_description = open("README.txt").read() + "\n" + \
open("CHANGES.txt").read() + "\n"
......
......@@ -53,6 +53,7 @@ class Recipe(GenericSlapRecipe):
'partition_id': slap_connection['partition-id'],
'software': slap_connection['software-release-url'],
'namebase': self.parameter_dict['namebase'],
'takeover_triggered_file_path': self.options['takeover-triggered-file-path'],
})
path_list.append(takeover_wrapper)
......
......@@ -11,7 +11,8 @@ logging.basicConfig(level=logging.DEBUG)
def takeover(server_url, key_file, cert_file, computer_guid,
partition_id, software_release, namebase,
winner_instance_suffix = None):
winner_instance_suffix = None,
takeover_triggered_file_path=None):
"""
This function does
......@@ -74,6 +75,10 @@ def takeover(server_url, key_file, cert_file, computer_guid,
# Note: Root instance will reconfigure itself the winning instance (software_type
# and parameters.)
# Create "lock" file preventing equeue to run import scripts
# XXX hardcoded
open(takeover_triggered_file_path, 'w').write('')
def run(args):
slapos.recipe.addresiliency.takeover.takeover(server_url = args.pop('server_url'),
key_file = args.pop('key_file'),
......@@ -81,5 +86,6 @@ def run(args):
computer_guid = args.pop('computer_id'),
partition_id = args.pop('partition_id'),
software_release = args.pop('software'),
namebase = args.pop('namebase'))
namebase = args.pop('namebase'),
takeover_triggered_file_path = args.pop('takeover_triggered_file_path'))
......@@ -36,6 +36,9 @@ class Recipe(GenericBaseRecipe):
'--lockfile', self.options['lockfile']
]
if 'takeover-triggered-file-path' in self.options:
parameters.extend(['--takeover-triggered-file-path', self.options['takeover-triggered-file-path']])
if 'loglevel' in self.options:
parameters.extend(['--loglevel', self.options['loglevel']])
......
......@@ -38,7 +38,7 @@ eggs = collective.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/pbsready.cfg.in
output = ${buildout:directory}/pbsready.cfg
md5sum = cbc5bdb360fb5c72418dba03135df526
md5sum = ec4f71330cccfa17ddb8fee51d2e6441
mode = 0644
[pbsready-import]
......@@ -47,7 +47,7 @@ mode = 0644
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/pbsready-import.cfg.in
output = ${buildout:directory}/pbsready-import.cfg
md5sum = a5570ecfeff7a9d1b5f8be08db4feefe
md5sum = 26c75eac66ce97abbb891ab6e806730c
mode = 0644
[pbsready-export]
......
......@@ -40,6 +40,12 @@ port = 22220
[notifier]
port = 65533
# Add path of file created by takeover script when takeover is triggered
# Takeover script will create this file
# equeue process will watch for file existence.
[equeue]
takeover-triggered-file-path = $${resiliency:takeover-triggered-file-path}
[import-on-notification]
# notifier.callback runs a script when a notification (sent by a parent PBS)
# is received
......
......@@ -133,9 +133,8 @@ rotate-num = 30
[resiliency]
recipe = slapos.cookbook:addresiliency
wrapper-takeover = takeover
services = $${basedirectory:services}
takeover-triggered-file-path = $${rootdirectory:srv}/takeover_triggered
bin = $${rootdirectory:bin}
etc = $${rootdirectory:etc}
#----------------
......
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