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

Cherrypick #1058[Handle health check not found error gracefully] into release-1.9 #1060

Merged
merged 1 commit into from
Mar 26, 2020
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
21 changes: 13 additions & 8 deletions pkg/healthchecks/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,26 @@ func (h *HealthChecks) Delete(name string, scope meta.KeyType) error {
if err != nil {
return err
}
klog.V(2).Infof("Deleting regional health check %v", name)
// L7-ILB is the only use of regional right now
err = composite.DeleteHealthCheck(cloud, key, features.L7ILBVersions().HealthCheck)
// Ignore error if the deletion candidate is being used by another resource.
// In most of the cases, this is the associated backend resource itself.
if utils.IsHTTPErrorCode(err, http.StatusNotFound) || utils.IsInUsedByError(err) {
klog.V(4).Infof("DeleteRegionalHealthCheck(%s, _): %v, ignorable error", name, err)
return nil
if err = composite.DeleteHealthCheck(cloud, key, features.L7ILBVersions().HealthCheck); err != nil {
// Ignore error if the deletion candidate is being used by another resource.
// In most of the cases, this is the associated backend resource itself.
if utils.IsHTTPErrorCode(err, http.StatusNotFound) || utils.IsInUsedByError(err) {
klog.V(4).Infof("DeleteRegionalHealthCheck(%s, _): %v, ignorable error", name, err)
return nil
}
return err
}
return nil
}

klog.V(2).Infof("Deleting health check %v", name)
// Not using composite here since the tests still rely on the fake health check interface
if err := h.cloud.DeleteHealthCheck(name); err != nil {
// Ignore error if the deletion candidate is being used by another resource.
if utils.IsInUsedByError(err) {
// Ignore error if the deletion candidate does not exist or is being used
// by another resource.
if utils.IsHTTPErrorCode(err, http.StatusNotFound) || utils.IsInUsedByError(err) {
klog.V(4).Infof("DeleteHealthCheck(%s, _): %v, ignorable error", name, err)
return nil
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/healthchecks/healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ func TestHealthCheckDelete(t *testing.T) {
if !utils.IsHTTPErrorCode(err, http.StatusNotFound) {
t.Errorf("expected not-found error, actual: %v", err)
}

// Delete only HTTP 1234
err = healthChecks.Delete(testNamer.IGBackend(1234), meta.Global)
if err == nil {
t.Errorf("expected not-found error when deleting health check, err: %v", err)
}
}

func TestHTTP2HealthCheckDelete(t *testing.T) {
Expand Down