Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parameter to force ODCR to a single AZ #4325

Merged
merged 8 commits into from
Jan 3, 2022
Merged

Conversation

fridim
Copy link
Collaborator

@fridim fridim commented Dec 23, 2021

jira: GPTEINFRA-2334

New feature for the agnosticd_odcr module: force all AZs to be a single AZ.

Sometimes we want to provision all the instances into a single AZ (for saving costs for example).

In order to do that, one would have to redefine the reservations defined in the var agnosticd_aws_capacity_reservations to make it single-zone. Here is an example with ocp4-cluster.

From:

agnosticd_aws_capacity_reservations:
  # Bastion can have its own AZ
  az1:
  - instance_type: "{{ bastion_instance_type }}"
    instance_count: 1
    instance_platform: "{{ bastion_instance_platform }}"

  masters:
  - instance_type: "{{ master_instance_type }}"
    instance_count: 3
    instance_platform: Linux/UNIX

  # Split workers in 2 AZs if possible.  Could be the same zone.
  workers1:
  # Workers: half of workers
  - instance_type: "{{ worker_instance_type }}"
    instance_count: >-
      {{ ( worker_instance_count | int / 2 )
      | round(0, 'ceil')
      | int }}
    instance_platform: Linux/UNIX
  workers2:
  - instance_type: "{{ worker_instance_type }}"
    instance_count: >-
      {{ ( worker_instance_count | int / 2 )
      | round(0, 'ceil')
      | int }}
    instance_platform: Linux/UNIX

to:

agnosticd_aws_capacity_reservations:
  # Bastion can have its own AZ
  az1:
  - instance_type: "{{ bastion_instance_type }}"
    instance_count: 1
    instance_platform: "{{ bastion_instance_platform }}"

  - instance_type: "{{ master_instance_type }}"
    instance_count: 3
    instance_platform: Linux/UNIX

  - instance_type: "{{ worker_instance_type }}"
    instance_count: "{{ worker_instance_count }}"
    instance_platform: Linux/UNIX

To avoid the work of redefining the reservations in all the configs depending on whether the user wants a single AZ or spread across multiple AZ, we want a simple ON|OFF flag.

This PR, if applied, adds a new parameter to the agnosticd_odcr module to automatically group the reservations into one or keep the default behavior. That parameter can be controlled via the global variable agnosticd_aws_capacity_reservation_single_zone (false by default).
The advantage of doing so inside the module is that it should be transparent for the config (ocp4-cluster). No logic needed there.

If the parameter single_zone is set to true, all the reservation will target the same AZ.
All the reservations are merged into one AZ. Reservations that are the same instance_type and instance_platform are merged together and instance_count is incremented accordingly.

The result will include availability_zone value for the virtual zones, but they will all be the same.

  • Add unit tests to helper functions to regroup all the reservation into
    a single AZ
  • test with ocp4-cluster
    • patch install-config.yml.j2 template to actually use odcr AZs
  • update Readme.adoc
SUMMARY
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

Tested with:

  • ansible2.9-python3.6-2021-11-30 python virtualenv
  • ansible 2.9.27
  • python 3.10.1

jira: GPTEINFRA-2334

New feature for the agnosticd_odcr module: force all AZs to be a single
AZ.

If the parameter 'all_in_one' is set to true, all the reservation will target the same
AZ.

All the reservations are merged into one AZ. Reservations that are the
same instance_type and platform, are merged together and instance_count
is updated accordingly.

- Add unit tests to helper functions to regroup all the reservation into
a single AZ
- test with ocp4-cluster
  - destroy should loop over all the possible regions to build the
  inventory (bastion)
  - try multiple regions: let agnosticd_odcr find the right region and AZ.
  - patch install-config.yml.j2 template to actually use odcr AZs
- update Readme.adoc
@fridim fridim requested a review from a team as a code owner December 23, 2021 22:39
@fridim fridim requested a review from rut31337 December 24, 2021 00:24
@fridim fridim merged commit b028055 into development Jan 3, 2022
@fridim fridim deleted the GPTEINFRA-2334 branch January 3, 2022 15:49
pericnenad pushed a commit to migtools/agnosticd that referenced this pull request Jan 18, 2022
* New parameter to force ODCR to a single AZ

jira: GPTEINFRA-2334

New feature for the agnosticd_odcr module: force all AZs to be a single
AZ.

If the parameter 'all_in_one' is set to true, all the reservation will target the same
AZ.

All the reservations are merged into one AZ. Reservations that are the
same instance_type and platform, are merged together and instance_count
is updated accordingly.

- Add unit tests to helper functions to regroup all the reservation into
a single AZ
- test with ocp4-cluster
  - destroy should loop over all the possible regions to build the
  inventory (bastion)
  - try multiple regions: let agnosticd_odcr find the right region and AZ.
  - patch install-config.yml.j2 template to actually use odcr AZs
- update Readme.adoc

* formating

* Remove debug statement

* Remove temporary tags

* rename 'all_in_one' to 'single_zone'

* Don't work with multi-region for now

* Propagate the single-AZ to all virtual AZ

To make it transparent for the config.

* Address JK's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants