Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
slapos
Commits
1b6f936f
Commit
1b6f936f
authored
Oct 27, 2014
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed unused bully script - resilience now simpler and faster.
parent
ee253abb
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
13 additions
and
725 deletions
+13
-725
slapos/recipe/addresiliency/__init__.py
slapos/recipe/addresiliency/__init__.py
+0
-36
slapos/recipe/addresiliency/bully.py
slapos/recipe/addresiliency/bully.py
+0
-241
slapos/recipe/addresiliency/template/bully.conf.in
slapos/recipe/addresiliency/template/bully.conf.in
+0
-2
slapos/recipe/addresiliency/template/bully.py.in
slapos/recipe/addresiliency/template/bully.py.in
+0
-134
slapos/recipe/addresiliency/template/bully_new.py.in
slapos/recipe/addresiliency/template/bully_new.py.in
+0
-278
stack/lamp/buildout.cfg
stack/lamp/buildout.cfg
+1
-1
stack/lamp/instance-resilient.cfg.jinja2
stack/lamp/instance-resilient.cfg.jinja2
+1
-1
stack/lapp/buildout.cfg
stack/lapp/buildout.cfg
+1
-1
stack/lapp/instance-resilient.cfg.jinja2
stack/lapp/instance-resilient.cfg.jinja2
+1
-1
stack/resilient/buildout.cfg
stack/resilient/buildout.cfg
+4
-4
stack/resilient/pbsready.cfg.in
stack/resilient/pbsready.cfg.in
+1
-5
stack/resilient/template-parts.cfg.in
stack/resilient/template-parts.cfg.in
+0
-2
stack/resilient/template-replicated.cfg.in
stack/resilient/template-replicated.cfg.in
+4
-19
No files found.
slapos/recipe/addresiliency/__init__.py
View file @
1b6f936f
...
...
@@ -40,44 +40,8 @@ class Recipe(GenericSlapRecipe):
def
_install
(
self
):
path_list
=
[]
confpath
=
os
.
path
.
join
(
self
.
options
[
'etc'
],
'bully.conf'
)
ip_list
=
self
.
parameter_dict
[
'ip-list'
]
print
'Creating bully configuration with ips : %s
\
n
'
%
ip_list
conf
=
self
.
createFile
(
confpath
,
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'bully.conf.in'
),
{
'self_id'
:
int
(
self
.
parameter_dict
[
'number'
]),
'ip_list'
:
ip_list
}
))
path_list
.
append
(
conf
)
slap_connection
=
self
.
buildout
[
'slap-connection'
]
if
self
.
optionIsTrue
(
'enable-bully-service'
,
default
=
False
):
bully_dir
=
self
.
options
[
'services'
]
else
:
bully_dir
=
self
.
options
[
'bin'
]
bully_wrapper
=
self
.
createPythonScript
(
name
=
os
.
path
.
join
(
bully_dir
,
self
.
options
[
'wrapper-bully'
]),
absolute_function
=
'slapos.recipe.addresiliency.bully.run'
,
arguments
=
{
'confpath'
:
confpath
,
'server_url'
:
slap_connection
[
'server-url'
],
'key_file'
:
slap_connection
.
get
(
'key-file'
),
'cert_file'
:
slap_connection
.
get
(
'cert-file'
),
'computer_id'
:
slap_connection
[
'computer-id'
],
'partition_id'
:
slap_connection
[
'partition-id'
],
'software'
:
slap_connection
[
'software-release-url'
],
'namebase'
:
self
.
parameter_dict
[
'namebase'
],
})
path_list
.
append
(
bully_wrapper
)
takeover_wrapper
=
self
.
createPythonScript
(
name
=
os
.
path
.
join
(
self
.
options
[
'bin'
],
self
.
options
[
'wrapper-takeover'
]),
absolute_function
=
'slapos.recipe.addresiliency.takeover.run'
,
...
...
slapos/recipe/addresiliency/bully.py
deleted
100644 → 0
View file @
ee253abb
# -*- coding: utf-8 -*-
import
logging
import
Queue
import
socket
import
thread
import
time
import
slapos.recipe.addresiliency.renamer
import
slapos
log
=
logging
.
getLogger
(
__name__
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
BASE_PORT
=
50000
SLEEPING_MINS
=
2
# XXX was 30, increase after testing
MSG_PING
=
'ping'
MSG_HALT
=
'halt'
MSG_VICTORY
=
'victory'
MSG_OK
=
'ok'
STATE_NORMAL
=
'normal'
STATE_WAITINGCONFIRM
=
'waitingConfirm'
STATE_ELECTION
=
'election'
STATE_REORGANIZATION
=
'reorganization'
## Leader is always number 0
class
ResilientInstance
(
object
):
def
__init__
(
self
,
comm
,
renamer
,
confpath
):
self
.
comm
=
comm
self
.
participant_id
=
0
self
.
state
=
STATE_NORMAL
self
.
halter_id
=
0
self
.
inElection
=
False
self
.
alive
=
True
self
.
mainCanal
=
self
.
comm
.
create_canal
([
MSG_PING
,
MSG_HALT
,
MSG_VICTORY
])
self
.
renamer
=
renamer
self
.
okCanal
=
self
.
comm
.
create_canal
([
MSG_OK
])
self
.
confpath
=
confpath
self
.
loadConnectionInfo
()
def
loadConnectionInfo
(
self
):
params
=
open
(
self
.
confpath
,
'r'
).
readlines
()
self
.
total_participants
=
len
(
params
[
0
].
split
())
new_id
=
int
(
params
[
1
])
if
self
.
participant_id
!=
new_id
:
self
.
halter_id
=
new_id
self
.
participant_id
=
new_id
log
.
debug
(
'I am {} of {}'
.
format
(
self
.
participant_id
,
self
.
total_participants
))
## Needs to be changed to use the master
def
aliveManagement
(
self
):
while
self
.
alive
:
log
.
info
(
'XXX sleeping for %d minutes'
%
SLEEPING_MINS
)
time
.
sleep
(
SLEEPING_MINS
*
60
)
if
self
.
participant_id
==
0
:
continue
self
.
comm
.
send
(
MSG_PING
,
0
)
message
,
sender
=
self
.
okCanal
.
get
()
if
message
:
continue
self
.
election
()
def
listen
(
self
):
while
self
.
alive
:
self
.
comm
.
recv
()
def
main
(
self
):
while
self
.
alive
:
message
,
sender
=
self
.
mainCanal
.
get
()
if
message
==
MSG_PING
:
self
.
comm
.
send
(
MSG_OK
,
sender
)
elif
message
==
MSG_HALT
:
self
.
state
=
STATE_WAITINGCONFIRM
self
.
halter_id
=
int
(
sender
)
self
.
comm
.
send
(
MSG_OK
,
sender
)
elif
message
==
MSG_VICTORY
:
if
int
(
sender
)
==
self
.
halter_id
and
self
.
state
==
STATE_WAITINGCONFIRM
:
log
.
info
(
'{} thinks {} is the leader'
.
format
(
self
.
participant_id
,
sender
))
self
.
comm
.
send
(
MSG_OK
,
sender
)
self
.
state
=
STATE_NORMAL
def
election
(
self
):
self
.
inElection
=
True
self
.
loadConnectionInfo
()
# Check if I'm the highest instance alive
for
higher
in
range
(
self
.
participant_id
+
1
,
self
.
total_participants
):
self
.
comm
.
send
(
MSG_PING
,
higher
)
message
,
sender
=
self
.
okCanal
.
get
()
if
message
:
log
.
info
(
'{} is alive ({})'
.
format
(
higher
,
self
.
participant_id
))
self
.
inElection
=
False
return
False
continue
if
not
self
.
alive
:
return
False
# I should be the new coordinator, halt those below me
log
.
info
(
'Should be ME : {}'
.
format
(
self
.
participant_id
))
self
.
state
=
STATE_ELECTION
self
.
halter_id
=
self
.
participant_id
ups
=
[]
for
lower
in
range
(
self
.
participant_id
):
self
.
comm
.
send
(
MSG_HALT
,
lower
)
message
,
sender
=
self
.
okCanal
.
get
()
if
message
:
ups
.
append
(
lower
)
#Broadcast Victory
self
.
state
=
STATE_REORGANIZATION
for
up
in
ups
:
self
.
comm
.
send
(
MSG_VICTORY
,
up
)
message
,
sender
=
self
.
okCanal
.
get
()
if
message
:
continue
log
.
info
(
'Something is wrong... let
\
'
s start over'
)
return
self
.
election
()
self
.
state
=
STATE_NORMAL
self
.
active
=
True
log
.
info
(
'{} Is THE LEADER'
.
format
(
self
.
participant_id
))
self
.
renamer
.
failover
()
self
.
inElection
=
False
return
True
class
FilteredCanal
(
object
):
def
__init__
(
self
,
accept
,
timeout
):
self
.
accept
=
accept
self
.
queue
=
Queue
.
Queue
()
self
.
timeout
=
timeout
def
append
(
self
,
message
,
sender
):
if
message
in
self
.
accept
:
self
.
queue
.
put
([
message
,
sender
])
def
get
(
self
):
try
:
return
self
.
queue
.
get
(
timeout
=
self
.
timeout
)
except
Queue
.
Empty
:
return
[
None
,
None
]
class
Wrapper
(
object
):
def
__init__
(
self
,
confpath
,
timeout
=
20
):
self
.
canals
=
[]
self
.
ips
=
[]
self
.
participant_id
=
0
self
.
timeout
=
timeout
self
.
confpath
=
confpath
self
.
getConnectionInfo
()
self
.
socket
=
None
def
getConnectionInfo
(
self
):
params
=
open
(
self
.
confpath
,
'r'
).
readlines
()
self
.
ips
=
params
[
0
].
split
()
self
.
participant_id
=
int
(
params
[
1
])
log
.
debug
(
'I am {} of {}'
.
format
(
self
.
participant_id
,
self
.
ips
))
def
start
(
self
):
self
.
getConnectionInfo
()
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_STREAM
)
self
.
socket
.
bind
((
self
.
ips
[
self
.
participant_id
],
BASE_PORT
+
self
.
participant_id
))
self
.
socket
.
listen
(
5
)
def
send
(
self
,
message
,
number
):
self
.
getConnectionInfo
()
try
:
s
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_STREAM
)
s
.
connect
((
self
.
ips
[
number
],
BASE_PORT
+
number
))
s
.
send
(
message
+
(
' {}
\
n
'
.
format
(
self
.
participant_id
)))
except
(
socket
.
error
,
socket
.
herror
,
socket
.
gaierror
,
socket
.
timeout
):
pass
finally
:
s
.
close
()
def
create_canal
(
self
,
accept
):
created
=
FilteredCanal
(
accept
,
self
.
timeout
)
self
.
canals
.
append
(
created
)
return
created
def
recv
(
self
):
client
,
_
=
self
.
socket
.
accept
()
client_message
=
client
.
recv
(
1024
)
if
client_message
:
message
,
sender
=
client_message
.
split
()
for
canal
in
self
.
canals
:
canal
.
append
(
message
,
int
(
sender
))
def
run
(
args
):
confpath
=
args
.
pop
(
'confpath'
)
renamer
=
slapos
.
recipe
.
addresiliency
.
renamer
.
Renamer
(
server_url
=
args
.
pop
(
'server_url'
),
key_file
=
args
.
pop
(
'key_file'
),
cert_file
=
args
.
pop
(
'cert_file'
),
computer_guid
=
args
.
pop
(
'computer_id'
),
partition_id
=
args
.
pop
(
'partition_id'
),
software_release
=
args
.
pop
(
'software'
),
namebase
=
args
.
pop
(
'namebase'
))
if
args
:
raise
ValueError
(
'Unknown arguments: %s'
%
', '
.
join
(
args
))
wrapper
=
Wrapper
(
confpath
=
confpath
,
timeout
=
20
)
computer
=
ResilientInstance
(
wrapper
,
renamer
=
renamer
,
confpath
=
confpath
)
# idle waiting for connection infos
while
computer
.
total_participants
<
2
:
computer
.
loadConnectionInfo
()
time
.
sleep
(
30
)
log
.
info
(
'Starting'
)
computer
.
comm
.
start
()
thread
.
start_new_thread
(
computer
.
listen
,
())
thread
.
start_new_thread
(
computer
.
aliveManagement
,
())
computer
.
main
()
slapos/recipe/addresiliency/template/bully.conf.in
deleted
100644 → 0
View file @
ee253abb
%(ip_list)s
%(self_id)s
slapos/recipe/addresiliency/template/bully.py.in
deleted
100644 → 0
View file @
ee253abb
#!%(executable)s
import select
import socket
import threading
import time
import sys
sys.path[:] = %(syspath)s
import slapos
from slapos import slap as slapmodule
port = 50000
size = 1024
wait = True
def loadConnectionInfos():
connectionInfos = {}
file = open('%(confpath)s', 'r')
params = file.read().split('\n')
file.close()
ip_list = [x.strip("' ") for x in params[0].strip('[],').split(',')]
connectionInfos['self_id'] = int(params[1])
connectionInfos['server_list'] = \
[(i, ip_list[i]) for i in range(len(ip_list))]
connectionInfos['self_ip'] = ip_list[connectionInfos['self_id']]
return connectionInfos
def rename_broken_and_stop():
try:
slap = slapmodule.slap()
slap.initializeConnection('%(server_url)s',
'%(key_file)s',
'%(cert_file)s')
computer_partition = slap.registerComputerPartition(computer_guid='%(computer_id)s',
partition_id='%(partition_id)s')
broken = computer_partition.request(software_release='%(software)s',
software_type='frozen',
partition_reference='%(namebase)s0')
broken.rename('broken-%%s' %% (time.strftime("%%d-%%b_%%H:%%M:%%S", time.gmtime())))
broken.stopped()
computer_partition.rename('%(namebase)s0')
print 'renaming done\n'
except slapos.slap.slap.ServerError:
print 'Internal server error\n'
def election():
global wait
connection = loadConnectionInfos()
message = "%%s, %%s" %% (connection['self_id'], "Election")
victory = True
for (remote_id, addr) in connection['server_list']:
if remote_id > connection['self_id']:
try:
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((addr, port + remote_id))
s.send(message)
reply = s.recv(size)
if reply == "%%s, %%s" %% (remote_id, "Alive"):
victory = False
except (socket.error, socket.herror, socket.gaierror, socket.timeout):
pass
finally:
s.close()
if victory:
wait = True
for (remote_id, addr) in connection['server_list']:
if remote_id < connection['self_id']:
try:
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((addr, port + remote_id))
s.send("%%s, %%s" %% (connection['self_id'], "Victory"))
except (socket.error, socket.herror, socket.gaierror, socket.timeout):
pass
finally:
s.close()
rename_broken_and_stop()
def failure_detect():
global wait
connection = loadConnectionInfos()
while True:
time.sleep(30)
if wait:
print 'waiting 30 minutes\n'
time.sleep(30 * 60)
wait = False
if not connection['server_list'][0]:
continue
(remote_id, addr) = connection['server_list'][0]
try:
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((addr, port + remote_id))
s.close()
except (socket.error, socket.herror, socket.gaierror, socket.timeout):
s.close()
election()
failure_detect_thread = threading.Thread(target=failure_detect)
failure_detect_thread.start()
connection = loadConnectionInfos()
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.bind((connection['self_ip'], port + connection['self_id']))
s.listen(5)
#election()
while True:
force_election = False
client, _ = s.accept()
client_message = client.recv(1024)
if client_message:
client_id, message = client_message.split(', ')
client_id = eval(client_id)
if message == "Victory":
wait = True
print "%%s wins" %% client_id
elif message == "Election":
print "%%s starts an election" %% client_id
if client_id < connection['self_id']:
client.send("%%s, %%s" %% (connection['self_id'], "Alive"))
force_election = True
client.close()
if force_election:
election()
slapos/recipe/addresiliency/template/bully_new.py.in
deleted
100644 → 0
View file @
ee253abb
#!%(executable)s
import logging
import os
import socket
import sys
import thread
import time
sys.path[:] = %(syspath)s
from slapos import slap as slapmodule
import slapos
BASE_PORT = 50000
SLEEPING_MINS = 2
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
class Renamer(object):
def __init__(self, server_url, key_file, cert_file, computer_guid,
partition_id, software_release, namebase):
self.server_url = server_url
self.key_file = key_file
self.cert_file = cert_file
self.computer_guid = computer_guid
self.partition_id = partition_id
self.software_release = software_release
self.namebase = namebase
def _failover(self):
slap = slapmodule.slap()
slap.initializeConnection(self.server_url,
self.key_file,
self.cert_file)
computer_partition = slap.registerComputerPartition(computer_guid=self.computer_guid,
partition_id=self.partition_id)
broken = computer_partition.request(software_release=self.software_release,
software_type='frozen',
partition_reference=self.namebase+'0')
broken.rename('broken-{}'.format(time.strftime("%%d-%%b_%%H:%%M:%%S", time.gmtime())))
broken.stopped()
computer_partition.rename(self.namebase+'0')
def failover(self):
try:
log.info('renaming done')
except slapos.slap.slap.ServerError:
log.info('Internal server error')
## Leader is always number 0
class ResilientInstance(object):
def __init__(self, comm, renamer, confpath):
self.comm = comm
self.id = 0
self.state = 'normal'
self.halter = 0
self.inElection = False
self.alive = True
self.lastPing = time.clock()
self.mainCanal = self.comm.canal(['ping', 'halt', 'victory'])
self.renamer = renamer
self.okCanal = self.comm.canal(['ok'])
self.confpath = confpath
self.loadConnectionInfos()
def loadConnectionInfos(self):
file = open(self.confpath, 'r')
params = file.read().split('\n')
file.close()
self.nbComp = len([x.strip("' ") for x in params[0].strip('[],').split(',')])
new_id = int(params[1])
if self.id != new_id:
self.halter = new_id
self.id = new_id
## Needs to be changed to use the master
def aliveManagement(self):
while self.alive:
log.info('XXX sleeping for %%d minutes' %% SLEEPING_MINS)
time.sleep(SLEEPING_MINS*60)
if self.id == 0:
continue
self.comm.send('ping', 0)
message, sender = self.okCanal.get()
if message:
continue
self.election()
def listen(self):
while self.alive:
self.comm.recv()
def main(self):
while self.alive:
message, sender = self.mainCanal.get()
if message == 'ping':
self.comm.send('ok', sender)
elif message == 'halt':
self.state = 'waitingConfirm'
self.halter = sender
self.comm.send('ok', sender)
elif message == 'victory':
if int(sender) == int(self.halter) and self.state == 'waitingConfirm':
log.info('{} thinks {} is the leader'.format(self.id, sender))
self.comm.send('ok', sender)
self.state = 'normal'
def election(self):
self.inElection = True
self.loadConnectionInfos()
#Check if I'm the highest instance alive
for higher in range(self.id + 1, self.nbComp):
self.comm.send('ping', higher)
message, sender = self.okCanal.get()
if message:
log.info('{} is alive ({})'.format(higher, self.id))
self.inElection = False
return False
continue
if not self.alive:
return False
#I should be the new coordinator, halt those below me
log.info('Should be ME : {}'.format(self.id))
self.state = 'election'
self.halter = self.id
ups = []
for lower in range(self.id):
self.comm.send('halt', lower)
message, sender = self.okCanal.get()
if message:
ups.append(lower)
#Broadcast Victory
self.state = 'reorganization'
for up in ups:
self.comm.send('victory', up)
message, sender = self.okCanal.get()
if message:
continue
log.info('Something is wrong... let\'s start over')
return self.election()
self.state = 'normal'
self.active = True
log.info('{} Is THE LEADER'.format(self.id))
self.renamer.failover()
self.inElection = False
return True
class FilteredCanal(object):
def __init__(self, accept, timeout):
self.accept = accept
self.list = []
self.lock = thread.allocate_lock()
self.timeout = timeout
def append(self, message, sender):
if message in self.accept:
self.lock.acquire()
self.list.append([message, sender])
self.lock.release()
def get(self):
start = time.clock()
while (time.clock() - start < self.timeout):
self.lock.acquire()
if self.list:
self.lock.release()
return self.list.pop(0)
self.lock.release()
return [None, None]
class Wrapper(object):
def __init__(self, confpath, timeout=20):
self.canals = []
self.ips = []
self.id = 0
self.timeout = timeout
self.confpath = confpath
self.getConnectionInfos()
self.socket = None
def getConnectionInfos(self):
file = open(self.confpath, 'r')
params = file.read().split('\n')
file.close()
self.ips = [x.strip("' ") for x in params[0].strip('[],').split(',')]
self.id = int(params[1])
def start(self):
self.getConnectionInfos()
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
self.socket.bind((self.ips[self.id], BASE_PORT + self.id))
self.socket.listen(5)
def send(self, message, number):
self.getConnectionInfos()
try:
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((self.ips[number], BASE_PORT + number))
s.send(message + (' {}\n'.format(self.id)))
except (socket.error, socket.herror, socket.gaierror, socket.timeout):
pass
finally:
s.close()
def canal(self, accept):
created = FilteredCanal(accept, self.timeout)
self.canals.append(created)
return created
def recv(self):
client, _ = self.socket.accept()
client_message = client.recv(1024)
if client_message:
message, sender = client_message.split()
for canal in self.canals:
canal.append(message, int(sender))
def main():
renamer = Renamer(server_url = '%(server_url)s',
key_file = '%(key_file)s',
cert_file = '%(cert_file)s',
computer_guid = '%(computer_id)s',
partition_id = '%(partition_id)s',
software_release = '%(software)s',
namebase = '%(namebase)s')
confpath = '%(confpath)s'
wrapper = Wrapper(confpath=confpath, timeout=20)
computer = ResilientInstance(wrapper, renamer=renamer, confpath=confpath)
#idle waiting for connection infos
while computer.nbComp < 2 :
computer.loadConnectionInfos()
time.sleep(30)
log.info('Starting')
computer.comm.start()
thread.start_new_thread(computer.listen, ())
thread.start_new_thread(computer.main, ())
thread.start_new_thread(computer.aliveManagement, ())
while True:
# XXX tight loop
continue
if __name__ == '__main__':
main()
stack/lamp/buildout.cfg
View file @
1b6f936f
...
...
@@ -112,7 +112,7 @@ context = key buildout buildout:bin-directory
import-list = file parts template-parts:destination
file replicated template-replicated:destination
md5sum =
f6dc9290194ad1fbe1ced553f5668922
md5sum =
1640ebe7f8ced607ce1ec93c4f6e5413
mode = 0644
[instance-mariadb]
...
...
stack/lamp/instance-resilient.cfg.jinja2
View file @
1b6f936f
...
...
@@ -19,7 +19,7 @@ parts +=
[request-apache]
return = url ssh-public-key ssh-url notification-id ip url backend_url
# XXX: hardcoded values
config = domain number authorized-key notify
ip-list
namebase mariadb1-computer-guid pbs-mariadb1-computer-guid mariadb2-computer-guid pbs-mariadb2-computer-guid mariadb3-computer-guid pbs-mariadb3-computer-guid
config = domain number authorized-key notify namebase mariadb1-computer-guid pbs-mariadb1-computer-guid mariadb2-computer-guid pbs-mariadb2-computer-guid mariadb3-computer-guid pbs-mariadb3-computer-guid
config-mariadb1-computer-guid = ${slap-parameter:mariadb1-computer-guid}
config-pbs-mariadb1-computer-guid = ${slap-parameter:pbs-mariadb1-computer-guid}
config-mariadb2-computer-guid = ${slap-parameter:mariadb2-computer-guid}
...
...
stack/lapp/buildout.cfg
View file @
1b6f936f
...
...
@@ -100,7 +100,7 @@ context = key buildout buildout:bin-directory
import-list = file parts template-parts:destination
file replicated template-replicated:destination
md5sum =
ef38aa9810ce20960382261f235abfcd
md5sum =
26da0631906c2267b82703c4d4f4a911
mode = 0644
[instance-postgres]
...
...
stack/lapp/instance-resilient.cfg.jinja2
View file @
1b6f936f
...
...
@@ -19,7 +19,7 @@ parts +=
[request-apache]
return = url ssh-public-key ssh-url notification-id ip url backend_url
# XXX: hardcoded values
config = domain number authorized-key notify
ip-list
namebase postgres1-computer-guid pbs-postgres1-computer-guid postgres2-computer-guid pbs-postgres2-computer-guid postgres3-computer-guid pbs-postgres3-computer-guid maarch-sql-data-file
config = domain number authorized-key notify namebase postgres1-computer-guid pbs-postgres1-computer-guid postgres2-computer-guid pbs-postgres2-computer-guid postgres3-computer-guid pbs-postgres3-computer-guid maarch-sql-data-file
config-postgres1-computer-guid = ${slap-parameter:postgres1-computer-guid}
config-pbs-postgres1-computer-guid = ${slap-parameter:pbs-postgres1-computer-guid}
config-postgres2-computer-guid = ${slap-parameter:postgres2-computer-guid}
...
...
stack/resilient/buildout.cfg
View file @
1b6f936f
...
...
@@ -34,11 +34,11 @@ eggs = collective.recipe.template
[pbsready]
# Common parts for pbsready-import and pbsready-export.
# Provides rdiff-backup, notification queue, ssh authentication,
# dropbear server, and the
bully
script.
# dropbear server, and the
takeover
script.
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/pbsready.cfg.in
output = ${buildout:directory}/pbsready.cfg
md5sum =
28e9bc354cc146d1bec31c8cac263ee2
md5sum =
e89d8378cc610704b518a89b095d3a19
mode = 0644
[pbsready-import]
...
...
@@ -69,14 +69,14 @@ mode = 0644
[template-replicated]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/template-replicated.cfg.in
md5sum =
c04971c7d9e4e481396de81ef2707ef1
md5sum =
649b4d898ecbcdca5135ad356788c7d3
mode = 0644
destination = ${buildout:directory}/template-replicated.cfg.in
[template-parts]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/template-parts.cfg.in
md5sum =
a3f55a20881c3f1ec4416662146c06f7
md5sum =
071b1034ee8f5cc14f79b16fdeba2813
mode = 0644
destination = ${buildout:directory}/template-parts.cfg.in
...
...
stack/resilient/pbsready.cfg.in
View file @
1b6f936f
...
...
@@ -128,14 +128,10 @@ rotate-num = 30
#----------------
#--
#-- Resiliency script for the
bully algorithm
#-- Resiliency script for the
node takeover
[resiliency]
# If enable-bully-service is true, the scripts will be run automatically.
# If false, they can be run with bin/bullly for all the PBSReady instances.
enable-bully-service = False
recipe = slapos.cookbook:addresiliency
wrapper-bully = bully
wrapper-takeover = takeover
services = $${basedirectory:services}
bin = $${rootdirectory:bin}
...
...
stack/resilient/template-parts.cfg.in
View file @
1b6f936f
...
...
@@ -3,12 +3,10 @@
{% macro replicate(namebase, nbbackup) %}
request-{{namebase}}
request-{{namebase}}-2
resilient-request-{{namebase}}-public-key-promise
{% for id in range(1,nbbackup|int) %}
request-{{namebase}}-pseudo-replicating-{{id}}
request-{{namebase}}-pseudo-replicating-{{id}}-2
resilient-request-{{namebase}}-pseudo-replicating-{{id}}-public-key-promise
{% endfor %}
...
...
stack/resilient/template-replicated.cfg.in
View file @
1b6f936f
...
...
@@ -24,10 +24,6 @@ recipe = slapos.cookbook:request
config-namebase = {{namebase}}
software-url = ${slap-connection:software-release-url}
## Every request is double to provide the 3 IPs.
## First, we request with ip-list parameter hardcoded.
## Then, we request the same thing without this.
## XXX-Cedric: is it useful?
[request-{{namebase}}]
<= resilient
slap-connection
...
...
@@ -37,7 +33,7 @@ name = {{namebase}}0
return = ssh-public-key ssh-url notification-id ip
config =
# Resilient related parameters
number authorized-key notify
ip-list
namebase
number authorized-key notify namebase
{% if slapparameter_dict is defined %}
# Software Instance related parameters
{% for parameter_name in slapparameter_dict.keys() %}{{parameter_name}} {% endfor %}
...
...
@@ -45,7 +41,6 @@ config =
config-number = 0
config-authorized-key = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}{% endfor %}
config-notify = {% for id in range(1,nbbackup|int) %} ${request-pbs-{{namebase}}-{{id}}:connection-notification-url}{% endfor %}
config-ip-list =
# Bubble up all the instance parameters to the requested export instance.
{% if slapparameter_dict is defined %}
{% for parameter_name, parameter_value in slapparameter_dict.items() %}config-{{parameter_name}} = {{parameter_value}}
...
...
@@ -90,11 +85,10 @@ return = ssh-public-key ssh-url notification-url ip
pbs-notification-id = ${slap-connection:computer-id}-${slap-connection:partition-id}-{{namebase}}-{{id}}-push
config = number authorized-key on-notification
ip-list
namebase
config = number authorized-key on-notification namebase
config-number = {{id}}
config-authorized-key = ${request-pbs-{{namebase}}-{{id}}:connection-ssh-key}
config-on-notification = ${request-pbs-{{namebase}}-{{id}}:connection-feeds-url}${:pbs-notification-id}
config-ip-list =
{% if sla_parameter_dict == {} -%}
sla = mode
sla-mode = unique_by_network
...
...
@@ -125,12 +119,6 @@ feed-url-{{namebase}}-{{id}}-push = ${request-pbs-{{namebase}}-{{id}}:connection
{% endfor -%}
[iplist]
config-ip-list = ${request-{{namebase}}:connection-ip}{% for j in range(1,nbbackup|int) %} ${request-{{namebase}}-pseudo-replicating-{{j}}:connection-ip}{% endfor %}
[request-{{namebase}}-2]
<= request-{{namebase}}
iplist
[resilient-request-{{namebase}}-public-key-promise]
# Check that public-key-value parameter exists and is not empty
...
...
@@ -138,7 +126,7 @@ config-ip-list = ${request-{{namebase}}:connection-ip}{% for j in range(1,nbback
recipe = collective.recipe.template
# XXX: don't use system executable
input = inline:#!/bin/sh
PUBLIC_KEY_CONTENT="${request-{{namebase}}
-2
:connection-ssh-public-key})"
PUBLIC_KEY_CONTENT="${request-{{namebase}}:connection-ssh-public-key})"
if [[ ! -n "$PUBLIC_KEY_CONTENT" || "$PUBLIC_KEY_CONTENT" == *None* ]]; then
exit 1
fi
...
...
@@ -146,9 +134,6 @@ output = ${resilient-directory:promise}/resilient-request-{{namebase}}-public-ke
mode = 700
{% for id in range(1,nbbackup|int) %}
[request-{{namebase}}-pseudo-replicating-{{id}}-2]
<= request-{{namebase}}-pseudo-replicating-{{id}}
iplist
[resilient-request-{{namebase}}-pseudo-replicating-{{id}}-public-key-promise]
# Check that public-key-value parameter exists and is not empty
...
...
@@ -156,7 +141,7 @@ mode = 700
recipe = collective.recipe.template
# XXX: don't use system executable
input = inline:#!/bin/sh
PUBLIC_KEY_CONTENT="${request-{{namebase}}-pseudo-replicating-{{id}}
-2
:connection-ssh-public-key})"
PUBLIC_KEY_CONTENT="${request-{{namebase}}-pseudo-replicating-{{id}}:connection-ssh-public-key})"
if [[ ! -n "$PUBLIC_KEY_CONTENT" || "$PUBLIC_KEY_CONTENT" == *None* ]]; then
exit 1
fi
...
...
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