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

WIP: custom platform properties #1432

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BuildStream-Migration-Bot

See original merge request on GitLab
In GitLab by [Gitlab user @tpollard] on Nov 6, 2020, 16:55

This is related to https://gitlab.com/BuildStream/buildstream/-/issues/1313

In short, there are remote-exection usecases where server/worker implementations may incorporate custom/additional platform properties, or choose not to implement all/any of the 'optional' standard properties, as defined by the platform message lexicon:
https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/execution/v2/platform.md

  • Add tests (probably excessive running the full set of tests against multiple platform configurations?)
  • Add validation type filtering (no nesting etc)
  • Add support for multi value properties (i.e, ISA which needs support adding already even without this MR)
  • Cache Key considerations (when changing default properties which have previously constituted get_unique_key() for the sandbox config)

This branch is being exercised with this remote-apis-testing MR https://gitlab.com/remote-apis-testing/remote-apis-testing/-/merge_requests/192

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 6, 2020, 16:56

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 13:06

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 13:13

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 13:14

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 15:21

added 1 commit

  • 7eee7ea7 - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 15:42

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 15:50

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 16:01

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 16:02

changed the description

1 similar comment
@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 16:02

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 9, 2020, 16:04

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 12:54

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 13:44

added 1 commit

  • b6f2f26a - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 13:55

added 1 commit

  • 6fef601e - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 14:07

added 1 commit

  • 60e5903b - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 16:49

added 1 commit

  • def5d301 - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 16:50

marked the task Add tests (expand remote_services fixture?) as completed

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 16:50

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 10, 2020, 17:36

added 1 commit

  • fee056bd - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 11, 2020, 11:04

added 1 commit

  • 36766aba - Try with without a custom property

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 11, 2020, 11:15

added 14 commits

  • 945cbba5 - _loader/loader.py: Avoid double dictionary lookup
  • a90de781 - _loader/loader.py: Fix _load_file() for cross project link element loads.
  • eeb2ab18 - _loader/loader.py: Fixing new pylint "no-member" error
  • 8e0e4702 - get release and snapshot badges from docs website
  • c225ff50 - testutils/platform: Refactor to be compatible with Python 3.9
  • 53b9590d - _loader/loader.py: Support overriding elements
  • 93d62dfa - tests/format/junctions.py: Testing element override scenarios
  • b19107ad - plugins/elements/junction.py: Documenting element overrides.
  • 2afa8f0c - _stream.py: Make `_enqueue_plan` a timed activity
  • 86fd33de - tox.ini/.gitlab-ci.yml: Add test environment for Python 3.9
  • c5a35e66 - NEWS/setup.py: Advertise our support for Python 3.9
  • b2785e50 - src/buildstream/element.py: __use_remote_execution() reword desc
  • 9b2e0005 - WIP custom platform properties
  • e8210fba - try debug

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 11, 2020, 11:26

added 1 commit

  • c66aab73 - try debug

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 11, 2020, 11:36

added 1 commit

  • 3f9c075b - try debug

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 11, 2020, 11:50

added 22 commits

  • 3f9c075b...f6ee38f5 - 20 commits from branch master
  • 166bff5a - WIP custom platform properties
  • f9798863 - Add debug

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 15:38

added 1 commit

  • 39d0c154 - Try using custom bgd conf

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 15:52

added 1 commit

  • 24bdad8e - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 15:55

The RE tests should now be working with the default properties, with the addition of a custom property and with a default property not set (ISA).

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 16:02

added 1 commit

  • 474d23f7 - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 16:03

added 1 commit

  • abd19c98 - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 12, 2020, 16:08

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 13, 2020, 15:56

mentioned in merge request remote-apis-testing/remote-apis-testing!192

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 16, 2020, 10:45

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 16, 2020, 13:37

This is branch now passing the buildstream-buildbarn integration test at https://gitlab.com/remote-apis-testing/remote-apis-testing/-/merge_requests/192

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 18, 2020, 10:30

I feel like this implementation needs initial review before working on the remaining hardening

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 18, 2020, 10:45

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tristanvb] on Nov 20, 2020, 05:12

First pass highlevel API considerations:

  • Custom platform properties as I understand, must be worker bound and not RE service bound. From the BuildStream perspective, I think it only makes sense to have these configurable at the SandboxConfig level, and not at the project level (a project-wide default can be set for project elements across the board anyway).

    Having platform properties configurable only at the project level would preclude use cases where a project requires some elements to be built in some specific environments while others need to be built in different environments (and I think that the ability to build in multiple different environments is one of the more significant value additions which RE brings to the table).

  • The default-platform-properties approach deserves some discussion.

    Ideally, a project author should not have to special case project or element configuration in any was just because the build site has been configured to be connected to an RE service.

    The behavior we're looking for is:

    • If BuildStream is building locally, and if an element requires a platform property which cannot be satisfied by buildbox-run on the local build machine, then BuildStream exits (either early exit, or build everything which can be built, that is a separate discussion).
    • If BuildStream is building over an RE service, and if no worker on that service can be found with the platform properties required by that element, then that element fails in that build (again, either as early as possible or not, separate concern).

    If I understand correctly, default-platform-properties (probably more aptly named as default-platform-requirements) is a set of platform properties that BuildStream core decides to require for element builds on an RE service.

    This (iiuc) mostly revolves things like locally discovered machine architecture reported by uname.

    I personally do not like having this switch, as we're straying into territory where project authors need to make special considerations only based user configuration, like whether a user decided to build on an RE service or not (if there is project configuration here; it is only advice, user configuration has the last word on details of how to build, project data consists of what to build).

    I think it would be more desirable to force the project authors to specify required platform properties more explicitly, rather than have BuildStream core automatically derive anything from the local platform, which has no relation to the platform the project should be built on (if we are running in RE mode, there is no reason to expect the local platform to be relevant at all). If there are platform properties which must absolutely be specified when building on an RE service, then the build can simply fail if the project author failed to specify that platform property requirement.

    It is also worth considering how platform properties can be extended. If we have a local boolean switch which says that BuildStream will automatically derive stuff from the local build host, can such automatically required platform properties be extended in a backwards compatible way ? I think not, I think that upgrading to a version of BuildStream which suddenly requires a new platform property automatically, will break cache key stability.

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 23, 2020, 12:05

Hi [Gitlab user @tristanvb] thanks for the initial comments, I'll try and answer where I can:

Custom platform properties as I understand, must be worker bound and not RE service bound.

In terms of Buildgrid, the server also needs to be configured to allow arbitrary/custom properties for jobs before they're assigned to a worker, this MR currently has an example of that using the required config from https://gitlab.com/BuildGrid/buildgrid/-/blob/master/buildgrid/_app/settings/reference.yml#L150 Without BuildStream being able to query the capabilities of a server (which even if it could I don't think it should) I think the remotespec is the correct place for this config.

preclude use cases where a project requires some elements to be built in some specific environments while others need to be built in different environments

I agree, there's definitely usecases where a project could have elements that need to be built on differing workers (for instance, with gpu acceleration present). I suppose one approach to that could be to have specific junctions for specific environments?

I think it would be more desirable to force the project authors to specify required platform properties more explicitly

I wouldn't be against this, but I also can see the view that the current sourcing of 'default properties' is a nice to have. However if a user wants to specify 'custom properties', then I'd be happy if that then superseeded any local decisions bst would normally make (i.e, the user needs to declare all the properties they require if they want to stray from the local defaults). This would be more explicit, and would only require a single new config option.

It is worth considering the complication of cachekeys being a product of these local defaults from the host sandboxconfig (uname etc), if not set by the user/project/element. For instance, this could lead to hashing linux and x86-64 for the key but then ignoring this input data and building remotely with darwin and arm64 as the platform properties with this explicit superseeding without some form of validation against the sanboxconfig values. Not just cachekeys either, this could lead to issues when trying to launch a local sandbox on an artifact that was built remotely without handling the mismatch.

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @juergbi] on Nov 25, 2020, 08:13

It's overall pretty tricky because the Remote Execution API allows the server implementation a lot of flexibility. I.e., it's underspecified and the servers are not required to support any particular platform property. The reason for this is that RE clients and their (sandboxing) requirements are also quite diverse.

Platform properties are used for a variety of use cases. From OS/ISA selection to sandboxing restrictions, Docker images, hardware requirements and project tagging. The effect of this is that at least in some cases BuildStream as a client will need server-specific 'platform properties'.

I think our aim should be that anything that is not specific to a particular RE server (and thus, is typically also applicable to local builds) is declared in the project or element-level sandbox config and takes part in the cache key calculation.

However, configuration that is truly server-specific should clearly not take part in the cache key calculation and thus belongs in the remote-execution section, in my opinion.

A concern are aspects that are not specific to a particular RE server, however, where the RE server requires non-standard configuration (or standard configuration does not even exist).

I tend towards something like the following:

  • Support server-specific platform properties in the remote-execution section as in this MR (I'd shorten custom-platform-properties to just platform-properties, though). Also support multi-valued properties by means of YAML lists.
  • Support overriding platform properties from the sandbox section in the remote-execution section. I.e., let the latter take precedence. However, drop default-platform-properties and require explicit listing of each property to override, reducing the risk of accidentally diverging/skipping configuration. Support e.g. OS: [] (empty YAML list) to unset a property.
  • Also support custom platform properties in the sandbox section, adding a platform-properties dict (or reapi-platform?). These properties will take part in the cache key calculation and be passed to both buildbox-run and remote execution (unless overridden by server-specific properties).¹ We could defer this until we have a use case for it.
  • Reject/fail builds that specify platform properties not supported by the local sandbox. For remote execution we can't determine what the server supports, so it's up to the server to reject the action for unsupported platform properties.

¹ A more radical variant would be to simply make sandbox a dict of REAPI platform properties and completely drop BuildStream core logic mangling with platform properties. However, this would definitely have some downsides: not forcing arch/OS values to exist (risk of underspecified cache key), not providing the convenience of inferring the arch/OS from the host (or arch alias), possible problem to enable network and inherit uid for non-isolated bst shell, maybe more.

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 25, 2020, 15:54

changed the description

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 26, 2020, 10:24

added 11 commits

  • abd19c98...19a450c3 - 10 commits from branch master
  • b32ef1d - WIP custom platform properties

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 26, 2020, 14:52

added 1 commit

  • 45e36db6 - Remove and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 26, 2020, 16:45

added 1 commit

  • e1449829 - Remove and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 09:46

added 1 commit

  • 3c149b3b - Remove and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 10:23

added 1 commit

  • dc5fbd35 - Remove and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 12:25

added 1 commit

  • e770509b - Remove and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 13:20

added 1 commit

  • 1303bc1b - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 14:19

added 1 commit

  • 1c3bc0a5 - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 14:43

added 1 commit

  • f521c49c - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 15:12

added 1 commit

  • b3d1c275 - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 15:27

added 1 commit

  • 555d0289 - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 15:46

added 1 commit

  • 7c401da9 - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 15:47

added 1 commit

  • 8d46637 - Remove 'default-platform-properties' and reduce scope

Compare with previous version

@BuildStream-Migration-Bot
Copy link
Author

In GitLab by [Gitlab user @tpollard] on Nov 27, 2020, 16:35

[Gitlab user @juergbi]

I've added a commit (will squash and tidy etc after agreement/code review ofc) which drops the default-platform-properties bool, changing custom-platform-properties to platform-properties, and allowing that as an entry point to explicitly disable any locally derived sandbox 'default' platform properties by providing a value of [] as suggested.

If one of the 'default' properties is passed via this config option, providing a value which is anything other than [] will not be accepted and a related SandBoxError is raised (there's also a new test for this). If we limit changing the values of these properties (OSFamily, ISA etc. Those that are not specific/custom to the remote server) to sandbox config, then it ensures the true value will be part of the cache key, and match reality when using the config locally (important when trying to launch a local sandbox on an element that may have been built remotely on an isa/os that is not supported locally). When launching a remote sandbox the capabilities of the local sandbox are also not assessed pre-preemptively, so this means we won't wrongly block remote builds when buildbox locally is limited to the host environment which does not match the remote executor.

What do you think? (There's obviously a few things left to implement, like allowing properties to have list values and preventing nested dicts in the yaml, etc)

@jjardon
Copy link
Contributor

jjardon commented Apr 4, 2022

Note this is related with #1313

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.

3 participants