Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 404 properly from Service Accounts API #15902

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions pkg/resources/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ func deleteGCEDisk(cloud fi.Cloud, r *resources.Resource) error {
op, err := c.Compute().Disks().Delete(u.Project, u.Zone, u.Name)
if err != nil {
if gce.IsNotFound(err) {
klog.Infof("disk not found, assuming deleted: %q", t.SelfLink)
klog.Infof("Disk not found, assuming deleted: %q", t.SelfLink)
return nil
}
return fmt.Errorf("error deleting disk %s: %v", t.SelfLink, err)
return fmt.Errorf("error deleting Disk %s: %v", t.SelfLink, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages should not start with the word "error"

Suggested change
return fmt.Errorf("error deleting Disk %s: %v", t.SelfLink, err)
return fmt.Errorf("deleting Disk %s: %v", t.SelfLink, err)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry... missed this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do it in a followup PR

}

return c.WaitForOp(op)
Expand Down Expand Up @@ -930,7 +930,7 @@ func deleteSubnet(cloud fi.Cloud, r *resources.Resource) error {
c := cloud.(gce.GCECloud)
o := r.Obj.(*compute.Subnetwork)

klog.V(2).Infof("deleting GCE subnetwork %s", o.SelfLink)
klog.V(2).Infof("deleting GCE Subnetwork %s", o.SelfLink)
u, err := gce.ParseGoogleCloudURL(o.SelfLink)
if err != nil {
return err
Expand All @@ -939,10 +939,10 @@ func deleteSubnet(cloud fi.Cloud, r *resources.Resource) error {
op, err := c.Compute().Subnetworks().Delete(u.Project, u.Region, u.Name)
if err != nil {
if gce.IsNotFound(err) {
klog.Infof("subnetwork not found, assuming deleted: %q", o.SelfLink)
klog.Infof("Subnetwork not found, assuming deleted: %q", o.SelfLink)
return nil
}
return fmt.Errorf("error deleting subnetwork %s: %v", o.SelfLink, err)
return fmt.Errorf("error deleting Subnetwork %s: %v", o.SelfLink, err)
}

return c.WaitForOp(op)
Expand Down Expand Up @@ -993,7 +993,7 @@ func deleteRouter(cloud fi.Cloud, r *resources.Resource) error {
op, err := c.Compute().Routers().Delete(u.Project, u.Region, u.Name)
if err != nil {
if gce.IsNotFound(err) {
klog.Infof("router not found, assuming deleted: %q", o.SelfLink)
klog.Infof("Router not found, assuming deleted: %q", o.SelfLink)
return nil
}
return fmt.Errorf("error deleting router %s: %v", o.SelfLink, err)
Expand Down Expand Up @@ -1044,7 +1044,14 @@ func deleteServiceAccount(cloud fi.Cloud, r *resources.Resource) error {

klog.V(2).Infof("deleting GCE ServiceAccount %s", o.Name)
_, err := c.IAM().ServiceAccounts().Delete(o.Name)
return err
if err != nil {
if gce.IsNotFound(err) {
klog.Infof("ServiceAccount not found, assuming deleted: %q", o.Name)
return nil
}
return fmt.Errorf("error deleting ServiceAccount %s: %v", o.Name, err)
}
return nil
}

// containsOnlyListedIGMs returns true if all the given backend service's backends
Expand Down
Loading