heat metadata : remove metadata_url logic
Remove logic where the heat-metadata server registers a URL on startup with the engine. The instance metadata is now served via the CFN api, so we just have a config-file option specifying the URL of the CFN API. We don't want to preserve the "register on startup" logic, because we need the engine to have access to this information even if it is restarted independent of some other service (avoid reliance on services coming up in a particular order) Change-Id: I690170977227ec96451d2a2fd25f7e507370b604 Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
parent
763cf3142b
commit
997a2165e7
|
@ -33,10 +33,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')):
|
|||
|
||||
gettext.install('heat', unicode=1)
|
||||
|
||||
from heat.openstack.common import rpc
|
||||
from heat.common import config
|
||||
from heat.common import wsgi
|
||||
from heat.common import context
|
||||
|
||||
from heat.openstack.common import log as logging
|
||||
from heat.openstack.common import cfg
|
||||
|
@ -44,24 +42,6 @@ from heat.openstack.common import cfg
|
|||
LOG = logging.getLogger('heat.metadata')
|
||||
|
||||
|
||||
def send_address_to_engine(host, port):
|
||||
con = context.get_admin_context()
|
||||
timeout = 2
|
||||
while True:
|
||||
try:
|
||||
resp = rpc.call(con, 'engine',
|
||||
{'method': 'metadata_register_address',
|
||||
'args': {'url': 'http://%s:%s' % (host, port)}},
|
||||
timeout=timeout)
|
||||
except rpc.common.Timeout:
|
||||
LOG.info('Could not connect to the engine, retrying...')
|
||||
if timeout < 30:
|
||||
timeout *= 2
|
||||
else:
|
||||
LOG.info('registered the hostname and port with the engine.')
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
cfg.CONF(project='heat', prog='heat-metadata')
|
||||
|
@ -73,7 +53,6 @@ if __name__ == '__main__':
|
|||
|
||||
port = cfg.CONF.bind_port
|
||||
host = cfg.CONF.bind_host
|
||||
send_address_to_engine(host, port)
|
||||
LOG.info(('Starting Heat Metadata on %s:%s') % (host, port))
|
||||
server = wsgi.Server()
|
||||
server.start(app, cfg.CONF, default_port=port)
|
||||
|
|
|
@ -183,6 +183,17 @@ Check that there is a ``F17-x86_64-cfntools`` JEOS in glance:
|
|||
)
|
||||
$GLANCE_INDEX | grep -q "F17-x86_64-cfntools"
|
||||
|
||||
Update heat engine configuration file
|
||||
-------------------------------------
|
||||
|
||||
The heat engine configuration file should be updated with the address of the bridge device (demonetbr0), however this device is not created by nova-network until the first instance is launched, so we assume that $BRIDGE_IP is 10.0.0.1 if $SUBNET is 10.0.0.0/24 as in the instructions above:
|
||||
|
||||
..
|
||||
BRIDGE_IP=`echo $SUBNET | awk -F'[./]' '{printf "%d.%d.%d.%d", $1, $2, $3, or($4, 1)}'`
|
||||
|
||||
::
|
||||
sudo sed -i -e "/heat_metadata_server_url/ s/127\.0\.0\.1/${BRIDGE_IP}/" /etc/heat/heat-engine.conf
|
||||
|
||||
Launch the Heat services
|
||||
------------------------
|
||||
|
||||
|
@ -315,7 +326,12 @@ Open up port 8002 so that the guests can communicate with the heat-metadata serv
|
|||
::
|
||||
sudo iptables -I INPUT -p tcp --dport 8002 -j ACCEPT -i demonetbr0
|
||||
|
||||
Note the above rule will not persist across reboot, so you may wish to add it to /etc/sysconfig/iptables
|
||||
Note Instance/resource metadata is actually now served via the cloudformation API, so it is necessary to also open up port 8000 so that the guests can communicate with the heat-api-cfn server:
|
||||
|
||||
::
|
||||
sudo iptables -I INPUT -p tcp --dport 8000 -j ACCEPT -i demonetbr0
|
||||
|
||||
Note the above rules will not persist across reboot, so you may wish to add them to /etc/sysconfig/iptables
|
||||
|
||||
Configure Heat Cloudwatch server
|
||||
--------------------------------
|
||||
|
|
|
@ -14,7 +14,14 @@ bind_port = 8001
|
|||
# Keystone role for heat template-defined users
|
||||
heat_stack_user_role = heat_stack_user
|
||||
|
||||
# Log to this file. Make sure the user running heat-engine has
|
||||
# URL for instances to connect for metadata
|
||||
# ie the IP of the bridge device connecting the
|
||||
# instances with the host and the bind_port of
|
||||
# the CFN API
|
||||
# NOTE : change this from 127.0.0.1 !!
|
||||
heat_metadata_server_url = http://127.0.0.1:8000
|
||||
|
||||
# Log to this file. Make sure the user running heat-api has
|
||||
# permissions to write to this file!
|
||||
log_file = /var/log/heat/engine.log
|
||||
|
||||
|
|
|
@ -378,9 +378,6 @@ class EngineManager(manager.Manager):
|
|||
return [api.format_stack_resource(resource)
|
||||
for resource in stack if resource.id is not None]
|
||||
|
||||
def metadata_register_address(self, context, url):
|
||||
cfg.CONF.heat_metadata_server_url = url
|
||||
|
||||
def metadata_list_stacks(self, context):
|
||||
"""
|
||||
Return the names of the stacks registered with Heat.
|
||||
|
|
|
@ -25,6 +25,8 @@ import heat
|
|||
from heat.engine.resources import resource
|
||||
from heat.common import exception
|
||||
|
||||
from heat.openstack.common import cfg
|
||||
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
logger = logging.getLogger('heat.engine.instance')
|
||||
|
@ -176,9 +178,7 @@ class Instance(resource.Resource):
|
|||
attachments.append((json.dumps(self.metadata),
|
||||
'cfn-init-data', 'x-cfninitdata'))
|
||||
|
||||
metadata_server = resource.Metadata.server()
|
||||
if metadata_server is not None:
|
||||
attachments.append((metadata_server,
|
||||
attachments.append((cfg.CONF.heat_metadata_server_url,
|
||||
'cfn-metadata-server', 'x-cfninitdata'))
|
||||
|
||||
subparts = [make_subpart(*args) for args in attachments]
|
||||
|
|
|
@ -62,17 +62,6 @@ class Metadata(object):
|
|||
rs = db_api.resource_get(resource.stack.context, resource.id)
|
||||
rs.update_and_save({'rsrc_metadata': metadata})
|
||||
|
||||
@staticmethod
|
||||
def server():
|
||||
'''
|
||||
Get the address of the currently registered metadata server. Return
|
||||
None if no server is registered.
|
||||
'''
|
||||
try:
|
||||
return cfg.CONF.heat_metadata_server_url
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
|
||||
class Resource(object):
|
||||
# Status strings
|
||||
|
|
|
@ -20,6 +20,8 @@ from heat.engine.resources import resource
|
|||
|
||||
from heat.openstack.common import log as logging
|
||||
|
||||
from heat.openstack.common import cfg
|
||||
|
||||
logger = logging.getLogger('heat.engine.wait_condition')
|
||||
|
||||
|
||||
|
@ -38,7 +40,7 @@ class WaitConditionHandle(resource.Resource):
|
|||
|
||||
def handle_create(self):
|
||||
self.instance_id = '%s/stacks/%s/resources/%s' % \
|
||||
(resource.Metadata.server(),
|
||||
(cfg.CONF.heat_metadata_server_url,
|
||||
self.stack.id,
|
||||
self.name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue