908e6b9810
The nova_cell_v2_discover_hosts.py was moved to run on compute nodes instead of controllers to allow adding computes without touching controllers and in case multiple stacks are used to manage compute nodes. In case the nova-manage command, run by nova_cell_v2_discover_hosts.py, gets triggered at the same time on compute nodes races. With this change if this is _not_ an additional cell: * in docker_config step4, on every compute, we start the nova-compute container and then start a (detach=false) container to wait for it's service to appear in the service list. * in docker_config step5, on the bootstrap node only, we run the discovery. Change-Id: I1a159a7c2ac286373df2b7c566426b37b7734961 Closes-bug: 1824445 Co-authored-by: mschuppert@redhat.com
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright 2018 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.
|
|
import logging
|
|
import os
|
|
import random
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
random.seed()
|
|
|
|
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
|
|
LOG = logging.getLogger('nova_cell_v2_discover_hosts')
|
|
|
|
iterations = 10
|
|
timeout_max = 30
|
|
nova_cfg = '/etc/nova/nova.conf'
|
|
|
|
if __name__ == '__main__':
|
|
if not os.path.isfile(nova_cfg):
|
|
LOG.error('Nova configuration file %s does not exist', nova_cfg)
|
|
sys.exit(1)
|
|
|
|
for i in range(iterations):
|
|
try:
|
|
subprocess.check_call([
|
|
'/usr/bin/nova-manage',
|
|
'cell_v2',
|
|
'discover_hosts',
|
|
'--by-service',
|
|
'--verbose'
|
|
])
|
|
sys.exit(0)
|
|
except subprocess.CalledProcessError as e:
|
|
LOG.error('Cell v2 discovery failed with exit code %d, retrying',
|
|
e.returncode)
|
|
except Exception as e:
|
|
LOG.exception('Error during host discovery')
|
|
time.sleep(random.randint(1, timeout_max))
|
|
sys.exit(1)
|
|
|
|
# vim: set et ts=4 sw=4 :
|