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

Bug 1795436: update error message when deleting default GCP routes #3049

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/destroy/gcp/network.go
Expand Up @@ -84,7 +84,7 @@ func (o *ClusterUninstaller) destroyNetworks() error {
for _, route := range routes {
err := o.deleteRoute(route)
if err != nil {
o.Logger.Debugf("Failed to delete route %s: %v", route, err)
o.Logger.Debugf("Failed to delete route %s: %v", route.name, err)
}
}
err = o.deleteNetwork(item)
Expand Down
4 changes: 4 additions & 0 deletions pkg/destroy/gcp/route.go
Expand Up @@ -2,6 +2,7 @@ package gcp

import (
"fmt"
"strings"

"github.com/pkg/errors"

Expand Down Expand Up @@ -56,6 +57,9 @@ func (o *ClusterUninstaller) deleteRoute(item cloudResource) error {
op, err := o.computeSvc.Routes.Delete(o.ProjectID, item.name).RequestId(o.requestID(item.typeName, item.name)).Context(ctx).Do()
if err != nil && !isNoOp(err) {
o.resetRequestID(item.typeName, item.name)
if strings.HasPrefix(item.name, "default-route") {
return errors.New("this looks like a default route, which cannot be deleted manually but will be deleted with the corresponding network")
Copy link
Contributor

Choose a reason for hiding this comment

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

what about error here

if op != nil && op.Status == "DONE" && isErrorStatus(op.HttpErrorStatusCode) {
o.resetRequestID(item.typeName, item.name)
return errors.Errorf("failed to delete route %s with error: %s", item.name, operationErrorMessage(op))
}
??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hitting this error would be unexpected, so I don't see a need for special handling as in the first case where we expect to hit the error. Let me know if you disagree.

}
return errors.Wrapf(err, "failed to delete route %s", item.name)
}
if op != nil && op.Status == "DONE" && isErrorStatus(op.HttpErrorStatusCode) {
Expand Down