Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend: UpdateBackfill and DeleteBackfill handlers #1292

Merged
merged 17 commits into from
Dec 3, 2020

Conversation

aLekSer
Copy link
Collaborator

@aLekSer aLekSer commented Nov 25, 2020

What this PR does / Why we need it:

UD methods for Backfill structure.

Which issue(s) this PR fixes:
Work on #1240

Special notes for your reviewer:
This PR contains another PR with CRud part of Frontend: #1279

So review please only changes from this commit and later commits:
9f970a7

@google-cla google-cla bot added the cla: yes label Nov 25, 2020
if req.Backfill == nil {
return nil, status.Errorf(codes.InvalidArgument, ".backfill is required")
}
if req.Backfill.CreateTime != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check required? If we look at doCreateBackfill it always assigns new value to CreateTime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a leftover of CreateTicket and is part of #1279 This PR would be rebased on top of master after #1279 would be merged.

if _, err = m.Unlock(ctx); err != nil {

logger.WithFields(logrus.Fields{
"error": err.Error(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to use WithError and specify fields such as backfill_id?

@aLekSer
Copy link
Collaborator Author

aLekSer commented Nov 26, 2020

Unrelated to the change CI failure:


time="2020-11-26T00:14:25Z" level=error msg="context canceled" app=openmatch component=api.test
--- FAIL: TestMatchFunctionMatchCollision (0.43s)
    fetch_matches_test.go:158: 
        	Error Trace:	fetch_matches_test.go:158
        	Error:      	Should be true
        	Test:       	TestMatchFunctionMatchCollision
        	Messages:   	381.29587ms

Generate ID, store into Redis, add telemetry.
Add lock/unlock to Frontend Create method.
Create and GetBackfill E2E test.
Add CreateBackfill validation check. Extend E2E test.
We need to create a new statestore, so cancel() would always succeed.
New frontend methods with locks and tests.
Fixing error handling adding UT similar to CreateBackfill.
return nil, err
}

err = s.store.DeleteTicketsFromPendingRelease(ctx, associatedTickets)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be done after the ticket is updated:
If the server performs this action, then dies, the tickets will think they can return to the active pool and find other matches, but the backfill will still think it can put tickets in this backfill, potentially assigning them twice.

The other way around, the backfill will release it's claim in the tickets, and if this server dies, then the tickets will just time out and then re-enter the pool.

return nil, status.Errorf(codes.InvalidArgument, ".backfill is required")
}

backfill, ok := proto.Clone(req.Backfill).(*pb.Backfill)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update here should be done defensively, currently you perform the get, but use the backfill passed in as the source of truth. Instead start with the backfill from the get, and then update each field which should be updated. Eg, create time would be overwritten if the wrong value were sent here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code with:

	// Update generation here, because Frontend is used by GameServer only
	bfStored.Generation++
	bfStored.SearchFields = backfill.SearchFields
	bfStored.Extensions = backfill.Extensions

require.Nil(t, err)

createdBf.SearchFields.StringArgs["key"] = "val"
updatedBf, err := om.Frontend().UpdateBackfill(ctx, &pb.UpdateBackfillRequest{Backfill: createdBf})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To better test this method, send an entirely new Backfill protobuf object, with the new value but setting the ID to the one from createdBf.

As it is, this test incorrectly thinks it verifies CreateTime can't be updated.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it would be a better way to show that generation doesn't need to be right.

},
},
}
createdBf, err := om.Frontend().CreateBackfill(ctx, &pb.CreateBackfillRequest{Backfill: bf})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test generation values?

Generation, CreateTime is ignored on Backfill updates, fixing test
to check that.
@aLekSer aLekSer requested a review from Laremere December 1, 2020 21:58
@aLekSer
Copy link
Collaborator Author

aLekSer commented Dec 1, 2020

All comments are resolved.

@Laremere
Copy link

Laremere commented Dec 2, 2020

/gcprun

@Laremere
Copy link

Laremere commented Dec 2, 2020

/gcbrun

Copy link

@Laremere Laremere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra comment should be removed, but a few things are depending on this so I'll merge it if the tests pass.

internal/app/frontend/frontend_service.go Outdated Show resolved Hide resolved
@Laremere
Copy link

Laremere commented Dec 2, 2020

Tests are still failing....

@Laremere Laremere merged commit c85af44 into googleforgames:master Dec 3, 2020
@syntxerror syntxerror added this to the v1.2.0 milestone Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants