@@ -699,13 +699,13 @@ func resolveKubetestRepoListPath(version string, path string) (string, error) {
699
699
// resolveKubernetesVersions looks at Kubernetes versions set as variables in the e2e config and sets them to a valid k8s version
700
700
// that has an existing capi offer image available. For example, if the version is "stable-1.22", the function will set it to the latest 1.22 version that has a published reference image.
701
701
func resolveKubernetesVersions (config * clusterctl.E2EConfig ) {
702
- ubuntuVersions := getVersionsInOffer (context .TODO (), os .Getenv (AzureLocation ), capiImagePublisher , capiOfferName )
703
- windowsVersions := getVersionsInOffer (context .TODO (), os .Getenv (AzureLocation ), capiImagePublisher , capiWindowsOfferName )
702
+ linuxVersions := getVersionsInCommunityGallery (context .TODO (), os .Getenv (AzureLocation ), capiCommunityGallery , "capi-ubun2-2404" )
703
+ windowsVersions := getVersionsInCommunityGallery (context .TODO (), os .Getenv (AzureLocation ), capiCommunityGallery , "capi-win-2022-containerd" )
704
704
flatcarK8sVersions := getFlatcarK8sVersions (context .TODO (), os .Getenv (AzureLocation ), flatcarCAPICommunityGallery )
705
705
706
706
// find the intersection of ubuntu and windows versions available, since we need an image for both.
707
707
var versions semver.Versions
708
- for k , v := range ubuntuVersions {
708
+ for k , v := range linuxVersions {
709
709
if _ , ok := windowsVersions [k ]; ok {
710
710
versions = append (versions , v )
711
711
}
@@ -758,16 +758,6 @@ func resolveFlatcarVersion(config *clusterctl.E2EConfig, versions semver.Version
758
758
resolveVariable (config , varName , version )
759
759
}
760
760
761
- // newImagesClient returns a new VM images client using environmental settings for auth.
762
- func newImagesClient () * armcompute.VirtualMachineImagesClient {
763
- cred , err := azidentity .NewDefaultAzureCredential (nil )
764
- Expect (err ).NotTo (HaveOccurred ())
765
- imagesClient , err := armcompute .NewVirtualMachineImagesClient (getSubscriptionID (Default ), cred , nil )
766
- Expect (err ).NotTo (HaveOccurred ())
767
-
768
- return imagesClient
769
- }
770
-
771
761
func newCommunityGalleryImagesClient () * armcompute.CommunityGalleryImagesClient {
772
762
cred , err := azidentity .NewDefaultAzureCredential (nil )
773
763
Expect (err ).NotTo (HaveOccurred ())
@@ -786,40 +776,16 @@ func newCommunityGalleryImageVersionsClient() *armcompute.CommunityGalleryImageV
786
776
return communityGalleryImageVersionsClient
787
777
}
788
778
789
- // getVersionsInOffer returns a map of Kubernetes versions as strings to semver.Versions.
790
- func getVersionsInOffer (ctx context.Context , location , publisher , offer string ) map [string ]semver.Version {
791
- Logf ("Finding image skus and versions for offer %s/%s in %s" , publisher , offer , location )
792
- var versions map [string ]semver.Version
793
- capiSku := regexp .MustCompile (`^[\w-]+-gen[12]$` )
794
- capiVersion := regexp .MustCompile (`^(\d)(\d{1,2})\.(\d{1,2})\.\d{8}$` )
795
- oldCapiSku := regexp .MustCompile (`^k8s-(0|[1-9][0-9]*)dot(0|[1-9][0-9]*)dot(0|[1-9][0-9]*)-[a-z]*.*$` )
796
- imagesClient := newImagesClient ()
797
- resp , err := imagesClient .ListSKUs (ctx , location , publisher , offer , nil )
798
- Expect (err ).NotTo (HaveOccurred ())
799
-
800
- skus := resp .VirtualMachineImageResourceArray
779
+ func getVersionsInCommunityGallery (ctx context.Context , location , galleryName , image string ) map [string ]semver.Version {
780
+ versions := make (map [string ]semver.Version )
801
781
802
- versions = make (map [string ]semver.Version , len (skus ))
803
- for _ , sku := range skus {
804
- res , err := imagesClient .List (ctx , location , publisher , offer , * sku .Name , nil )
782
+ client := newCommunityGalleryImageVersionsClient ()
783
+ pager := client .NewListPager (location , galleryName , image , nil )
784
+ for pager .More () {
785
+ resp , err := pager .NextPage (ctx )
805
786
Expect (err ).NotTo (HaveOccurred ())
806
- // Don't use SKUs without existing images. See https://github.com/Azure/azure-cli/issues/20115.
807
- if len (res .VirtualMachineImageResourceArray ) > 0 {
808
- // New SKUs don't contain the Kubernetes version and are named like "ubuntu-2004-gen1".
809
- if match := capiSku .FindStringSubmatch (* sku .Name ); len (match ) > 0 {
810
- for _ , vmImage := range res .VirtualMachineImageResourceArray {
811
- // Versions are named like "121.13.20220601", for Kubernetes v1.21.13 published on June 1, 2022.
812
- match = capiVersion .FindStringSubmatch (* vmImage .Name )
813
- stringVer := fmt .Sprintf ("%s.%s.%s" , match [1 ], match [2 ], match [3 ])
814
- versions [stringVer ] = semver .MustParse (stringVer )
815
- }
816
- continue
817
- }
818
- // Old SKUs before 1.21.12, 1.22.9, or 1.23.6 are named like "k8s-1dot21dot2-ubuntu-2004".
819
- if match := oldCapiSku .FindStringSubmatch (* sku .Name ); len (match ) > 0 {
820
- stringVer := fmt .Sprintf ("%s.%s.%s" , match [1 ], match [2 ], match [3 ])
821
- versions [stringVer ] = semver .MustParse (stringVer )
822
- }
787
+ for _ , version := range resp .Value {
788
+ versions [* version .Name ] = semver .MustParse (* version .Name )
823
789
}
824
790
}
825
791
0 commit comments