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

feat: configure flavors in Nova automatically #499

Merged
merged 19 commits into from
Dec 9, 2024
Merged

Conversation

skrobul
Copy link
Collaborator

@skrobul skrobul commented Nov 19, 2024

This PR brings a little operator style application that monitors a directory with YAML specifications of the machine flavors. If any of the files in the linked repository changes, the application parses all the specs in a directory, then compares and reconciles them with the configured Nova instance.

Please note that this will NOT delete (prune) flavors that have been removed from the repository.

Closes https://rackspace.atlassian.net/browse/PUC-598
Supersedes #454

Merge with https://github.com/RSS-Engineering/undercloud-deploy/pull/224

@skrobul skrobul force-pushed the nova-flavor-monitor branch 9 times, most recently from 72c0159 to 87d585e Compare November 20, 2024 16:15
@skrobul skrobul changed the title WIP: Nova flavor monitor feat: configure flavors in Nova automatically Nov 20, 2024
@skrobul skrobul marked this pull request as ready for review November 20, 2024 16:17
@skrobul skrobul force-pushed the nova-flavor-monitor branch from 87d585e to 9717207 Compare November 20, 2024 16:23
@skrobul skrobul requested a review from a team November 20, 2024 16:26
@skrobul skrobul force-pushed the nova-flavor-monitor branch from 9717207 to a615166 Compare November 20, 2024 17:08
Copy link
Contributor

@cardoe cardoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still wondering why not just using ansible and having a playbook for managing a flavor and it takes in the flavor spec as an input?

components/keystone/aio-values.yaml Outdated Show resolved Hide resolved
containers/nova-flavors/Dockerfile.nova-flavors Outdated Show resolved Hide resolved
@skrobul
Copy link
Collaborator Author

skrobul commented Nov 21, 2024

I'm still wondering why not just using ansible and having a playbook for managing a flavor and it takes in the flavor spec as an input?

OK, that's fair question - let me break this down. At the moment the Flavor specifications are presented as collection of YAML files in a specific structured format.
For each of those files, we have to execute some business logic in order to make them usable. Some of those tasks are:

  • parsing the input and validating that given flavor is defined correctly
  • filtering out the records that are not pertinent to a given environment
  • for the data itself, there are various unit conversions needed. For example, the specs have the memory size defined in gigabytes, but Nova expect them to be defined in mebibytes and the BMC/Redfish on the baremetal node reports them as megabytes.
  • for each of the flavors, the name will be different depending on the context - for example specification will say nonprod.gp2.small but in Nova this needs to have a resource class of resources:CUSTOM_BAREMETAL_GP2SMALL and in Ironic, this has to be baremetal.gp2small.
  • since Nova API does not support 'update' operation (unless you are updating just the description), to update flavors they need to be deleted and recreated. It's good to do that only when needed.

Now, you could of course implement all this logic inside of Ansible (which really is just a YAML wrapper around Python), but I am pretty sure it will get messy and untestable pretty quickly. You could write a custom module for Ansible, which would again be just another Python script.

Alternatively, you could manually write out playbooks with some of this data precomputed. However, this approach would result in duplicated data in various formats, which would make it more error-prone and require more work to maintain.

For the sake of argument, let's say we decided to use Ansible for all of this and you have a role that sets up flavors in Nova. Now you need to make sure that you run this playbook every time someone adds or removes a new flavor. As far as I know, we do not have the machinery to do that at the moment, so it would probably require additional dependencies like Argo to detect repository changes and yet another container image to execute the Ansible.

On top of all that, the testability of such solution would be difficult to achieve and quite convoluted.

Based on these considerations, I believe implementing this in a programming language like Python is a more suitable approach than using a markup language.

@skrobul skrobul force-pushed the nova-flavor-monitor branch from 99bb0d4 to d504e52 Compare November 25, 2024 11:05
skrobul added a commit that referenced this pull request Nov 25, 2024
Based on the discussion in #499 (comment) this commit removes the repetitive directives to set the application UIDs, GIDs as well as the name and home directory.
The new, standardised way is to use:
- user with name appuser and UID 1000
- group with name appgroup and GID 1000
- location of the code in /app
@skrobul skrobul force-pushed the nova-flavor-monitor branch 2 times, most recently from 069abbc to ad51616 Compare November 27, 2024 12:11
@skrobul skrobul force-pushed the nova-flavor-monitor branch from ad51616 to ae3c1c3 Compare December 5, 2024 18:29
This adds code that performs simple synchronization of the Flavor Specs
defined in a YAML files in particular directory (presumably downloaded
through git-sync) with a chosen Nova API instance.
Prior to this change it was down to the client of FlavorSpec to filter
out the irrelevant flavors, but now for consistency this filtering
happens immediately when the flavors are loaded.
@skrobul skrobul force-pushed the nova-flavor-monitor branch from ae3c1c3 to 7101e17 Compare December 5, 2024 18:55
@cardoe
Copy link
Contributor

cardoe commented Dec 9, 2024

I'll say long term I don't think this is the way to go. This is a lot of code for just flavor handling and we've got to handle images and keystone objects. But it moves us forward.

Copy link
Contributor

@cardoe cardoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll say long term I don't think this is the way to go. This is a lot of code for just flavor handling and we've got to handle images and keystone objects. But it moves us forward.

@cardoe cardoe added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit a09af47 Dec 9, 2024
26 checks passed
@cardoe cardoe deleted the nova-flavor-monitor branch December 9, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants