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

reapi: favor platform set in Action over Command #7550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sluongng
Copy link
Contributor

In REAPI v2.2, the usage of platform in Command was deprecated over in
Action. Although most of the older REAPI clients, such as Bazel, are
setting it in both, newer clients such as Buck2 would only set it in
Action message.

This change replace most of existing command.GetPlatform() calls with
action.GetPlatform() while using the command value as fallback.

Closes https://github.com/buildbuddy-io/buildbuddy-internal/issues/3863

In REAPI v2.2, the usage of platform in Command was deprecated over in
Action. Although most of the older REAPI clients, such as Bazel, are
setting it in both, newer clients such as Buck2 would only set it in
Action message.

This change replace most of existing `command.GetPlatform()` calls with
`action.GetPlatform()` while using the command value as fallback.

Closes buildbuddy-io/buildbuddy-internal#3863
@sluongng sluongng marked this pull request as ready for review September 27, 2024 12:35
Copy link
Member

@bduffany bduffany left a comment

Choose a reason for hiding this comment

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

as a preliminary step, wdyt about adding some logging in execution_server to see whether we get any actions where the action platform is empty but the command platform isn't? If in practice, the action platform is always set, then I think we could skip adding this fallback logic everywhere to simplify things a bit. (I'm fine with the fallback as well, just thinking if we want to remove the fallback eventually anyway, we may as well just do it right away, if possible?)

Comment on lines +262 to +265
p := task.GetAction().GetPlatform()
if p == nil || len(p.GetProperties()) == 0 {
p = task.GetCommand().GetPlatform()
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: can you consolidate this fallback logic into a helper func in platform.go like platform.GetProto(action, command)

Comment on lines +703 to +713
// FindValueInTask scans the platform properties of the given task for the given
// property name (ignoring case) and returns the value of that property if it
// exists, otherwise "".
func FindValueInTask(task *repb.ExecutionTask, name string) string {
p := task.GetAction().GetPlatform()
if p == nil || len(p.GetProperties()) == 0 {
p = task.GetCommand().GetPlatform()
}
value, _ := findValue(p, name)
return value
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think if we had a helper func like platform.GetProto(action, command) that returns the effective platform, then we could instead write p := platform.GetProto(task.GetAction(), task.GetCommand()) and platform.FindValue(p, "some-prop") instead of using this helper func. It's slightly more verbose but helps minimize the API surface of this package - and we only need this logic in a couple of places.

vanja-p added a commit that referenced this pull request Oct 4, 2024
In REAPI v2.2, the usage of platform in Command was deprecated over in
Action. Although most of the older REAPI clients, such as Bazel, are
setting it in both, newer clients such as Buck2 would only set it in
Action message.

This change replace most of existing command.GetPlatform() calls with
action.GetPlatform() while using the command value as fallback.

This was heavily inspired by #7550, but with a few more changes.

I tried a simpler approach where we overwrite command.platform with action.platform, but because we read the original protos by digest in ExecutionServer.markTaskComplete, this doesn't work.

Closes buildbuddy-io/buildbuddy-internal#3863
vanja-p added a commit that referenced this pull request Oct 7, 2024
In REAPI v2.2, the usage of platform in Command was deprecated over in
Action. Although most of the older REAPI clients, such as Bazel, are
setting it in both, newer clients such as Buck2 would only set it in
Action message.

This change replace most of existing command.GetPlatform() calls with
action.GetPlatform() while using the command value as fallback.

This was heavily inspired by
#7550, but with a few
more changes.

I tried a simpler approach where we overwrite command.platform with
action.platform, but because we read the original protos by digest in
ExecutionServer.markTaskComplete, this doesn't work.

Closes buildbuddy-io/buildbuddy-internal#3863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants