-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remote: Fix a bug that outputs of actions tagged with no-remote are u… #15212
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,37 +13,71 @@ | |
// limitations under the License. | ||
package com.google.devtools.build.lib.remote.common; | ||
|
||
import build.bazel.remote.execution.v2.ExecuteResponse; | ||
import build.bazel.remote.execution.v2.RequestMetadata; | ||
import com.google.devtools.build.lib.actions.ActionExecutionMetadata; | ||
import com.google.devtools.build.lib.actions.Spawn; | ||
import javax.annotation.Nullable; | ||
|
||
/** A context that provide remote execution related information for executing an action remotely. */ | ||
public interface RemoteActionExecutionContext { | ||
/** The type of the context. */ | ||
enum Type { | ||
REMOTE_EXECUTION, | ||
BUILD_EVENT_SERVICE, | ||
public class RemoteActionExecutionContext { | ||
/** The current step of the context. */ | ||
public enum Step { | ||
INIT, | ||
CHECK_ACTION_CACHE, | ||
UPLOAD_INPUTS, | ||
EXECUTE_REMOTELY, | ||
UPLOAD_OUTPUTS, | ||
DOWNLOAD_OUTPUTS, | ||
UPLOAD_BES_FILES, | ||
} | ||
|
||
/** Returns the {@link Type} of the context. */ | ||
Type getType(); | ||
private final Spawn spawn; | ||
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. Mark as 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. Done. |
||
private final RequestMetadata requestMetadata; | ||
private final NetworkTime networkTime; | ||
|
||
@Nullable private ExecuteResponse executeResponse; | ||
private Step step; | ||
|
||
public RemoteActionExecutionContext( | ||
Spawn spawn, RequestMetadata requestMetadata, NetworkTime networkTime) { | ||
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. Same as above. 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. Also - should we make the ctor private to enforce construction through one of the 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. Done. |
||
this.spawn = spawn; | ||
this.requestMetadata = requestMetadata; | ||
this.networkTime = networkTime; | ||
this.step = Step.INIT; | ||
} | ||
|
||
/** Returns current {@link Step} of the context. */ | ||
public Step getStep() { | ||
return step; | ||
} | ||
|
||
/** Sets current {@link Step} of the context. */ | ||
public void setStep(Step step) { | ||
this.step = step; | ||
} | ||
|
||
/** Returns the {@link Spawn} of the action being executed or {@code null}. */ | ||
@Nullable | ||
Spawn getSpawn(); | ||
public Spawn getSpawn() { | ||
return spawn; | ||
} | ||
|
||
/** Returns the {@link RequestMetadata} for the action being executed. */ | ||
RequestMetadata getRequestMetadata(); | ||
public RequestMetadata getRequestMetadata() { | ||
return requestMetadata; | ||
} | ||
|
||
/** | ||
* Returns the {@link NetworkTime} instance used to measure the network time during the action | ||
* execution. | ||
*/ | ||
NetworkTime getNetworkTime(); | ||
public NetworkTime getNetworkTime() { | ||
return networkTime; | ||
} | ||
|
||
@Nullable | ||
default ActionExecutionMetadata getSpawnOwner() { | ||
public ActionExecutionMetadata getSpawnOwner() { | ||
Spawn spawn = getSpawn(); | ||
if (spawn == null) { | ||
return null; | ||
|
@@ -52,23 +86,26 @@ default ActionExecutionMetadata getSpawnOwner() { | |
return spawn.getResourceOwner(); | ||
} | ||
|
||
/** Creates a {@link SimpleRemoteActionExecutionContext} with given {@link RequestMetadata}. */ | ||
static RemoteActionExecutionContext create(RequestMetadata metadata) { | ||
return new SimpleRemoteActionExecutionContext( | ||
/*type=*/ Type.REMOTE_EXECUTION, /*spawn=*/ null, metadata, new NetworkTime()); | ||
public void setExecuteResponse(@Nullable ExecuteResponse executeResponse) { | ||
this.executeResponse = executeResponse; | ||
} | ||
|
||
@Nullable | ||
public ExecuteResponse getExecuteResponse() { | ||
return executeResponse; | ||
} | ||
|
||
/** Creates a {@link RemoteActionExecutionContext} with given {@link RequestMetadata}. */ | ||
public static RemoteActionExecutionContext create(RequestMetadata metadata) { | ||
return new RemoteActionExecutionContext(/*spawn=*/ null, metadata, new NetworkTime()); | ||
} | ||
|
||
/** | ||
* Creates a {@link SimpleRemoteActionExecutionContext} with given {@link Spawn} and {@link | ||
* Creates a {@link RemoteActionExecutionContext} with given {@link Spawn} and {@link | ||
* RequestMetadata}. | ||
*/ | ||
static RemoteActionExecutionContext create(@Nullable Spawn spawn, RequestMetadata metadata) { | ||
return new SimpleRemoteActionExecutionContext( | ||
/*type=*/ Type.REMOTE_EXECUTION, spawn, metadata, new NetworkTime()); | ||
} | ||
|
||
static RemoteActionExecutionContext createForBES(RequestMetadata metadata) { | ||
return new SimpleRemoteActionExecutionContext( | ||
/*type=*/ Type.BUILD_EVENT_SERVICE, /*spawn=*/ null, metadata, new NetworkTime()); | ||
public static RemoteActionExecutionContext create( | ||
@Nullable Spawn spawn, RequestMetadata metadata) { | ||
return new RemoteActionExecutionContext(spawn, metadata, new NetworkTime()); | ||
} | ||
} |
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.
Is it a good idea to rename this, given that there are two different context objects?
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.
Yes. Revert the rename. Extracted RemoteAction to an upper level.