Skip to content

mantle/azure: Prepare to upload to Fedora Community Gallery#4500

Open
marmijo wants to merge 6 commits intocoreos:mainfrom
marmijo:azure-gallery-updates
Open

mantle/azure: Prepare to upload to Fedora Community Gallery#4500
marmijo wants to merge 6 commits intocoreos:mainfrom
marmijo:azure-gallery-updates

Conversation

@marmijo
Copy link
Copy Markdown
Member

@marmijo marmijo commented Mar 20, 2026

Rework the mantle Azure API to so we can start uploading to the Fedora Community Shared Image Gallery. See individual commits.

See:

Follow-on to #4109


This includes breaking changes to the pipeline, so we'll need coreos/fedora-coreos-pipeline#1323 to merge at the same time.

This was useful for a time, but now that we'll be uploading to shared
community galleries, we should remove the functionality so we don't
delete entire galleries by mistake.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Azure API in mantle to support uploading images to the Fedora Community Shared Image Gallery. The changes include adding support for image offers, using a deterministic versioning scheme based on the CoreOS version, and adding required tags to the gallery images. The code is also updated to be more careful by checking for existing resources before creating them and removing the functionality to delete an entire gallery.

My review focuses on improving code maintainability and adhering to best practices. I've suggested refactoring some duplicated error-handling logic into a helper function and using returned errors instead of os.Exit in a command handler. I also found a minor typo in a comment.

@marmijo marmijo force-pushed the azure-gallery-updates branch from d581583 to d891aaf Compare March 20, 2026 20:21
marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 20, 2026
Pass the full FCOS version through to the Azure gallery image creation
so ore can derive an Azure-compatible gallery image version. Azure
gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version.

See: coreos/coreos-assembler#4500
@marmijo
Copy link
Copy Markdown
Member Author

marmijo commented Mar 20, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request reworks the mantle Azure API to facilitate uploading images to the Fedora Community Shared Image Gallery. Key changes include adding flags for Azure offer and CoreOS version, making resource creation more idempotent by checking for existence before creation, and adjusting image identifiers for the gallery. The code is well-structured and aligns with the PR's objectives. I've included a couple of suggestions to improve error handling in the CLI and to follow Go best practices for context propagation, which will enhance maintainability and robustness.

marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 20, 2026
Pass the full FCOS version through to the Azure gallery image creation
so ore can derive an Azure-compatible gallery image version. Azure
gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version.

See: coreos/coreos-assembler#4500
@marmijo marmijo force-pushed the azure-gallery-updates branch from d891aaf to 91dfb49 Compare March 26, 2026 19:56
@marmijo marmijo added hold waiting on something labels Mar 26, 2026
dustymabe
dustymabe previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

code LGTM.

the suggestions are purely cosmetic (naming and such) and optional.

sv(&blobUrl, "image-blob", "", "source blob url")
sv(&resourceGroup, "resource-group", "kola", "resource group name")
sv(&architecture, "arch", "", "The target architecture for the image")
sv(&galleryProfile, "gallery-profile", "", "The azure image gallery profile")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK. Nothing wrong with the code. This is just a naming thing.

Suggested change
sv(&galleryProfile, "gallery-profile", "", "The azure image gallery profile")
sv(&coreos-gallery-policy, "coreos-gallery-policy", "", "The CoreOS specific profile/policy to apply to the image on upload")

I think right now the way things are presented to the user the user could think azure image gallery profile is actually an azure construct. It's not, this is CoreOS/Fedora Specific. The suggestion abovve is an attempt to try to improve the clarity here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not tied to the suggested name above either.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That makes a lot of sense. I'll change this to --coreos-gallery-profile.

Architecture: &azureArch,
},
}, nil)
profileCfg, err := a.resolveGalleryProfile(galleryProfile, version)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

at least in its current form this function is just setting the version and tags so it might be easier to read if it just set those instead of returning a GalleryProfileConfig

Suggested change
profileCfg, err := a.resolveGalleryProfile(galleryProfile, version)
version, tags, err := a.resolveGalleryProfile(galleryProfile, version)

totally optional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went with the struct mostly to allow us to easily expand the profile handling in the future.

Right now it only operates on version on tags so returning those would work too. I kept GalleryProfileConfig because if we add more profile-specific behavior later, I think it will be cleaner to extend a single return type. Additional metadata or other per-gallery overrides would fit easily in there like Offer, SKU, and Provider, etc.

@marmijo
Copy link
Copy Markdown
Member Author

marmijo commented Mar 27, 2026

code LGTM.

the suggestions are purely cosmetic (naming and such) and optional.

Thanks! I added that 4th commit to this PR to rework the image version/definition deletion. That commit also removes the deletion of the managed image that was being used as the source for the gallery image. So in it's current form, we'd have managed images accumulating with no garbage collection.

I’m testing an SDK upgrade that would let us use the uploaded blob directly as the source for the gallery image version instead of the managed image as source. If that works cleanly and the change stays reasonably small, I’d like to include it in this PR so we can drop the managed image step entirely.

EDIT: added a link to the "managed image step"

marmijo added 5 commits March 27, 2026 11:18
Support gallery profiles for Azure gallery image creation so
profile-specific version and tagging loggic can be handled in one place.

The new `fedora-community` profile truncates FCOS versions to Azure's
required x.y.z gallery image vresion format[1] and applies the Fedora
community gallery tags[2]. With no profile selected, the version is used
as-is and no extra tags are added.

This keeps the Fedora-specific behavior explicit while leaving room for
additional gallery profiles in the future.

[1]: coreos/fedora-coreos-tracker#148 (comment)
[2]: coreos/fedora-coreos-tracker#148 (comment)
Check for an existing gallery and image definition before creating
it and reuse it if present. Also check for an existing gallery
image version and fail if it already exists instead creating it.
Change Azure gallery deletion to operate on a single gallery image
version instead of removing all versions and deleting the image
definition unconditionally.

Require `--version` for `delete-gallery-image`, apply gallery-profile
version handling when resolving the version to delete, and treat a
missing version as a successful no-op.

Also add `--delete-definition` to optionally remove the gallery image
definition after the version delete, letting Azure reject the request if
other versions still exist in the definition.
refresh Go modules for azure-sdk-for-go armcompute/v4 upgrade.

Append `/v4 v4.2.1` to `armcompute` in go.mod and update all 5 imports
of `armcompute` in `mantle/platform/api/azure`.

```
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4
go mod vendor
go mod tidy
```
Now that the `armcompute` libraries in the azure-sdk-for-go have been
updated, we can stop creating an intermediate managed image before
creating the gallery image version, and just use the blob directly as
the source for the gallery image version.

Resolve the storage account resource ID from the blob URL to use when
creating the image from blob source, as required by the newer Azure
Compute API.
@dustymabe
Copy link
Copy Markdown
Member

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Azure SDK dependency to version 4.2.1 and introduces several enhancements to the Azure gallery image management. Key changes include the addition of new CLI flags for gallery profiles and image versions, improved error handling for gallery resource creation, and the refactoring of Azure API client initialization to use a client factory. My feedback focuses on improving code maintainability by suggesting the extraction of 'get-or-create' logic into helper methods and recommending that CLI command functions return errors instead of using os.Exit(1).

Copy link
Copy Markdown
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

LGTM

marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 27, 2026
Define the new coreos gallery profile config item in config.yaml and
pass it to the Azure gallery image creation.

Also pass the full FCOS version through so ore can derive an
Azure-compatible gallery image version based on the gallery profile.
Azure gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version since we are
using the "fedora-community" coreos gallery profile.

See: coreos/coreos-assembler#4500
marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 27, 2026
Define the new coreos gallery profile config item in config.yaml and
pass it to the Azure gallery image creation.

Also pass the full FCOS version through so ore can derive an
Azure-compatible gallery image version based on the gallery profile.
Azure gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version since we are
using the "fedora-community" coreos gallery profile.

See: coreos/coreos-assembler#4500
marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 27, 2026
Define the new coreos gallery profile config item in config.yaml and
pass it to the Azure gallery image creation.

Also pass the full FCOS version through so ore can derive an
Azure-compatible gallery image version based on the gallery profile.
Azure gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version since we are
using the "fedora-community" coreos gallery profile.

See: coreos/coreos-assembler#4500
marmijo added a commit to marmijo/fedora-coreos-pipeline that referenced this pull request Mar 27, 2026
Define the new coreos gallery profile config item in config.yaml and
pass it to the Azure gallery image creation.

Also pass the full FCOS version through so ore can derive an
Azure-compatible gallery image version based on the gallery profile.
Azure gallery image versions must be in x.y.z form, while FCOS versions
include an additional "stream" component. The full FCOS version is now
provided and truncated before creating the image version since we are
using the "fedora-community" coreos gallery profile.

See: coreos/coreos-assembler#4500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold waiting on something

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants