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

Add fallback_environment for remote_environment #16955

Merged
merged 5 commits into from
Sep 22, 2022

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Sep 21, 2022

Closes #16907.

This feature is particularly powerful when you are using a Docker image for remote execution and you set the fallback environment is a Docker environment: it means you can always use the same container.

Note that we considered instead having consuming targets set this fallback logic in the environment: str field. This would mean adding a docker_image field to the remote_execution environment target where the user gives us a hint what the value is, and then call sites use a new DSL like environment="image:centos6. This PR was accepted in https://pantsbuild.slack.com/archives/C0D7TNJHL/p1663790578352079 as a simper design, especially because we want to keep things simpler for consumers of this feature, which make up the majority of the users.

[ci skip-rust]
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano changed the title [wip] Add fallback_environment for remote_environment Add fallback_environment for remote_environment Sep 21, 2022
@Eric-Arellano Eric-Arellano added the category:internal CI, fixes for not-yet-released features, etc. label Sep 21, 2022
@Eric-Arellano Eric-Arellano marked this pull request as ready for review September 21, 2022 23:20
src/python/pants/core/util_rules/environments.py Outdated Show resolved Hide resolved
if (
not tgt.has_field(CompatiblePlatformsField)
and not tgt.has_field(DockerImageField)
and not tgt.has_field(RemotePlatformField)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. This blocked RE targets actually being usable

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!


Must be an environment name from the option `[environments-preview].names`, the
special string `{LOCAL_ENVIRONMENT_MATCHER}` to use the relevant local environment, or the
string `{_NO_FALLBACK_ENVIRONMENT}` to error when remote execution is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

I think that falling back by default to the local environment is error prone, so I think that this is potentially inverted.

The chances of a local environment being compatible with the remote environment without extra consideration/attention paid to setting up all of the env vars correctly is pretty slim: and it seems better to fail fast in that case ("you probably haven't made this compatible yet"), rather than to fail slowly ("I fell back automatically for you, and now something is failing in an unexpected way mid build").

Having this be None (the literal value) by default, and failing if remote execution cannot be used would be preferable I think, and avoids a special case.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@@ -204,12 +204,36 @@ class RemoteExtraPlatformPropertiesField(StringSequenceField):
)


_NO_FALLBACK_ENVIRONMENT = "<none>"
Copy link
Member

Choose a reason for hiding this comment

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

With None as the default, this value is no longer necessary.

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@Eric-Arellano Eric-Arellano enabled auto-merge (squash) September 22, 2022 18:34
@Eric-Arellano Eric-Arellano merged commit e6c6121 into pantsbuild:main Sep 22, 2022
@Eric-Arellano Eric-Arellano deleted the remote-fallback branch September 22, 2022 20:14
Eric-Arellano added a commit that referenced this pull request Sep 23, 2022
…nvironment` (#16971)

Follow up to #16955.

It makes sense to also allow fallbacks for local environments and docker environments, because using those environments is fallible:

- local environment might not match the platform
- docker environment might not match the platform when using Linux because it does not use virtualization, unlike macOS, to handle a different CPU arch

The user may want to do things like prefer local if on Linux, but fall back to Docker if on macOS.

[ci skip-rust]
[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--remote-execution global option should likely disable remote execution environments
3 participants