Skip to content

Commit

Permalink
Fix cache syncing causing transient failures (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored Jan 31, 2023
1 parent 96f1b61 commit 53e783d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ test: ## Run tests
--ginkgo.focus="${FOCUS}" \
-cover -coverprofile=coverage.out -outputdir=. -coverpkg=./...

deflake: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
--race \
--focus="${FOCUS}" \
--randomize-all \
--until-it-fails \
-v \
./pkg/...

verify: ## Verify code. Includes codegen, dependencies, linting, formatting, etc
go mod tidy
go generate ./...
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/machine/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var cloudProvider *fake.CloudProvider
func TestAPIs(t *testing.T) {
ctx = TestContextWithLogger(t)
RegisterFailHandler(Fail)
RunSpecs(t, "Node")
RunSpecs(t, "Machine")
}

var _ = BeforeSuite(func() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/test/cachesyncingclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ func (c *cacheSyncingStatusWriter) Patch(ctx context.Context, obj client.Object,
}

func objectSynced(ctx context.Context, c client.Client, obj client.Object) error {
stored := obj.DeepCopyObject().(client.Object)
if err := c.Get(ctx, client.ObjectKeyFromObject(obj), obj); err != nil {
temp := obj.DeepCopyObject().(client.Object)
if err := c.Get(ctx, client.ObjectKeyFromObject(obj), temp); err != nil {
return fmt.Errorf("getting object, %w", err)
}
if obj.GetResourceVersion() != stored.GetResourceVersion() {
if obj.GetResourceVersion() != temp.GetResourceVersion() {
return fmt.Errorf("object hasn't updated")
}
return nil
Expand Down

0 comments on commit 53e783d

Please sign in to comment.