-
Notifications
You must be signed in to change notification settings - Fork 1.5k
OCPBUGS-4809: Azure: toggle image in machinesets #6694
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ const ( | |
| ) | ||
|
|
||
| // Machines returns a list of machines for a machinepool. | ||
| func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string, capabilities map[string]string, rhcosVersion string) ([]machineapi.Machine, error) { | ||
| func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string, capabilities map[string]string, useImageGallery bool) ([]machineapi.Machine, error) { | ||
| if configPlatform := config.Platform.Name(); configPlatform != azure.Name { | ||
| return nil, fmt.Errorf("non-Azure configuration: %q", configPlatform) | ||
| } | ||
|
|
@@ -50,7 +50,7 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine | |
| if len(azs) > 0 { | ||
| azIndex = int(idx) % len(azs) | ||
| } | ||
| provider, err := provider(platform, mpool, osImage, userDataSecret, clusterID, role, &azIndex, capabilities, rhcosVersion) | ||
| provider, err := provider(platform, mpool, osImage, userDataSecret, clusterID, role, &azIndex, capabilities, useImageGallery) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "failed to create provider") | ||
| } | ||
|
|
@@ -82,7 +82,7 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine | |
| return machines, nil | ||
| } | ||
|
|
||
| func provider(platform *azure.Platform, mpool *azure.MachinePool, osImage string, userDataSecret string, clusterID string, role string, azIdx *int, capabilities map[string]string, rhcosVersion string) (*machineapi.AzureMachineProviderSpec, error) { | ||
| func provider(platform *azure.Platform, mpool *azure.MachinePool, osImage string, userDataSecret string, clusterID string, role string, azIdx *int, capabilities map[string]string, useImageGallery bool) (*machineapi.AzureMachineProviderSpec, error) { | ||
| var az *string | ||
| if len(mpool.Zones) > 0 && azIdx != nil { | ||
| az = &mpool.Zones[*azIdx] | ||
|
|
@@ -110,15 +110,17 @@ func provider(platform *azure.Platform, mpool *azure.MachinePool, osImage string | |
| image.Offer = mpool.OSImage.Offer | ||
| image.SKU = mpool.OSImage.SKU | ||
| image.Version = mpool.OSImage.Version | ||
| } else { | ||
| } else if useImageGallery { | ||
| // image gallery names cannot have dashes | ||
| galleryName := strings.Replace(clusterID, "-", "_", -1) | ||
| id := clusterID | ||
| if hyperVGen == "V2" { | ||
| id += "-gen2" | ||
| } | ||
| imageID := fmt.Sprintf("/resourceGroups/%s/providers/Microsoft.Compute/galleries/gallery_%s/images/%s/versions/%s", rg, galleryName, id, rhcosVersion) | ||
| imageID := fmt.Sprintf("/resourceGroups/%s/providers/Microsoft.Compute/galleries/gallery_%s/images/%s/versions/latest", rg, galleryName, id) | ||
| image.ResourceID = imageID | ||
| } else { | ||
| image.ResourceID = fmt.Sprintf("/resourceGroups/%s/providers/Microsoft.Compute/images/%s", rg, clusterID) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to append
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be fixed in e26a478 |
||
| } | ||
|
|
||
| networkResourceGroup, virtualNetwork, subnet, err := getNetworkInfo(platform, clusterID, role) | ||
|
|
@@ -188,9 +190,6 @@ func provider(platform *azure.Platform, mpool *azure.MachinePool, osImage string | |
|
|
||
| if platform.CloudName == azure.StackCloud { | ||
| spec.AvailabilitySet = fmt.Sprintf("%s-cluster", clusterID) | ||
|
|
||
| // Public Azure has moved to use image galleries, but ASH is still using managed images. | ||
| spec.Image.ResourceID = fmt.Sprintf("/resourceGroups/%s/providers/Microsoft.Compute/images/%s", rg, clusterID) | ||
| } | ||
|
|
||
| return spec, nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,8 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach | |
| if int64(idx) < total%numOfAZs { | ||
| replicas++ | ||
| } | ||
| provider, err := provider(platform, mpool, osImage, userDataSecret, clusterID, role, &idx, capabilities, rhcosVersion) | ||
| useImageGallery := platform.CloudName != azure.StackCloud | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this "toggle" here seems to be hardcoded to say that if the platform is ASH use managed images, if not use image gallery? does this mean hive uses ASH? i don't understand how this toggle helps with backwards compatibility in this case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just learning about this myself... Within the installer, there is no backward compatibility and Azure Stack using the bool is more of a coincidence. Hive vendors the asset package and calls the function to create machinesets: So basically they will set the bool based on whether the version is 4.12+.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah..ok..i see..good to know..thanks |
||
| provider, err := provider(platform, mpool, osImage, userDataSecret, clusterID, role, &idx, capabilities, useImageGallery) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "failed to create provider") | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does using
latesthere work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prashanth684 I remember you had issues when using anything other than an actual version here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it did - looking back at this comment: #6304 (comment), it did not like
latestwhen used as a versionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
namehere https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/2021-10-01/galleries/images/versions?pivots=deployment-language-arm-template. This is the ARM template but iirc the same restrictions applyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't like
latestwhen creating an image gallery (version), but it is ok when specifying the image to be used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense!