mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
Use formal error checking to validate a not found err.
This commit is contained in:
parent
90800bdc43
commit
e6d823da71
@ -20,9 +20,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
|
||||||
@ -78,7 +78,7 @@ func (e *EndpointController) SyncServiceEndpoints() error {
|
|||||||
currentEndpoints, err := e.client.GetEndpoints(nsCtx, service.ID)
|
currentEndpoints, err := e.client.GetEndpoints(nsCtx, service.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO this is brittle as all get out, refactor the client libraries to return a structured error.
|
// TODO this is brittle as all get out, refactor the client libraries to return a structured error.
|
||||||
if strings.Contains(err.Error(), "not found") {
|
if errors.IsNotFound(err) {
|
||||||
currentEndpoints = &api.Endpoints{
|
currentEndpoints = &api.Endpoints{
|
||||||
JSONBase: api.JSONBase{
|
JSONBase: api.JSONBase{
|
||||||
ID: service.ID,
|
ID: service.ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user