-
Notifications
You must be signed in to change notification settings - Fork 5
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
CRAYSAT-1896: Add support for CFS v2 or v3 to sat bootprep
#288
base: main
Are you sure you want to change the base?
Conversation
Keeping this as a draft until I test, but it's a fairly large PR, so feel free to look at it before I finish testing and let me know if you have any questions or concerns. |
It looks like I need to still add support for pagination of resources other than sessions (e.g. configurations). We do a GET of So I need to add paging support for other CFS API resources to Here's the error I get right now without this support for paging:
This is because a GET to |
I also still need to add the |
f2c4833
to
1d23089
Compare
sat bootprep
sat bootprep
I appear to have broken the ability to specify "latest" as the product version in a configuration layer as well. I'll have to look into that. |
23d602e
to
10d5836
Compare
I have fixed the issues noted in my prior comments. That is:
|
Minimal testing performed so far:
I need to do some more thorough testing, and while doing so, it would probably be nice to think about how we can start creating some automated tests of the |
6d6e14a
to
054e7bd
Compare
Add support for using either the CFS v2 or v3 API in `sat bootprep` based on the value of the command-line option `--cfs-version` or the config-file option `cfs.api_version`. Before this change, `sat bootprep` was hard-coded to always use CFS v2. Update the `InputConfiguration`, `InputConfigurationLayer`, and `AdditionalInventory` classes to keep a reference to the instance of the version-specific subclass of `CFSClientBase`, so that they can delegate operations to the appropriate version of the CFS API. This removes a lot of code that required knowledge of the CFS API and instead uses classes and methods defined in the `csm_api_client` library, which has already been updated to support both CFS v2 and v3. This should reduce code duplication across `sat` and `csm_api_client`. Some unit tests are no longer needed here because that functionality is tested in the `csm_api_client` instead. Other unit tests are updated to include the `cfs_client` instance that needs to be passed into the input layer and configuration objects. This also makes the `playbook` property required in the schema because the CFS v3 API requires that the playbook be specified. This is technically a backwards-incompatible schema change because it can invalidate certain bootprep input files if they define layers without playbooks. The default bootprep files contain a playbook for every layer and do not depend on the CFS default playbook value, so this should be a pretty safe and non-disruptive change. Test Description: Unit tests only so far. Still needs to be tested on a real system.
The CFS v3 API returns paged results for the `/components` API resource, which needs to be handled by the client. Upgrade the version of the csm_api_client library and use the new `get_configurations` method to handle the paging. Test Description: Not yet tested.
If the value "latest" is specified for the version of a product in a product-based layer in a CFS configuration in a bootprep input file, pass in `None` to `from_product_catalog` to properly get the product catalog data associated with the latest version of the product. Test Description: Not tested yet.
49b5c01
to
1bccea9
Compare
Here are my testing results from rocket: https://gist.github.com/haasken-hpe/8cc8455889b7afe729c5b77dcebfc0f7 I have only done limited testing with |
Since I have merged Cray-HPE/python-csm-api-client#47 and have pushed a release/2.3 branch there, we now have a stable build, so I am rebasing this PR to drop the commit that references the unstable repo. |
Add the `--cfs-version` command-line option to `sat bootprep run`. This option is used to select the version of the CFS API to use when creating CFS configurations or checking for the existence of CFS configurations when creating other items in the bootprep input file. Add this option to the man page as well. Test Description: Built man page and examined in `man`. Other testing yet to be performed on a system.
A delay has been observed in `sat bootprep`, and it may be due to the loading of product catalog data taking longer with the split product catalog config maps. Add a debug-level log message before and after loading the product catalog, so we can see what's happening.
Instead of requiring that the playbook be present in the bootprep input file through the schema, validate it specifically when `sat` is configured to use the CFS v3 API, since the CFS v2 API does not require that CFS configuration layers have a playbook. This will allow people to continue using old bootprep input files that have CFS configuration layers that do not specify a playbook as long as they use CFS v2. This is slightly less disruptive than making a schema change. Test Description: Unit tests only so far.
The `InputConfigurationLayer` instances stored in the `layers` attribute of the `InputConfiguration` class were not being validated when the `validate` method of the `InputConfiguration` was called because this class did not have any validation methods. Add a validation method that validates the layers, and make the `InputConfigurationLayer` class inherit from `Validatable`, so that it has a `validate` method itself. This has not been added for `AdditionalInventoryLayer` yet because there are currently no validation methods on that class. Note that an `index` is added to the constructor of the `InputConfigurationLayer` class to allow for the `__str__` to unambiguously refer to the layer within the CFS configuration. Test Description: Unit tests have been added to test the `validate` method on the `InputConfiguration` class.
Add support for Jinja2 template rendering to several more properties in the `sat bootprep` input file. The following properties now support Jinja2 templating: - configurations[].layers[].git.commit - configurations[].layers[].git.url - configurations[].layers[].product.commit - All properties under images[].base.ims - session_templates[].image.ims.id Allowing Jinja2 template rendering for these fields is helpful in writing automated test cases for `sat bootprep` that can run on any system. These values will vary from system to system, so it's helpful to pass this information in to the bootprep input file as a variable. Test Description: Added unit tests pass. Will also be tested on a system with bootprep input files that use Jinja templates in these properties.
Add support for Jinja template rendering to the `name`, `url`, `branch`, and `commit` properties of the `additional_inventory` of a CFS configuration specified in a bootprep input file. This is useful for writing automated tests that obtain this information from a system and pass it in through variables with `--vars-file`. Test Description: The added unit tests pass, and it will be tested on rocket as well.
b382efb
to
c751745
Compare
Summary and Scope
Add support for using either the CFS v2 or v3 API in
sat bootprep
based on the value of the command-line option--cfs-version
or the config-file optioncfs.api_version
. Before this change,sat bootprep
was hard-coded to always use CFS v2.Update the
InputConfiguration
,InputConfigurationLayer
, andAdditionalInventory
classes to keep a reference to the instance of the version-specific subclass ofCFSClientBase
, so that they can delegate operations to the appropriate version of the CFS API.This removes a lot of code that required knowledge of the CFS API and instead uses classes and methods defined in the
csm_api_client
library, which has already been updated to support both CFS v2 and v3. This should reduce code duplication acrosssat
andcsm_api_client
.Some unit tests are no longer needed here because that functionality is tested in the
csm_api_client
instead. Other unit tests are updated to include thecfs_client
instance that needs to be passed into the input layer and configuration objects.This also makes the
playbook
property required in the schema because the CFS v3 API requires that the playbook be specified. This is technically a backwards-incompatible schema change because it can invalidate certain bootprep input files if they define layers without playbooks. The default bootprep files contain a playbook for every layer and do not depend on the CFS default playbook value, so this should be a pretty safe and non-disruptive change.Issues and Related PRs
Testing
Tested on:
Test description:
Unit tests only so far.
Still needs to be tested on a real system.
Risks and Mitigations
This has a moderate risk level. It introduces a bootprep input file schema change that can cause files that do not specify playbook to not validate anymore.
It also is a significant code refactor in that it pushes a lot of the CFS-API knowledge out of the bootprep code and offloads it to the
csm_api_client
library.These risks can be mitigated by thorough testing to ensure that CFS configuration creation and image customization still works in
sat bootprep
.Pull Request Checklist