Skip to content

Commit 5f564fe

Browse files
authored
Merge pull request #17517 from hakman/azure-test
azure: Fix periodic tests
2 parents e66fc0a + 96a89b5 commit 5f564fe

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

cmd/kops/create_cluster.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,8 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
537537
}
538538

539539
if featureflag.Azure.Enabled() {
540-
if c.AzureSubscriptionID == "" {
541-
if id, ok := os.LookupEnv("AZURE_SUBSCRIPTION_ID"); ok {
542-
c.AzureSubscriptionID = id
543-
} else {
544-
return fmt.Errorf("--azure-subscription-id is required")
545-
}
540+
if c.CloudProvider == "azure" && c.AzureSubscriptionID == "" {
541+
return fmt.Errorf("--azure-subscription-id is required")
546542
}
547543
}
548544

tests/e2e/kubetest2-kops/deployer/common.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ func defaultClusterName(cloudProvider string) (string, error) {
319319
switch cloudProvider {
320320
case "aws":
321321
suffix = dnsDomain
322+
case "azure":
323+
// Azure uses --dns=none and the domain is not needed
324+
suffix = ""
322325
default:
323326
suffix = "k8s.local"
324327
}
@@ -337,7 +340,12 @@ func defaultClusterName(cloudProvider string) (string, error) {
337340
if len(jobName) > gcpLimit && cloudProvider == "gce" {
338341
jobName = jobName[:gcpLimit]
339342
}
340-
return fmt.Sprintf("%v.%v", jobName, suffix), nil
343+
344+
if suffix != "" {
345+
jobName = jobType + "." + suffix
346+
}
347+
348+
return jobName, nil
341349
}
342350

343351
// stateStore returns the kops state store to use

upup/pkg/fi/cloudup/azure/verifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (a azureVerifier) VerifyToken(ctx context.Context, rawRequest *http.Request
9191
}
9292
nodeName := strings.ToLower(*vm.Properties.OSProfile.ComputerName)
9393

94-
ni, err := a.client.nisClient.GetVirtualMachineScaleSetNetworkInterface(ctx, a.client.resourceGroup, vmssName, vmssIndex, vmssName+"-netconfig", nil)
94+
ni, err := a.client.nisClient.GetVirtualMachineScaleSetNetworkInterface(ctx, a.client.resourceGroup, vmssName, vmssIndex, vmssName, nil)
9595
if err != nil {
9696
return nil, fmt.Errorf("getting info for VMSS network interface %q #%s: %w", vmssName, vmssIndex, err)
9797
}

upup/pkg/fi/cloudup/azuretasks/vmscaleset.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func (s *VMScaleSet) RenderAzure(t *azure.AzureAPITarget, a, e, changes *VMScale
308308
}
309309
if *e.RequirePublicIP {
310310
ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{
311-
Name: to.Ptr(name + "-publicipconfig"),
311+
Name: to.Ptr(name),
312312
Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
313313
PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
314314
},
@@ -328,13 +328,13 @@ func (s *VMScaleSet) RenderAzure(t *azure.AzureAPITarget, a, e, changes *VMScale
328328
}
329329

330330
networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{
331-
Name: to.Ptr(name + "-netconfig"),
331+
Name: to.Ptr(name),
332332
Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{
333333
Primary: to.Ptr(true),
334334
EnableIPForwarding: to.Ptr(true),
335335
IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{
336336
{
337-
Name: to.Ptr(name + "-ipconfig"),
337+
Name: to.Ptr(name),
338338
Properties: ipConfigProperties,
339339
},
340340
},

upup/pkg/fi/cloudup/azuretasks/vmscaleset_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func TestVMScaleSetFind(t *testing.T) {
212212
PrivateIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
213213
}
214214
ipConfigProperties.PublicIPAddressConfiguration = &compute.VirtualMachineScaleSetPublicIPAddressConfiguration{
215-
Name: to.Ptr("vmss-publicipconfig"),
215+
Name: to.Ptr("vmss"),
216216
Properties: &compute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
217217
PublicIPAddressVersion: to.Ptr(compute.IPVersionIPv4),
218218
},
@@ -223,13 +223,13 @@ func TestVMScaleSetFind(t *testing.T) {
223223
},
224224
}
225225
networkConfig := &compute.VirtualMachineScaleSetNetworkConfiguration{
226-
Name: to.Ptr("vmss-netconfig"),
226+
Name: to.Ptr("vmss"),
227227
Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{
228228
Primary: to.Ptr(true),
229229
EnableIPForwarding: to.Ptr(true),
230230
IPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{
231231
{
232-
Name: to.Ptr("vmss-ipconfig"),
232+
Name: to.Ptr("vmss"),
233233
Properties: ipConfigProperties,
234234
},
235235
},

upup/pkg/fi/cloudup/new_cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cloudup
1919
import (
2020
"context"
2121
"fmt"
22+
"os"
2223
"strconv"
2324
"strings"
2425

@@ -179,6 +180,7 @@ func (o *NewClusterOptions) InitDefaults() {
179180

180181
// Azure-specific
181182
o.AzureAdminUser = "kops"
183+
o.AzureSubscriptionID = os.Getenv("AZURE_SUBSCRIPTION_ID")
182184
}
183185

184186
type NewClusterResult struct {

0 commit comments

Comments
 (0)