@@ -41,6 +41,7 @@ import (
4141
4242var (
4343 azureResourceGroupNameRE = regexp .MustCompile (`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/(?:.*)` )
44+ windowsServerYearRE = regexp .MustCompile (`\b20\d{2}\b` )
4445 nodeLabelLocation = "failure-domain.beta.kubernetes.io/region"
4546 defaultLocation = "eastus2"
4647)
@@ -54,6 +55,7 @@ type AzureTestClient struct {
5455 azFactoryConfig * azclient.ClientFactoryConfig
5556 IPFamily IPFamily
5657 HasWindowsNodes bool
58+ WindowsOSVersion string
5759}
5860
5961// CreateAzureTestClient makes a new AzureTestClient
@@ -91,9 +93,11 @@ func CreateAzureTestClient() (*AzureTestClient, error) {
9193 }
9294
9395 hasWindowsNodes := false
96+ windowsOSVersion := ""
9497 for _ , node := range nodes {
9598 if os , ok := node .Labels ["kubernetes.io/os" ]; ok && os == "windows" {
9699 hasWindowsNodes = true
100+ windowsOSVersion = nanoserverTagFromOSImage (node .Status .NodeInfo .OSImage )
97101 break
98102 }
99103 }
@@ -113,8 +117,9 @@ func CreateAzureTestClient() (*AzureTestClient, error) {
113117 location : location ,
114118 resourceGroup : resourceGroup ,
115119 IPFamily : ipFamily ,
116- HasWindowsNodes : hasWindowsNodes ,
117- authConfig : authConfig ,
120+ HasWindowsNodes : hasWindowsNodes ,
121+ WindowsOSVersion : windowsOSVersion ,
122+ authConfig : authConfig ,
118123 azFactoryConfig : clientFactoryConfig ,
119124 client : azFactory ,
120125 }
@@ -228,3 +233,12 @@ func getLocationFromNodeLabels(node *v1.Node) string {
228233 }
229234 return defaultLocation
230235}
236+
237+ // nanoserverTagFromOSImage extracts the Windows Server year from the node's OSImage
238+ // (e.g. "Windows Server 2022 Datacenter") and returns the nanoserver tag (e.g. "ltsc2022").
239+ func nanoserverTagFromOSImage (osImage string ) string {
240+ if year := windowsServerYearRE .FindString (osImage ); year != "" {
241+ return "ltsc" + year
242+ }
243+ return "ltsc2022"
244+ }
0 commit comments