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

check if instance manager not found on delete, don't return an error #7903

Merged
merged 1 commit into from
May 9, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package google
import (
"fmt"
"log"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -993,6 +994,14 @@ func resourceComputeInstanceGroupManagerDelete(d *schema.ResourceData, meta inte
if d.Get("wait_for_instances").(bool) {
err := computeIGMWaitForInstanceStatus(d, meta)
if err != nil {
notFound, reErr := regexp.MatchString(`not found`, err.Error())
if reErr != nil {
return reErr
}
if notFound {
// manager was not found, we can exit gracefully
return nil
}
return err
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package google
import (
"fmt"
"log"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -649,6 +650,12 @@ func waitForInstancesRefreshFunc(f getInstanceManagerFunc, waitForUpdates bool,
log.Printf("[WARNING] Error in fetching manager while waiting for instances to come up: %s\n", err)
return nil, "error", err
}
if m == nil {
// getManager/getRegional manager call handleNotFoundError, which will return a nil error and nil object in the case
// that the original error was a 404. if m == nil here, we will assume that it was not found return an "instance manager not found"
// error so that we can parse it later on and handle it there
return nil, "error", fmt.Errorf("instance manager not found")
}
if m.Status.IsStable {
if waitForUpdates {
// waitForUpdates waits for versions to be reached and per instance configs to be updated (if present)
Expand Down Expand Up @@ -932,6 +939,14 @@ func resourceComputeRegionInstanceGroupManagerDelete(d *schema.ResourceData, met
if d.Get("wait_for_instances").(bool) {
err := computeRIGMWaitForInstanceStatus(d, meta)
if err != nil {
notFound, reErr := regexp.MatchString(`not found`, err.Error())
if reErr != nil {
return reErr
}
if notFound {
// manager was not found, we can exit gracefully
return nil
}
return err
}
}
Expand Down