summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Pevec <apevec@redhat.com>2014-05-06 21:48:59 +0200
committerThomas Herve <thomas.herve@enovance.com>2014-07-16 11:01:52 +0200
commit46d6b9306c26f36bc2d490afd9fcab30aa4725f5 (patch)
tree3519b37f09bdd7255e0384ef3c8859a151132243
parentf1d48db515e7ce2283e7e96ba81e3dc74476e53a (diff)
downloadheat-46d6b9306c26f36bc2d490afd9fcab30aa4725f5.tar.gz
Refactor service readiness notification
Build upon cceda95a35f18f5f7b52daaf0662a4cd3768b3ac apply Oslo systemd module. It was imported in aef33d2d716c064f1f571c334fd36b1ea5928d5c. It also drops heat.common.systemd and deprecates onready configuration parameter. Oslo commit 53e1214c092f09e3851b1a1b55289a93a72b09ec Change-Id: I80f325c9be9c171c2dc8d5526570bf64f0f87c78
-rwxr-xr-xbin/heat-api4
-rwxr-xr-xbin/heat-api-cfn5
-rwxr-xr-xbin/heat-api-cloudwatch5
-rwxr-xr-xbin/heat-engine3
-rw-r--r--etc/heat/heat.conf.sample7
-rw-r--r--heat/common/config.py7
-rw-r--r--heat/common/notify.py40
-rw-r--r--heat/common/systemd.py45
8 files changed, 11 insertions, 105 deletions
diff --git a/bin/heat-api b/bin/heat-api
index a321cd00f..caeed6f2b 100755
--- a/bin/heat-api
+++ b/bin/heat-api
@@ -34,10 +34,10 @@ from oslo.config import cfg
from heat.common import config
from heat.common import messaging
-from heat.common import notify
from heat.common import wsgi
from heat.openstack.common import gettextutils
from heat.openstack.common import log as logging
+from heat.openstack.common import systemd
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
@@ -63,7 +63,7 @@ if __name__ == '__main__':
{'host': host, 'port': port})
server = wsgi.Server()
server.start(app, cfg.CONF.heat_api, default_port=port)
- notify.startup_notify(cfg.CONF.onready)
+ systemd.notify_once()
server.wait()
except RuntimeError as e:
sys.exit("ERROR: %s" % e)
diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn
index 6818463e9..cdc435481 100755
--- a/bin/heat-api-cfn
+++ b/bin/heat-api-cfn
@@ -36,10 +36,11 @@ from oslo.config import cfg
from heat.common import config
from heat.common import messaging
-from heat.common import notify
from heat.common import wsgi
from heat.openstack.common import gettextutils
+
from heat.openstack.common import log as logging
+from heat.openstack.common import systemd
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
@@ -65,7 +66,7 @@ if __name__ == '__main__':
{'host': host, 'port': port})
server = wsgi.Server()
server.start(app, cfg.CONF.heat_api_cfn, default_port=port)
- notify.startup_notify(cfg.CONF.onready)
+ systemd.notify_once()
server.wait()
except RuntimeError as e:
sys.exit("ERROR: %s" % e)
diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch
index 9a34909c4..d1b600b9f 100755
--- a/bin/heat-api-cloudwatch
+++ b/bin/heat-api-cloudwatch
@@ -36,10 +36,11 @@ from oslo.config import cfg
from heat.common import config
from heat.common import messaging
-from heat.common import notify
from heat.common import wsgi
from heat.openstack.common import gettextutils
+
from heat.openstack.common import log as logging
+from heat.openstack.common import systemd
gettextutils.enable_lazy()
gettextutils.install('heat', lazy=True)
@@ -65,7 +66,7 @@ if __name__ == '__main__':
{'host': host, 'port': port})
server = wsgi.Server()
server.start(app, cfg.CONF.heat_api_cloudwatch, default_port=port)
- notify.startup_notify(cfg.CONF.onready)
+ systemd.notify_once()
server.wait()
except RuntimeError as e:
sys.exit("ERROR: %s" % e)
diff --git a/bin/heat-engine b/bin/heat-engine
index 7042e6d57..7563a7679 100755
--- a/bin/heat-engine
+++ b/bin/heat-engine
@@ -35,10 +35,10 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')):
from oslo.config import cfg
from heat.common import messaging
-from heat.common import notify
from heat.openstack.common import gettextutils
from heat.openstack.common import log as logging
from heat.openstack.common import service
+
from heat.rpc import api as rpc_api
gettextutils.enable_lazy()
@@ -65,5 +65,4 @@ if __name__ == '__main__':
# We create the periodic tasks here, which mean they are created
# only in the parent process when num_engine_workers>1 is specified
srv.create_periodic_tasks()
- notify.startup_notify(cfg.CONF.onready)
launcher.wait()
diff --git a/etc/heat/heat.conf.sample b/etc/heat/heat.conf.sample
index 60de078ba..ac9446a7f 100644
--- a/etc/heat/heat.conf.sample
+++ b/etc/heat/heat.conf.sample
@@ -66,12 +66,7 @@
# stack locking. (integer value)
#engine_life_check_timeout=2
-# onready allows you to send a notification when the heat
-# processes are ready to serve. This is either a module with
-# the notify() method or a shell command. To enable
-# notifications with systemd, one may use the 'systemd-notify
-# --ready' shell command or the 'heat.common.systemd'
-# notification module. (string value)
+# Deprecated. (string value)
#onready=<None>
diff --git a/heat/common/config.py b/heat/common/config.py
index f9f962b02..17d115747 100644
--- a/heat/common/config.py
+++ b/heat/common/config.py
@@ -126,12 +126,7 @@ engine_opts = [
help=_('RPC timeout for the engine liveness check that is used'
' for stack locking.')),
cfg.StrOpt('onready',
- help=_('onready allows you to send a notification when the'
- ' heat processes are ready to serve. This is either a'
- ' module with the notify() method or a shell command. '
- ' To enable notifications with systemd, one may use'
- ' the \'systemd-notify --ready\' shell command or'
- ' the \'heat.common.systemd\' notification module.'))]
+ help=_('Deprecated.'))]
rpc_opts = [
cfg.StrOpt('host',
diff --git a/heat/common/notify.py b/heat/common/notify.py
deleted file mode 100644
index db0a6fee1..000000000
--- a/heat/common/notify.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright 2014 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""
-Startup notification using a shell script or systemd NOTIFY_SOCKET
-style notification
-"""
-
-
-from heat.openstack.common import importutils
-from heat.openstack.common import log as logging
-from heat.openstack.common import processutils
-
-LOG = logging.getLogger(__name__)
-
-
-def startup_notify(notify_param):
- if not notify_param or notify_param == "":
- return
- try:
- notifier = importutils.import_module(notify_param)
- except ImportError:
- try:
- processutils.execute(notify_param, shell=True)
- except Exception as e:
- LOG.error(_('Failed to execute onready command: %s') % e)
- else:
- notifier.notify()
diff --git a/heat/common/systemd.py b/heat/common/systemd.py
deleted file mode 100644
index cc8aa7247..000000000
--- a/heat/common/systemd.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright 2012 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""
-Helper module for systemd start-up completion notification.
-Used for "onready" configuration parameter in heat.conf
-"""
-
-import os
-import socket
-
-from heat.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-
-def _sd_notify(msg):
- sysd = os.getenv('NOTIFY_SOCKET')
- if sysd:
- sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
- if sysd.startswith('@'):
- # abstract namespace socket
- sysd = '\0%s' % sysd[1:]
- sock.connect(sysd)
- sock.sendall(msg)
- sock.close()
- else:
- LOG.warning(_('Unable to notify systemd of startup completion:'
- ' NOTIFY_SOCKET not set'))
-
-
-def notify():
- _sd_notify('READY=1')