Repository navigation
Conversation
…sections Signed-off-by: Yevhen Artemenko <eartemenko@playtika.com>
Contributor
Author
|
@Avatos Please check the PR when you have time, thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add
imageNametoblockDevicefor InstanceV2Description of your changes
Adds
imageName/imageNameRef/imageNameSelectorsupport toblockDevice[]entries ofInstanceV2(both cluster and namespaced scope).Background
The upstream Terraform provider resolves
image_name→ image UUID only for the top-levelimage_namefield (ephemeral-disk boot). For boot-from-volume (block_device[].uuid,source_type: image,destination_type: volume) the provider requires a raw image UUID. This made it impossible to write portable manifests across clusters where the same image has different UUIDs.What this PR does
New field
blockDevice[].imageNameImageV2Client+imagesutils.IDFromName(Glance API), without any changes to the upstream Terraform provider.uuid; only valid forsource_type: image.ForceNew: true— changing the name is detected as drift and blocks the update (refuse to update … requires replacing it), consistent with the existinguuidbehaviour.Drift detection via
ReadContextwrapperRead, the provider looks up the current name of the boot-volume image (by UUID) in Glance and writes it back to the Terraform state asimage_name.CustomizeDiffcompares the config name with the observed name. A change produces aForceNewdiff that upjet refuses to apply, surfacing a clear error.imageNameRef/imageNameSelector— optional; resolves the name from aImageV2managed resource usingExtractParamPath("name", false). Works with both fully-managed andmanagementPolicies: [Observe]images (for the latter, setspec.forProvider.nameexplicitly).Late-initialize guard —
BlockDevice.ImageNameis added toLateInitializer.IgnoredFieldsso it is never overwritten by the observed UUID during late-init.Usage examples
Direct name (no ImageV2 object required):
With reference to an observe-only ImageV2:
I have
make submodules; make reviewable testto ensure this PR is ready for review.How has this code been tested
go test ./config/common/blockdevice/...— unit tests covering:image_namefield present,DiffSuppressFuncset onuuid)CreateContextwrapper: name resolved to UUID before upstream createuuid+imageNameconflict, wrongsource_type, image not found, multiple images with same nameReadContextwrapper: image name populated from Glance after readmake generate— verified generated types (ImageName,ImageNameRef,ImageNameSelectorinblockDevicefor both cluster and namespaced scope), resolvers, deepcopy, CRDsmake reviewable test—0 issues, all unit tests passInstanceV2withimageName: Ubuntu_2404_openstackcreated successfully;status.atProvider.blockDevice[0].imageNameshows the resolved name after first reconcileimageNameto a different image name →Synced=False, errorrefuse to update … cannot change the value of the argument "block_device.0.image_name"— server untouchedimageNameRefpointing to an observe-onlyImageV2withforProvider.nameset — resolves correctly