Remove ignoring of object not found on deletion

This is all handled properly at the caller sites
pull/6/head
Bowei Du 2018-01-18 17:48:01 -08:00
parent 9710da8be5
commit 8de8a6d8f2
4 changed files with 6 additions and 34 deletions

View File

@ -18,7 +18,6 @@ package gce
import (
"context"
"net/http"
computealpha "google.golang.org/api/compute/v0.alpha"
compute "google.golang.org/api/compute/v1"
@ -66,11 +65,7 @@ func (gce *GCECloud) UpdateAlphaGlobalBackendService(bg *computealpha.BackendSer
// DeleteGlobalBackendService deletes the given BackendService by name.
func (gce *GCECloud) DeleteGlobalBackendService(name string) error {
mc := newBackendServiceMetricContext("delete", "")
err := gce.c.BackendServices().Delete(context.Background(), meta.GlobalKey(name))
if isHTTPErrorCode(err, http.StatusNotFound) {
return nil
}
return mc.Observe(err)
return mc.Observe(gce.c.BackendServices().Delete(context.Background(), meta.GlobalKey(name)))
}
// CreateGlobalBackendService creates the given BackendService.
@ -119,11 +114,7 @@ func (gce *GCECloud) UpdateRegionBackendService(bg *compute.BackendService, regi
// DeleteRegionBackendService deletes the given BackendService by name.
func (gce *GCECloud) DeleteRegionBackendService(name, region string) error {
mc := newBackendServiceMetricContext("delete", region)
err := gce.c.RegionBackendServices().Delete(context.Background(), meta.RegionalKey(name, region))
if isHTTPErrorCode(err, http.StatusNotFound) {
err = nil
}
return mc.Observe(err)
return mc.Observe(gce.c.RegionBackendServices().Delete(context.Background(), meta.RegionalKey(name, region)))
}
// CreateRegionBackendService creates the given BackendService.

View File

@ -18,7 +18,6 @@ package gce
import (
"context"
"net/http"
compute "google.golang.org/api/compute/v1"
@ -50,11 +49,7 @@ func (gce *GCECloud) CreateSslCertificate(sslCerts *compute.SslCertificate) (*co
// DeleteSslCertificate deletes the SslCertificate by name.
func (gce *GCECloud) DeleteSslCertificate(name string) error {
mc := newCertMetricContext("delete")
err := gce.c.SslCertificates().Delete(context.Background(), meta.GlobalKey(name))
if isHTTPErrorCode(err, http.StatusNotFound) {
err = nil
}
return mc.Observe(err)
return mc.Observe(gce.c.SslCertificates().Delete(context.Background(), meta.GlobalKey(name)))
}
// ListSslCertificates lists all SslCertificates in the project.

View File

@ -18,7 +18,6 @@ package gce
import (
"context"
"net/http"
compute "google.golang.org/api/compute/v1"
@ -53,11 +52,7 @@ func (gce *GCECloud) SetUrlMapForTargetHttpProxy(proxy *compute.TargetHttpProxy,
// DeleteTargetHttpProxy deletes the TargetHttpProxy by name.
func (gce *GCECloud) DeleteTargetHttpProxy(name string) error {
mc := newTargetProxyMetricContext("delete")
err := gce.c.TargetHttpProxies().Delete(context.Background(), meta.GlobalKey(name))
if isHTTPErrorCode(err, http.StatusNotFound) {
err = nil
}
return mc.Observe(err)
return mc.Observe(gce.c.TargetHttpProxies().Delete(context.Background(), meta.GlobalKey(name)))
}
// ListTargetHttpProxies lists all TargetHttpProxies in the project.
@ -101,11 +96,7 @@ func (gce *GCECloud) SetSslCertificateForTargetHttpsProxy(proxy *compute.TargetH
// DeleteTargetHttpsProxy deletes the TargetHttpsProxy by name.
func (gce *GCECloud) DeleteTargetHttpsProxy(name string) error {
mc := newTargetProxyMetricContext("delete")
err := gce.c.TargetHttpsProxies().Delete(context.Background(), meta.GlobalKey(name))
if isHTTPErrorCode(err, http.StatusNotFound) {
err = nil
}
return mc.Observe(err)
return mc.Observe(gce.c.TargetHttpsProxies().Delete(context.Background(), meta.GlobalKey(name)))
}
// ListTargetHttpsProxies lists all TargetHttpsProxies in the project.

View File

@ -18,7 +18,6 @@ package gce
import (
"context"
"net/http"
compute "google.golang.org/api/compute/v1"
@ -52,11 +51,7 @@ func (gce *GCECloud) UpdateUrlMap(urlMap *compute.UrlMap) error {
// DeleteUrlMap deletes a url map by name.
func (gce *GCECloud) DeleteUrlMap(name string) error {
mc := newUrlMapMetricContext("delete")
err := gce.c.UrlMaps().Delete(context.Background(), meta.GlobalKey(name))
if isHTTPErrorCode(err, http.StatusNotFound) {
err = nil
}
return mc.Observe(err)
return mc.Observe(gce.c.UrlMaps().Delete(context.Background(), meta.GlobalKey(name)))
}
// ListUrlMaps lists all UrlMaps in the project.