Skip to content

Commit 57c5357

Browse files
committed
Refactor LogAndFormatError to LoggedErrorf
Signed-off-by: perdasilva <[email protected]>
1 parent 483aaec commit 57c5357

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

Diff for: test/e2e/util/e2e_catalog_helper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ type CatalogSourceHelper struct {
1616
func (c *CatalogSourceHelper) EventuallyHasGrpcConnectionWithLastConnectionState(expectedState connectivity.State) {
1717
c.waitForCatalogToBeLike(func(catalogSource *v1alpha1.CatalogSource) error {
1818
if catalogSource.Status.GRPCConnectionState == nil {
19-
return LogAndFormatError("expected catalog source grpc connection state to be '%s' but there is no connection state", expectedState)
19+
return LoggedErrorf("expected catalog source grpc connection state to be '%s' but there is no connection state", expectedState)
2020
}
2121
if catalogSource.Status.GRPCConnectionState.LastObservedState != expectedState.String() {
22-
return LogAndFormatError("expected catalog source gprc connection state '%s' to be '%s'", catalogSource.Status.GRPCConnectionState.LastObservedState, expectedState)
22+
return LoggedErrorf("expected catalog source gprc connection state '%s' to be '%s'", catalogSource.Status.GRPCConnectionState.LastObservedState, expectedState)
2323
}
2424
return nil
2525
})

Diff for: test/e2e/util/e2e_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (m *E2EKubeClient) Reset() error {
6666

6767
Logf("deleting %s/%s", namespace, obj.GetName())
6868
if err := k8scontrollerclient.IgnoreNotFound(m.Delete(context.Background(), obj)); err != nil {
69-
Logf("error deleting object %s/%s: %s", namespace, obj.GetName(), obj)
69+
Logf("error deleting object %s/%s: %s", namespace, obj.GetName(), err)
7070
return err
7171
}
7272
}

Diff for: test/e2e/util/e2e_determined_client.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package util
33
import (
44
"context"
55

6+
"k8s.io/client-go/util/retry"
67
k8scontrollerclient "sigs.k8s.io/controller-runtime/pkg/client"
78

89
. "github.com/onsi/gomega"
@@ -30,7 +31,9 @@ func (m *DeterminedE2EClient) Create(context context.Context, obj k8scontrollerc
3031

3132
func (m *DeterminedE2EClient) Update(context context.Context, obj k8scontrollerclient.Object, options ...k8scontrollerclient.UpdateOption) error {
3233
m.keepTrying(func() error {
33-
return m.E2EKubeClient.Update(context, obj, options...)
34+
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
35+
return m.E2EKubeClient.Update(context, obj, options...)
36+
})
3437
})
3538
return nil
3639
}

Diff for: test/e2e/util/e2e_subscription_helper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type SubscriptionHelper struct {
1515
func (s *SubscriptionHelper) EventuallyHasState(expectedState v1alpha1.SubscriptionState) {
1616
s.waitForSubscriptionToBeLike(func(subscription *v1alpha1.Subscription) error {
1717
if subscription.Status.State != expectedState {
18-
return LogAndFormatError("expected subscription state '%s' to be '%s'", subscription.Status.State, expectedState)
18+
return LoggedErrorf("expected subscription state '%s' to be '%s'", subscription.Status.State, expectedState)
1919
}
2020
return nil
2121
})
@@ -28,7 +28,7 @@ func (s *SubscriptionHelper) EventuallyContainsCondition(expectedCondition v1alp
2828
return nil
2929
}
3030
}
31-
return LogAndFormatError("expected subscription condition %s to be in %s", expectedCondition, ObjectToJsonString(subscription.Status.Conditions))
31+
return LoggedErrorf("expected subscription condition %s to be in %s", expectedCondition, ObjectToJsonString(subscription.Status.Conditions))
3232
})
3333
}
3434

@@ -41,7 +41,7 @@ func (s *SubscriptionHelper) EventuallyContainsConditionWithConditionType(expect
4141
}
4242
foundConditionTypes = append(foundConditionTypes, condition.Type)
4343
}
44-
return LogAndFormatError("expected subscription condition type '%s' to be in %s", expectedConditionType, foundConditionTypes)
44+
return LoggedErrorf("expected subscription condition type '%s' to be in %s", expectedConditionType, foundConditionTypes)
4545
})
4646
}
4747

Diff for: test/e2e/util/test_logging.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Logf(f string, v ...interface{}) {
1515
_, _ = fmt.Fprintf(g.GinkgoWriter, f, v...)
1616
}
1717

18-
func LogAndFormatError(format string, args ...interface{}) error {
18+
func LoggedErrorf(format string, args ...interface{}) error {
1919
Logf(format, args...)
2020
return fmt.Errorf(format, args...)
2121
}

0 commit comments

Comments
 (0)