-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add testing functionality for WaitExecution #393
Open
bergsieker
wants to merge
3
commits into
bazelbuild:master
Choose a base branch
from
bergsieker:early_wait
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,12 +218,6 @@ func buildCommand(ac *Action) *repb.Command { | |
// 1) If an error occurs before the first operation is returned, or after the final operation is | ||
// returned (i.e. the one with op.Done==true), retry by calling Execute again. | ||
// 2) Otherwise, retry by calling WaitExecution with the last operation name. | ||
// In addition, we want the retrier to trigger based on certain operation statuses as well as on | ||
// explicit errors. (The shouldRetry function knows which statuses.) We do this by mapping statuses, | ||
// if present, to errors inside the closure and then throwing away such "fake" errors outside the | ||
// closure (if we ran out of retries or if there was never a retrier enabled). The exception is | ||
// deadline-exceeded statuses, which we never give to the retrier (and hence will always propagate | ||
// directly to the caller). | ||
func (c *Client) ExecuteAndWait(ctx context.Context, req *repb.ExecuteRequest) (op *oppb.Operation, err error) { | ||
return c.ExecuteAndWaitProgress(ctx, req, nil) | ||
} | ||
|
@@ -233,8 +227,7 @@ func (c *Client) ExecuteAndWait(ctx context.Context, req *repb.ExecuteRequest) ( | |
// The supplied callback function is called for each message received to update the state of | ||
// the remote action. | ||
func (c *Client) ExecuteAndWaitProgress(ctx context.Context, req *repb.ExecuteRequest, progress func(metadata *repb.ExecuteOperationMetadata)) (op *oppb.Operation, err error) { | ||
wait := false // Should we retry by calling WaitExecution instead of Execute? | ||
opError := false // Are we propagating an Operation status as an error for the retrier's benefit? | ||
wait := false // Should we retry by calling WaitExecution instead of Execute? | ||
lastOp := &oppb.Operation{} | ||
closure := func(ctx context.Context) (e error) { | ||
var res regrpc.Execution_ExecuteClient | ||
|
@@ -254,6 +247,7 @@ func (c *Client) ExecuteAndWaitProgress(ctx context.Context, req *repb.ExecuteRe | |
if e != nil { | ||
return e | ||
} | ||
returnEarly := !wait && c.ForceEarlyWaitCalls && !op.Done | ||
wait = !op.Done | ||
lastOp = op | ||
if progress != nil { | ||
|
@@ -262,19 +256,14 @@ func (c *Client) ExecuteAndWaitProgress(ctx context.Context, req *repb.ExecuteRe | |
progress(metadata) | ||
} | ||
} | ||
} | ||
st := OperationStatus(lastOp) | ||
if st != nil { | ||
opError = true | ||
if st.Code() == codes.DeadlineExceeded { | ||
return nil | ||
if returnEarly { | ||
return status.Error(codes.Internal, "fake error to for wait call") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "(...) error to for wait (...)", shouldn't it be, "(...) error to trigger the wait (...)" |
||
} | ||
return st.Err() | ||
} | ||
return nil | ||
} | ||
err = c.Retrier.Do(ctx, func() error { return c.CallWithTimeout(ctx, "Execute", closure) }) | ||
if err != nil && !opError { | ||
if err != nil { | ||
if st, ok := status.FromError(err); ok { | ||
err = StatusDetailedError(st) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not inheretly opposed to this... But I think the most appropriate place for this behavior would be on the fake server: https://github.com/bazelbuild/remote-apis-sdks/blob/af1232ee0d79920ab8390fb855f95dca18a69cf0/go/pkg/fakes/exec.go. Wdyt?