Skip to content

Commit 0187158

Browse files
authored
Merge pull request #18194 from hakman/fix-not-found-disk
azure: Handle missing resource group in disk listing
2 parents e820301 + a0b03e6 commit 0187158

File tree

12 files changed

+52
-2
lines changed

12 files changed

+52
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
238238
}
239239
case "azure":
240240
// Use SKUs for which there is enough quota
241-
args = appendIfUnset(args, "--control-plane-size", "Standard_D4als_v7")
242-
args = appendIfUnset(args, "--node-size", "Standard_D4als_v7")
241+
args = appendIfUnset(args, "--control-plane-size", "Standard_D4ls_v6")
242+
args = appendIfUnset(args, "--node-size", "Standard_D4ls_v6")
243243
case "gce":
244244
if isArm {
245245
args = appendIfUnset(args, "--control-plane-size", "t2a-standard-2")

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package azure
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223

24+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
2325
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
2426
compute "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
2527
)
@@ -50,11 +52,19 @@ func (c *disksClientImpl) CreateOrUpdate(ctx context.Context, resourceGroupName,
5052
}
5153

5254
func (c *disksClientImpl) List(ctx context.Context, resourceGroupName string) ([]*compute.Disk, error) {
55+
if resourceGroupName == "" {
56+
return nil, nil
57+
}
58+
5359
var l []*compute.Disk
5460
pager := c.c.NewListByResourceGroupPager(resourceGroupName, nil)
5561
for pager.More() {
5662
resp, err := pager.NextPage(ctx)
5763
if err != nil {
64+
var respErr *azcore.ResponseError
65+
if errors.As(err, &respErr) && respErr.ErrorCode == "ResourceGroupNotFound" {
66+
return nil, nil
67+
}
5868
return nil, fmt.Errorf("listing disks: %w", err)
5969
}
6070
l = append(l, resp.Value...)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (asg *ApplicationSecurityGroup) Find(c *fi.CloudupContext) (*ApplicationSec
6565
if found == nil {
6666
return nil, nil
6767
}
68+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
69+
klog.Warningf("found application security group %q in failed provisioning state", *asg.Name)
70+
return nil, nil
71+
}
6872

6973
asg.ID = found.ID
7074

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (d *Disk) Find(c *fi.CloudupContext) (*Disk, error) {
6767
if found == nil {
6868
return nil, nil
6969
}
70+
if found.Properties != nil && fi.ValueOf(found.Properties.ProvisioningState) == "Failed" {
71+
klog.Warningf("found disk %q in failed provisioning state", *d.Name)
72+
return nil, nil
73+
}
7074

7175
disk := &Disk{
7276
Name: d.Name,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func (lb *LoadBalancer) Find(c *fi.CloudupContext) (*LoadBalancer, error) {
155155
if found == nil {
156156
return nil, nil
157157
}
158+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
159+
klog.Warningf("found load balancer %q in failed provisioning state", *lb.Name)
160+
return nil, nil
161+
}
158162

159163
lbProperties := found.Properties
160164

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (ngw *NatGateway) Find(c *fi.CloudupContext) (*NatGateway, error) {
6767
if found == nil {
6868
return nil, nil
6969
}
70+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
71+
klog.Warningf("found NAT gateway %q in failed provisioning state", *ngw.Name)
72+
return nil, nil
73+
}
7074

7175
ngw.ID = found.ID
7276

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ func (nsg *NetworkSecurityGroup) Find(c *fi.CloudupContext) (*NetworkSecurityGro
7373
if found == nil {
7474
return nil, nil
7575
}
76+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
77+
klog.Warningf("found network security group %q in failed provisioning state", *nsg.Name)
78+
return nil, nil
79+
}
7680

7781
actual := &NetworkSecurityGroup{
7882
Name: nsg.Name,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (p *PublicIPAddress) Find(c *fi.CloudupContext) (*PublicIPAddress, error) {
6666
if found == nil {
6767
return nil, nil
6868
}
69+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
70+
klog.Warningf("found public IP address %q in failed provisioning state", *p.Name)
71+
return nil, nil
72+
}
6973

7074
p.ID = found.ID
7175

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (r *RouteTable) Find(c *fi.CloudupContext) (*RouteTable, error) {
6565
if found == nil {
6666
return nil, nil
6767
}
68+
if found.Properties != nil && found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
69+
klog.Warningf("found route table %q in failed provisioning state", *r.Name)
70+
return nil, nil
71+
}
6872

6973
r.ID = found.ID
7074

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func (s *Subnet) Find(c *fi.CloudupContext) (*Subnet, error) {
8989
if found.Properties == nil {
9090
return nil, fmt.Errorf("found subnet without properties")
9191
}
92+
if found.Properties.ProvisioningState != nil && *found.Properties.ProvisioningState == network.ProvisioningStateFailed {
93+
klog.Warningf("found subnet %q in failed provisioning state", *s.Name)
94+
return nil, nil
95+
}
9296

9397
s.ID = found.ID
9498

0 commit comments

Comments
 (0)