Commit c7f71ecf authored by Nicolas Wavrant's avatar Nicolas Wavrant

resilient: notifier port is now dynamic, and gets a promise

parent 93ccdbc7
...@@ -66,6 +66,12 @@ class Callback(GenericBaseRecipe): ...@@ -66,6 +66,12 @@ class Callback(GenericBaseRecipe):
class Notify(GenericBaseRecipe): class Notify(GenericBaseRecipe):
def __init__(self, buildout, name, options):
super(Notify, self).__init__(buildout, name, options)
log = os.path.join(options['feeds'], options['name'])
options['log-file'] = log
self.options = options
def createNotifier(self, notifier_binary, wrapper, executable, def createNotifier(self, notifier_binary, wrapper, executable,
log, title, notification_url, feed_url, pidfile=None): log, title, notification_url, feed_url, pidfile=None):
...@@ -98,13 +104,11 @@ class Notify(GenericBaseRecipe): ...@@ -98,13 +104,11 @@ class Notify(GenericBaseRecipe):
port=self.options['port'], port=self.options['port'],
path='/get/%s' % self.options['name']) path='/get/%s' % self.options['name'])
log = os.path.join(self.options['feeds'], self.options['name'])
options = self.options options = self.options
script = self.createNotifier(notifier_binary=options['notifier-binary'], script = self.createNotifier(notifier_binary=options['notifier-binary'],
wrapper=options['wrapper'], wrapper=options['wrapper'],
executable=options['executable'], executable=options['executable'],
log=log, log=options['log-file'],
title=options['title'], title=options['title'],
pidfile=options['pidfile'], pidfile=options['pidfile'],
notification_url=options['notify'], notification_url=options['notify'],
......
...@@ -71,6 +71,12 @@ database = $${rootdirectory:srv}/equeue.db ...@@ -71,6 +71,12 @@ database = $${rootdirectory:srv}/equeue.db
wrapper = $${basedirectory:services}/equeue wrapper = $${basedirectory:services}/equeue
equeue-binary = ${buildout:bin-directory}/equeue equeue-binary = ${buildout:bin-directory}/equeue
[notifier-port]
recipe = slapos.cookbook:free_port
minimum = 8088
maximum = 8097
ip = $${notifier:host}
# notifier.notify adds the [exporter, notifier] to the execution queue # notifier.notify adds the [exporter, notifier] to the execution queue
# notifier.notify.callback sets up a callback # notifier.notify.callback sets up a callback
[notifier] [notifier]
...@@ -81,11 +87,10 @@ wrapper = $${basedirectory:services}/notifier ...@@ -81,11 +87,10 @@ wrapper = $${basedirectory:services}/notifier
mode = 0700 mode = 0700
command = ${buildout:bin-directory}/pubsubserver --callbacks $${directory:notifier-callbacks} --feeds $${directory:notifier-feeds} --equeue-socket $${equeue:socket} --logfile $${basedirectory:log}/notifier.log $${:host} $${:port} command = ${buildout:bin-directory}/pubsubserver --callbacks $${directory:notifier-callbacks} --feeds $${directory:notifier-feeds} --equeue-socket $${equeue:socket} --logfile $${basedirectory:log}/notifier.log $${:host} $${:port}
host = $${slap-network-information:global-ipv6} host = $${slap-network-information:global-ipv6}
port = 8088 port = $${notifier-port:port}
context = context =
key content notifier:command key content notifier:command
[logrotate-entry-equeue] [logrotate-entry-equeue]
<= logrotate <= logrotate
recipe = slapos.cookbook:logrotate.d recipe = slapos.cookbook:logrotate.d
......
...@@ -18,6 +18,7 @@ parts = ...@@ -18,6 +18,7 @@ parts =
resilient-sshkeys-sshd-promise resilient-sshkeys-sshd-promise
sshd-pbs-authorized-key sshd-pbs-authorized-key
notifier notifier
notifier-exporter-promise
cron-entry-backup cron-entry-backup
...@@ -36,6 +37,12 @@ minimum = 22200 ...@@ -36,6 +37,12 @@ minimum = 22200
maximum = 22209 maximum = 22209
ip = $${slap-network-information:global-ipv6} ip = $${slap-network-information:global-ipv6}
[notifier-port]
recipe = slapos.cookbook:free_port
minimum = 65526
maximum = 65535
ip = $${notifier:host}
[resilient-publish-connection-parameter] [resilient-publish-connection-parameter]
notification-id = http://[$${notifier:host}]:$${notifier:port}/get/$${notifier-exporter:name} notification-id = http://[$${notifier:host}]:$${notifier:port}/get/$${notifier-exporter:name}
...@@ -51,6 +58,16 @@ wrapper = $${rootdirectory:bin}/exporter ...@@ -51,6 +58,16 @@ wrapper = $${rootdirectory:bin}/exporter
notify = $${slap-parameter:notify} notify = $${slap-parameter:notify}
pidfile = $${resilient-directory:pid}/$${:name}.pid pidfile = $${resilient-directory:pid}/$${:name}.pid
[notifier-exporter-promise]
recipe = slapos.recipe.template:jinja2
mode = 700
template = inline:
#!${bash:location}/bin/bash
EXPORTER_FEED="$${notifier-exporter:log-file}"
FAILURE_PATTERN="FAILURE"
tail -n 1 $EXPORTER_FEED | grep -vq FAILURE_PATTERN
rendered = $${basedirectory:promises}/exporter-status
[cron-entry-backup] [cron-entry-backup]
# Schedule the periodic database dump. # Schedule the periodic database dump.
# Through notifications, this triggers (one or more) incremental backups on PBS instances. # Through notifications, this triggers (one or more) incremental backups on PBS instances.
......
...@@ -42,8 +42,11 @@ maximum = 22219 ...@@ -42,8 +42,11 @@ maximum = 22219
ip = $${slap-network-information:global-ipv6} ip = $${slap-network-information:global-ipv6}
# Define port of notifier (same reason) # Define port of notifier (same reason)
[notifier] [notifier-port]
port = 65533 recipe = slapos.cookbook:free_port
minimum = 65516
maximum = 65525
ip = $${notifier:host}
[import-on-notification] [import-on-notification]
# notifier.callback runs a script when a notification (sent by a parent PBS) # notifier.callback runs a script when a notification (sent by a parent PBS)
......
...@@ -165,7 +165,7 @@ callbacks = $${directory:notifier-callbacks} ...@@ -165,7 +165,7 @@ callbacks = $${directory:notifier-callbacks}
command = ${buildout:bin-directory}/pubsubserver --callbacks $${directory:notifier-callbacks} --feeds $${directory:notifier-feeds} --equeue-socket $${equeue:socket} --logfile $${basedirectory:log}/notifier.log $${:host} $${:port} command = ${buildout:bin-directory}/pubsubserver --callbacks $${directory:notifier-callbacks} --feeds $${directory:notifier-feeds} --equeue-socket $${equeue:socket} --logfile $${basedirectory:log}/notifier.log $${:host} $${:port}
notifier-binary = ${buildout:bin-directory}/pubsubnotifier notifier-binary = ${buildout:bin-directory}/pubsubnotifier
host = $${slap-network-information:global-ipv6} host = $${slap-network-information:global-ipv6}
port = 65534 port = $${notifier-port:port}
context = context =
key content notifier:command key content notifier:command
......
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