feat: support multiple storage map definitions#42
Conversation
|
Good use case — being able to pre-provision multiple storage maps for different performance tiers is a real need in complex migration environments. The implementation is clean and small. A few things to flag: 1. Both variables defined = both single AND multiple maps silently skippedIf a user sets vars:
mtv_management_storage_map_overrides: "{{ item.value }}"This is actually fine for the multiple path — each iteration gets its own overrides. But the single-map path is skipped entirely (the This is probably the intended behavior, but it's not obvious from the defaults file that the two variables are mutually exclusive. A validation assertion or a comment in 2. Redundant inventory queries on each loop iterationThe "Configure MTV Storage Maps (Multiple)" task calls
These are all re-queried on every iteration of the loop even though the results don't change between storage map definitions. For 2-3 maps this is fine, but at scale it's unnecessary API calls against the MTV inventory. Not a blocker, but worth noting as a potential optimization — the queries could be hoisted above the loop. 3.
|
| Area | Verdict |
|---|---|
| Format/style | Pass (minor trailing whitespace, double blank line) |
| Backward compat | Pass — defaults to {}, single-map path untouched when empty |
| Correctness (happy path) | Pass |
| Correctness (mutual exclusivity) | Works but undocumented — add a comment noting precedence |
| Security | No issues |
Solid feature, small and well-scoped. The main ask is just a note in defaults/main.yml clarifying the relationship between mtv_management_storage_map_overrides and mtv_management_multiple_storage_maps_overrides.
Description
This PR enables the creation of multiple
StorageMapresources within the same MTV management execution. It introduces a new variablemtv_management_multiple_storage_maps_overrideswhich allows users to define a dictionary of storage maps.Motivation
In complex migration scenarios, different virtual machines or plans might require different storage mapping strategies (e.g., migrating to different StorageClasses based on performance tiers).
Currently, the role only supports creating a single, default storage map. By allowing multiple maps:
Changes
mtv_maps.yml: Added logic to detectmtv_management_multiple_storage_maps_overrides. If defined, the role loops through the dictionary to create multiple maps. It maintains backward compatibility with the single-map approach if the new variable is empty or undefined.storagemap.yml.j2: Updated the metadata name to be dynamic, using the key from the overrides dictionary or falling back to the default naming convention.main.yml(defaults): Added the new dictionary structure with documentation examples.Data Structure Example
Testing
mtv_management_multiple_storage_maps_overridesis provided, all specified maps are created in OpenShift.