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

Add image/blob tagging functionality to ore #3915

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mike-nguyen
Copy link
Member

This is prep work for the garbage collection on RHCOS. In OpenShift, RHCOS nodes are provisioned with the original boot image and regardless of newer boot images. The original boot images need to be kept indefinitely and policies can be set up to garbage collect images based on tags.

We need the ability to tag images to facilitate garbage collection
of RHCOS AMIs that are not used in boot images. The pre-existing
tagging functionality on the initial upload cannot be leveraged because
we don't know whether a RHCOS build will be used as a boot image
at build time.
Add ability to tag images to facilate resource management.
Add ability to label images to facilate resource management.
Add ability to tag images to facilate resource management.
@jlebon
Copy link
Member

jlebon commented Oct 30, 2024

This seems sane to me though do note that there is renewed interest in solving the bootimage bump problem along with a rough timeline. So we should be able at some point to delete even those bootimages that were promoted.

@mike-nguyen
Copy link
Member Author

They still want us to tag images for cost reporting. We can figure out the cluster boot image updates when it happens.


err := API.CreateTags([]string{amiID}, tagMap)
if err != nil {
fmt.Fprintf(os.Stderr, "couldn't create image tags: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

\n

Copy link
Member

Choose a reason for hiding this comment

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

And similarly for the other files.

Comment on lines +53 to +62
tagMap := make(map[string]string)
for _, tag := range tags {
splitTag := strings.SplitN(tag, "=", 2)
if len(splitTag) != 2 {
fmt.Fprintf(os.Stderr, "invalid tag format; should be key=value, not %v\n", tag)
os.Exit(1)
}
key, value := splitTag[0], splitTag[1]
tagMap[key] = value
}
Copy link
Member

Choose a reason for hiding this comment

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

Minor: feels like we should just lower this into API.CreateTags() so that it's deduped with ore aws upload --tags.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly for the others.

Aliyun.AddCommand(cmdTagImage)
cmdTagImage.Flags().StringVar(&id, "id", "", "Aliyun Image ID")
cmdTagImage.Flags().StringVar(&region, "region", "", "Region")
cmdTagImage.Flags().StringSliceVar(&tags, "tags", []string{}, "list of key=value tags to attach to the Aliyun image")
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to add --tags to ore aliyun create-image too for consistency.

Similarly for GCP and Azure.

For cost reporting purposes, I would expect us actually to want to set the tags on upload instead of as a postprocess step.

}

if len(kr.Keys) == 0 {
fmt.Fprintf(os.Stderr, "No storage service keys found")
Copy link
Member

Choose a reason for hiding this comment

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

\n

Doesn't need Fprintf.

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.

2 participants