Skip to content

Commit

Permalink
removed error mocking
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Rammer <[email protected]>
  • Loading branch information
hamersaw committed Jan 17, 2024
1 parent c359d67 commit 7085329
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions flytestdlib/otelutils/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package otelutils
import (
"context"
"fmt"
"time"

k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand All @@ -24,15 +21,7 @@ func WrapK8sCache(c cache.Cache) cache.Cache {
func (c *K8sCacheWrapper) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
ctx, span := NewSpan(ctx, K8sClientTracer, fmt.Sprintf("%s.Cache/Get", k8sSpanPathPrefix))
defer span.End()

err := c.Cache.Get(ctx, key, obj, opts...)
if time.Since(obj.GetCreationTimestamp().Time) < (time.Second * 3) {
obj = nil
return k8serrors.NewNotFound(schema.GroupResource{Group: "foo", Resource: "bar"}, key.Name)
}

return err
//return c.Cache.Get(ctx, key, obj, opts...)
return c.Cache.Get(ctx, key, obj, opts...)
}

func (c *K8sCacheWrapper) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error {
Expand All @@ -54,14 +43,7 @@ func WrapK8sClient(c client.Client) client.Client {
func (c *K8sClientWrapper) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
ctx, span := NewSpan(ctx, K8sClientTracer, fmt.Sprintf("%s.Client/Get", k8sSpanPathPrefix))
defer span.End()
err := c.Client.Get(ctx, key, obj, opts...)
if time.Since(obj.GetCreationTimestamp().Time) < (time.Second * 3) {
obj = nil
return k8serrors.NewNotFound(schema.GroupResource{Group: "foo", Resource: "bar"}, key.Name)
}

return err
//return c.Client.Get(ctx, key, obj, opts...)
return c.Client.Get(ctx, key, obj, opts...)
}

func (c *K8sClientWrapper) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error {
Expand Down

0 comments on commit 7085329

Please sign in to comment.