Merge pull request #17517 from hakman/azure-test

azure: Fix periodic tests
This commit is contained in:
Kubernetes Prow Robot 2025-07-26 13:30:27 -07:00 committed by GitHub
commit 5f564fe1ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 14 deletions

View File

@ -537,12 +537,8 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
} }
if featureflag.Azure.Enabled() { if featureflag.Azure.Enabled() {
if c.AzureSubscriptionID == "" { if c.CloudProvider == "azure" && c.AzureSubscriptionID == "" {
if id, ok := os.LookupEnv("AZURE_SUBSCRIPTION_ID"); ok { return fmt.Errorf("--azure-subscription-id is required")
c.AzureSubscriptionID = id
} else {
return fmt.Errorf("--azure-subscription-id is required")
}
} }
} }

View File

@ -319,6 +319,9 @@ func defaultClusterName(cloudProvider string) (string, error) {
switch cloudProvider { switch cloudProvider {
case "aws": case "aws":
suffix = dnsDomain suffix = dnsDomain
case "azure":
// Azure uses --dns=none and the domain is not needed
suffix = ""
default: default:
suffix = "k8s.local" suffix = "k8s.local"
} }
@ -337,7 +340,12 @@ func defaultClusterName(cloudProvider string) (string, error) {
if len(jobName) > gcpLimit && cloudProvider == "gce" { if len(jobName) > gcpLimit && cloudProvider == "gce" {
jobName = jobName[:gcpLimit] jobName = jobName[:gcpLimit]
} }
return fmt.Sprintf("%v.%v", jobName, suffix), nil
if suffix != "" {
jobName = jobType + "." + suffix
}
return jobName, nil
} }
// stateStore returns the kops state store to use // stateStore returns the kops state store to use

View File

@ -91,7 +91,7 @@ func (a azureVerifier) VerifyToken(ctx context.Context, rawRequest *http.Request
} }
nodeName := strings.ToLower(*vm.Properties.OSProfile.ComputerName) nodeName := strings.ToLower(*vm.Properties.OSProfile.ComputerName)
ni, err := a.client.nisClient.GetVirtualMachineScaleSetNetworkInterface(ctx, a.client.resourceGroup, vmssName, vmssIndex, vmssName+"-netconfig", nil) ni, err := a.client.nisClient.GetVirtualMachineScaleSetNetworkInterface(ctx, a.client.resourceGroup, vmssName, vmssIndex, vmssName, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("getting info for VMSS network interface %q #%s: %w", vmssName, vmssIndex, err) return nil, fmt.Errorf("getting info for VMSS network interface %q #%s: %w", vmssName, vmssIndex, err)
} }

View File

@ -308,7 +308,7 @@ func (s *VMScaleSet) RenderAzure(t *azure.AzureAPITarget, a, e, changes *VMScale
} }
if *e.RequirePublicIP { if *e.RequirePublicIP {
ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{ ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr(name + "-publicipconfig"), Name: to.Ptr(name),
Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{ Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4), PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
}, },
@ -328,13 +328,13 @@ func (s *VMScaleSet) RenderAzure(t *azure.AzureAPITarget, a, e, changes *VMScale
} }
networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{ networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{
Name: to.Ptr(name + "-netconfig"), Name: to.Ptr(name),
Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{ Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{
Primary: to.Ptr(true), Primary: to.Ptr(true),
EnableIPForwarding: to.Ptr(true), EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{ IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{
{ {
Name: to.Ptr(name + "-ipconfig"), Name: to.Ptr(name),
Properties: ipConfigProperties, Properties: ipConfigProperties,
}, },
}, },

View File

@ -212,7 +212,7 @@ func TestVMScaleSetFind(t *testing.T) {
PrivateIPAddressVersion: to.Ptr(compute.IPVersionIPv4), PrivateIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
} }
ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{ ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: to.Ptr("vmss-publicipconfig"), Name: to.Ptr("vmss"),
Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{ Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4), PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
}, },
@ -223,13 +223,13 @@ func TestVMScaleSetFind(t *testing.T) {
}, },
} }
networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{ networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{
Name: to.Ptr("vmss-netconfig"), Name: to.Ptr("vmss"),
Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{ Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{
Primary: to.Ptr(true), Primary: to.Ptr(true),
EnableIPForwarding: to.Ptr(true), EnableIPForwarding: to.Ptr(true),
IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{ IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{
{ {
Name: to.Ptr("vmss-ipconfig"), Name: to.Ptr("vmss"),
Properties: ipConfigProperties, Properties: ipConfigProperties,
}, },
}, },

View File

@ -19,6 +19,7 @@ package cloudup
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"strconv" "strconv"
"strings" "strings"
@ -179,6 +180,7 @@ func (o *NewClusterOptions) InitDefaults() {
// Azure-specific // Azure-specific
o.AzureAdminUser = "kops" o.AzureAdminUser = "kops"
o.AzureSubscriptionID = os.Getenv("AZURE_SUBSCRIPTION_ID")
} }
type NewClusterResult struct { type NewClusterResult struct {