Skip to content

Commit

Permalink
DNM ci_dcn_site: Add scaling down of a DCN site
Browse files Browse the repository at this point in the history
  • Loading branch information
krcmarik committed Dec 21, 2024
1 parent d821883 commit cec7c54
Show file tree
Hide file tree
Showing 7 changed files with 389 additions and 19 deletions.
19 changes: 19 additions & 0 deletions playbooks/dcn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@
- _ceph_bootstrap_node != ''
ansible.builtin.include_role:
name: ci_dcn_site
when: cifmw_ci_dcn_site_scaledown_az is not defined or cifmw_ci_dcn_site_scaledown_az == ""

- name: The map for az0 contains all AZ backends
ansible.builtin.set_fact:
az_to_group_map:
az0: computes
az1: dcn1-computes
az2: dcn2-computes

- name: Scaledown the {{ cifmw_ci_dcn_site_scaledown_az }} site
vars:
_az_to_scaledown: "{{ cifmw_ci_dcn_site_scaledown_az }}"
_subnet: "subnet{{ (az_to_group_map | dict2items | map(attribute='key') | list)
| ansible.utils.index_of('eq', cifmw_ci_dcn_site_scaledown_az) + 1 }}"
_group_name: "{{ az_to_group_map[cifmw_ci_dcn_site_scaledown_az] }}"
_group_hosts: "{{ groups[az_to_group_map[cifmw_ci_dcn_site_scaledown_az]] }}"
ansible.builtin.include_role:
name: ci_dcn_site
when: cifmw_ci_dcn_site_scaledown_az is defined and cifmw_ci_dcn_site_scaledown_az != ""

- name: Find all created CRs
ansible.builtin.find:
Expand Down
1 change: 1 addition & 0 deletions roles/ci_dcn_site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ with a collocated Ceph cluster.
## Parameters

* `_az`: The name of the availability zone for the AZ, e.g. `az1`
* `_az_to_scaledown`: The name of the availability zone for the deployed AZ to be scale-downed.
* `_group_name`: The name of the group of nodes to be deployed, e.g. `dcn1-computes`
* `_subnet`: The name of the subnet the DCN site will use, e.g. `subnet2`
* `_subnet_network_range`: The range of the subnet the DCN site will use, e.g. `192.168.133.0/24`
Expand Down
1 change: 1 addition & 0 deletions roles/ci_dcn_site/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ ci_dcn_site_search_storagemgmt_network_names:
- "storagemgmtdcn1"
- "storagemgmtdcn2"
cifmw_ci_dcn_site_enable_network_az: false
_az_to_scaledown: ""
34 changes: 34 additions & 0 deletions roles/ci_dcn_site/tasks/deploy_site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# 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.

- name: Render and apply pre-ceph CRs in DCN context
ansible.builtin.include_tasks: pre-ceph.yml

- name: Deploy Ceph in DCN context
ansible.builtin.include_tasks: ceph.yml

- name: Render and apply post-ceph CRs in DCN context
ansible.builtin.include_tasks: post-ceph.yml

- name: Run Nova cell discovery for new DCN hosts
kubernetes.core.k8s_exec:
api_key: "{{ _auth_results.openshift_auth.api_key }}"
namespace: openstack
pod: nova-cell0-conductor-0
command: nova-manage cell_v2 discover_hosts --verbose

- name: Create new AZ and add new hosts to it
ansible.builtin.include_tasks: az.yml
23 changes: 6 additions & 17 deletions roles/ci_dcn_site/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,10 @@
- name: Set Network related facts
ansible.builtin.include_tasks: set_network_facts.yml

- name: Render and apply pre-ceph CRs in DCN context
ansible.builtin.include_tasks: pre-ceph.yml
- name: Deploy a DCN site
ansible.builtin.include_tasks: deploy_site.yml
when: _az_to_scaledown == ""

- name: Deploy Ceph in DCN context
ansible.builtin.include_tasks: ceph.yml

- name: Render and apply post-ceph CRs in DCN context
ansible.builtin.include_tasks: post-ceph.yml

- name: Run Nova cell discovery for new DCN hosts
kubernetes.core.k8s_exec:
api_key: "{{ _auth_results.openshift_auth.api_key }}"
namespace: openstack
pod: nova-cell0-conductor-0
command: nova-manage cell_v2 discover_hosts --verbose

- name: Create new AZ and add new hosts to it
ansible.builtin.include_tasks: az.yml
- name: Scale a DCN site down
ansible.builtin.include_tasks: scaledown_site.yml
when: _az_to_scaledown is defined and _az_to_scaledown != ""
Loading

0 comments on commit cec7c54

Please sign in to comment.