diff --git a/pkg/core/resources/registry/registry.go b/pkg/core/resources/registry/registry.go index ef895ff4948d..95308ecd216c 100644 --- a/pkg/core/resources/registry/registry.go +++ b/pkg/core/resources/registry/registry.go @@ -26,16 +26,16 @@ func NewTypeRegistry() TypeRegistry { } } -type InvalidResourceType struct { +type InvalidResourceTypeError struct { ResType model.ResourceType } -func (e *InvalidResourceType) Error() string { +func (e *InvalidResourceTypeError) Error() string { return fmt.Sprintf("invalid resource type %q", e.ResType) } -func (e *InvalidResourceType) Is(target error) bool { - t, ok := target.(*InvalidResourceType) +func (e *InvalidResourceTypeError) Is(target error) bool { + t, ok := target.(*InvalidResourceTypeError) if !ok { return false } @@ -49,7 +49,7 @@ type typeRegistry struct { func (t *typeRegistry) DescriptorFor(resType model.ResourceType) (model.ResourceTypeDescriptor, error) { typDesc, ok := t.descriptors[resType] if !ok { - return model.ResourceTypeDescriptor{}, &InvalidResourceType{ResType: resType} + return model.ResourceTypeDescriptor{}, &InvalidResourceTypeError{ResType: resType} } return typDesc, nil } diff --git a/pkg/core/rest/errors/error_handler.go b/pkg/core/rest/errors/error_handler.go index 60adbab414d7..18312ace52e3 100644 --- a/pkg/core/rest/errors/error_handler.go +++ b/pkg/core/rest/errors/error_handler.go @@ -32,7 +32,7 @@ func HandleError(ctx context.Context, response *restful.Response, err error, tit Title: title, Detail: "Not found", } - case errors.Is(err, &rest.InvalidResourceError{}) || errors.Is(err, ®istry.InvalidResourceType{}) || errors.Is(err, &store.PreconditionError{}): + case errors.Is(err, &rest.InvalidResourceError{}) || errors.Is(err, ®istry.InvalidResourceTypeError{}) || errors.Is(err, &store.PreconditionError{}): kumaErr = &types.Error{ Status: 400, Title: "Bad Request", diff --git a/pkg/kds/server/status_sink.go b/pkg/kds/server/status_sink.go index 2932e4dcb75b..866b8b4e15c9 100644 --- a/pkg/kds/server/status_sink.go +++ b/pkg/kds/server/status_sink.go @@ -2,9 +2,11 @@ package server import ( "context" + "errors" "time" "github.com/go-logr/logr" + "google.golang.org/protobuf/proto" system_proto "github.com/kumahq/kuma/api/system/v1alpha1" config_store "github.com/kumahq/kuma/pkg/config/core/resources/store" @@ -15,7 +17,6 @@ import ( "github.com/kumahq/kuma/pkg/core/user" kuma_log "github.com/kumahq/kuma/pkg/log" "github.com/kumahq/kuma/pkg/multitenant" - "google.golang.org/protobuf/proto" ) type ZoneInsightSink interface { @@ -85,7 +86,7 @@ func (s *zoneInsightSink) Start(ctx context.Context, stop <-chan struct{}) { } if err := s.store.Upsert(gracefulCtx, zone, currentState); err != nil { - if store.IsResourceConflict(err) || store.IsResourceAlreadyExists(err) { + if errors.Is(err, &store.ResourceConflictError{}) { log.V(1).Info("failed to flush ZoneInsight because it was updated in other place. Will retry in the next tick", "zone", zone) } else { log.Error(err, "failed to flush zone status", "zone", zone)