[Queens] Run cellv2 host discovery via workflow or deploy_steps_tasks
This is a queens only modified version of https://review.opendev.org/682644 due to the different deployment methods we have there. When the compute bootstrap node gets blacklisted or deployment is run with skip-deploy-identifier the discovery job we have in step_5 won't run. This runs the the discovery via an ansible playbook to make sure it runs in this conditions. In case of default deploy method the discovery is run by the discovery workflow. In case of config-download the discovery is run via the deploy_steps_tasks. Change-Id: Icda4c1eb3e8c39a01547586dbc6f0407ce846c64 Closes-Bug: #1831711 Depends-On: I54d42df162a6744806301d97bca5d94e5f380a2b
This commit is contained in:
parent
7c93dab6ab
commit
d8eefd0a75
|
@ -43,9 +43,33 @@ outputs:
|
|||
nova_wait_for_placement_service.py:
|
||||
mode: "0755"
|
||||
content: { get_file: ../../docker_config_scripts/nova_wait_for_placement_service.py }
|
||||
nova_cell_v2_discover_hosts.py:
|
||||
mode: "0755"
|
||||
content: { get_file: ../../docker_config_scripts/nova_cell_v2_discover_hosts.py }
|
||||
nova_wait_for_compute_service.py:
|
||||
mode: "0755"
|
||||
content: { get_file: ../../docker_config_scripts/nova_wait_for_compute_service.py }
|
||||
|
||||
# deploy_steps_tasks only run in queens when config-download is used
|
||||
nova_compute_common_deploy_steps_tasks:
|
||||
description: Common host prep tasks for nova-compute services (compute + ironic)
|
||||
value: &nova_compute_common_deploy_steps_tasks
|
||||
- when: step|int == 5
|
||||
block:
|
||||
# discovery for non config-download method is triggered by workflow_tasks
|
||||
# in docker/services/nova-api.yaml
|
||||
- name: discover via nova_compute?
|
||||
set_fact:
|
||||
delegate_host: "{{ groups['nova_compute'][0] }}"
|
||||
when:
|
||||
- groups['nova_compute'] is defined and (groups['nova_compute']|length>0)
|
||||
- name: discover via nova_ironic?
|
||||
set_fact:
|
||||
delegate_host: "{{ groups['nova_ironic'][0] }}"
|
||||
when:
|
||||
- delegate_host is not defined
|
||||
- groups['nova_ironic'] is defined and (groups['nova_ironic']|length>0)
|
||||
- name: Discovering nova hosts
|
||||
command: "docker exec nova_compute nova-manage cell_v2 discover_hosts --by-service"
|
||||
become: true
|
||||
changed_when: False
|
||||
when:
|
||||
- delegate_host is defined
|
||||
- inventory_hostname == delegate_host
|
||||
|
|
|
@ -81,6 +81,10 @@ parameters:
|
|||
description: >
|
||||
Setting this to a unique value will re-run any deployment tasks which
|
||||
perform configuration on a Heat stack-update.
|
||||
ConfigDownload:
|
||||
default: false
|
||||
description: Whether config-download method is used or not.
|
||||
type: boolean
|
||||
|
||||
resources:
|
||||
|
||||
|
@ -118,6 +122,7 @@ resources:
|
|||
|
||||
conditions:
|
||||
enable_instance_ha: {equals: [{get_param: EnableInstanceHA}, true]}
|
||||
config_download_not_enabled: {equals: [{get_param: ConfigDownload}, false]}
|
||||
|
||||
outputs:
|
||||
role_data:
|
||||
|
@ -265,29 +270,25 @@ outputs:
|
|||
- /var/lib/docker-config-scripts/:/docker-config-scripts/
|
||||
user: nova
|
||||
command: "/docker-config-scripts/nova_wait_for_compute_service.py"
|
||||
step_5:
|
||||
nova_cell_v2_discover_hosts:
|
||||
start_order: 0
|
||||
image: *nova_compute_image
|
||||
net: host
|
||||
detach: false
|
||||
volumes:
|
||||
list_concat:
|
||||
- {get_attr: [ContainersCommon, volumes]}
|
||||
-
|
||||
- /var/lib/config-data/nova_libvirt/etc/my.cnf.d/:/etc/my.cnf.d/:ro
|
||||
- /var/lib/config-data/nova_libvirt/etc/nova/:/etc/nova/:ro
|
||||
- /var/log/containers/nova:/var/log/nova
|
||||
- /var/lib/docker-config-scripts/:/docker-config-scripts/
|
||||
user: root
|
||||
command: "/usr/bin/bootstrap_host_exec nova_compute su nova -s /bin/bash -c '/docker-config-scripts/nova_cell_v2_discover_hosts.py'"
|
||||
environment:
|
||||
# NOTE: this should force this container to re-run on each
|
||||
# update (scale-out, etc.)
|
||||
- list_join:
|
||||
- ''
|
||||
- - 'TRIPLEO_DEPLOY_IDENTIFIER='
|
||||
- {get_param: DeployIdentifier}
|
||||
workflow_tasks:
|
||||
if:
|
||||
- config_download_not_enabled
|
||||
-
|
||||
step5:
|
||||
# Discover hosts via workflow _ONLY_ for non config-download deploy method
|
||||
# that we also run it when:
|
||||
# - nodes get blacklisted
|
||||
# - deployment is run with skip-deploy-identifier
|
||||
# For config-download method we use bellow deploy_steps_tasks
|
||||
- name: nova_compute_discovery_workflow
|
||||
workflow: 'tripleo.nova.v1.cellv2_discovery'
|
||||
input:
|
||||
nova_host_discovery_service: 'nova_compute'
|
||||
nova_host_discovery_container: 'nova_compute'
|
||||
nova_host_discovery_ansible_playbook: '/usr/share/tripleo-common/playbooks/nova_cellv2_host_discover.yaml'
|
||||
- {}
|
||||
# deploy_steps_tasks only run in queens when config-download is used
|
||||
deploy_steps_tasks: {get_attr: [NovaComputeCommon, nova_compute_common_deploy_steps_tasks]}
|
||||
host_prep_tasks:
|
||||
list_concat:
|
||||
- {get_attr: [NovaLogging, host_prep_tasks]}
|
||||
|
|
|
@ -40,6 +40,10 @@ parameters:
|
|||
default: false
|
||||
description: Remove package if the service is being disabled during upgrade
|
||||
type: boolean
|
||||
ConfigDownload:
|
||||
default: false
|
||||
description: Whether config-download method is used or not.
|
||||
type: boolean
|
||||
|
||||
resources:
|
||||
|
||||
|
@ -69,6 +73,9 @@ resources:
|
|||
RoleName: {get_param: RoleName}
|
||||
RoleParameters: {get_param: RoleParameters}
|
||||
|
||||
conditions:
|
||||
config_download_not_enabled: {equals: [{get_param: ConfigDownload}, false]}
|
||||
|
||||
outputs:
|
||||
role_data:
|
||||
description: Role data for the Nova Compute service.
|
||||
|
@ -160,22 +167,25 @@ outputs:
|
|||
- /var/lib/docker-config-scripts/:/docker-config-scripts/
|
||||
user: root
|
||||
command: "/docker-config-scripts/nova_wait_for_compute_service.py"
|
||||
step_5:
|
||||
nova_cell_v2_discover_hosts:
|
||||
start_order: 0
|
||||
image: *nova_ironic_image
|
||||
net: host
|
||||
detach: false
|
||||
volumes:
|
||||
list_concat:
|
||||
- {get_attr: [ContainersCommon, volumes]}
|
||||
-
|
||||
- /var/lib/config-data/nova/etc/my.cnf.d/:/etc/my.cnf.d/:ro
|
||||
- /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
|
||||
- /var/log/containers/nova:/var/log/nova
|
||||
- /var/lib/docker-config-scripts/:/docker-config-scripts/
|
||||
user: root
|
||||
command: "su nova -s /bin/bash -c '/docker-config-scripts/nova_cell_v2_discover_hosts.py'"
|
||||
workflow_tasks:
|
||||
if:
|
||||
- config_download_not_enabled
|
||||
-
|
||||
step5:
|
||||
# Discover hosts via workflow _ONLY_ for non config-download deploy method
|
||||
# that we also run it when:
|
||||
# - nodes get blacklisted
|
||||
# - deployment is run with skip-deploy-identifier
|
||||
# For config-download method we use bellow deploy_steps_tasks
|
||||
- name: nova_compute_discovery_workflow
|
||||
workflow: 'tripleo.nova.v1.cellv2_discovery'
|
||||
input:
|
||||
nova_host_discovery_service: 'nova_compute'
|
||||
nova_host_discovery_container: 'nova_compute'
|
||||
nova_host_discovery_ansible_playbook: '/usr/share/tripleo-common/playbooks/nova_cellv2_host_discover.yaml'
|
||||
- {}
|
||||
# deploy_steps_tasks only run in queens when config-download is used
|
||||
deploy_steps_tasks: {get_attr: [NovaComputeCommon, nova_compute_common_deploy_steps_tasks]}
|
||||
host_prep_tasks:
|
||||
- name: create persistent directories
|
||||
file:
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
#!/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 :
|
|
@ -15,3 +15,5 @@ resource_registry:
|
|||
# stable/queens fix to enable config-download for PreNetworkConfig
|
||||
OS::TripleO::Services::BootParams: ../extraconfig/pre_network/boot-params-service.yaml
|
||||
OS::TripleO::Reboot::SoftwareDeployment: OS::Heat::None
|
||||
parameter_defaults:
|
||||
ConfigDownload: True
|
||||
|
|
|
@ -42,6 +42,7 @@ OPTIONAL_SECTIONS = ['workflow_tasks', 'cellv2_discovery']
|
|||
REQUIRED_DOCKER_SECTIONS = ['service_name', 'docker_config', 'puppet_config',
|
||||
'config_settings']
|
||||
OPTIONAL_DOCKER_SECTIONS = ['docker_puppet_tasks', 'upgrade_tasks',
|
||||
'deploy_steps_tasks',
|
||||
'pre_upgrade_rolling_tasks',
|
||||
'fast_forward_upgrade_tasks',
|
||||
'fast_forward_post_upgrade_tasks',
|
||||
|
|
Loading…
Reference in New Issue