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

fix: fix nodejs_binary cross-platform RBE issue #1305 #1320

Merged
merged 3 commits into from
Nov 13, 2019

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Oct 30, 2019

First commit reproduces #1305.

Repo here: https://buildkite.com/bazel/rules-nodejs-nodejs/builds/4727#5a880596-2b15-49a3-947c-a7b2894f6cca from #1324.

A bit hacky but the issue can be reproduced in run_targets in bazelci. There doesn’t seem to be a run_flags to pass —config=remote so I used shell_commands to set the --platform to linux in a new mac_fake_rbe job on buildkite. This sets up the same scenario where the build with --platform linux selected (as it would be on RBE) but the resulting nodejs_binary runnable target is run on osx.

2nd commit fixes the issue.

  • node_launcher.sh now picks the node binary at runtime instead of it being a templated arg evaluated at build time
  • node_binary now adds the correct node tool_files to the nodejs_binary runfiles

3rd commit updates the nodejs toolchain test to no longer test for runfiles. What should be tested is that ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"].nodeinfo.tool_files are for the correct selected --platform.

Fixes #1305.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

nodejs_binary does not work with cross-platform RBE. For example, developer machine is osx and RBE is a linux box

What is the new behavior?

nodejs_binary works with cross-platform RBE

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@gregmagolan gregmagolan changed the title test: repro test: reproduce issue https://github.com/bazelbuild/rules_nodejs/issues/1305 on buildkite Oct 30, 2019
@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 2 times, most recently from cce1e08 to e016ed0 Compare November 1, 2019 06:35
@gregmagolan gregmagolan changed the title test: reproduce issue https://github.com/bazelbuild/rules_nodejs/issues/1305 on buildkite fix: fix nodejs_binary cross-platform RBE issue #1305 Nov 1, 2019
@gregmagolan gregmagolan marked this pull request as ready for review November 1, 2019 06:46
@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 5 times, most recently from 7d9531c to edbd128 Compare November 1, 2019 08:54
internal/node/node.bzl Outdated Show resolved Hide resolved
internal/node/node_launcher.sh Outdated Show resolved Hide resolved
Darwin*) machine=darwin;;
CYGWIN*) machine=windows;;
MINGW*) machine=windows;;
MSYS_NT*) machine=windows;;
Copy link
Collaborator

Choose a reason for hiding this comment

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

sigh, when we introduce a batch/powershell version of the launcher we'll have to pick through this logic again

@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 2 times, most recently from 4d0eef1 to 09446d7 Compare November 1, 2019 20:27
Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

Need more error handling in the case fallthrough

.bazelci/presubmit.yml Show resolved Hide resolved
internal/node/node.bzl Outdated Show resolved Hide resolved
gregmagolan added a commit to gregmagolan/angular that referenced this pull request Nov 2, 2019
@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 5 times, most recently from afc1a95 to d8dfa36 Compare November 7, 2019 01:38
@gregmagolan
Copy link
Collaborator Author

Need more error handling in the case fallthrough

Done

gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 2 times, most recently from b7e1030 to e49745e Compare November 9, 2019 09:18
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 9, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
build_flags:
- "--platforms=@build_bazel_rules_nodejs//toolchains/node:darwin_amd64"
build_targets:
- "//..."
Copy link
Collaborator

Choose a reason for hiding this comment

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

feels really expensive to re-build everything in each configuration. I wonder if we are using more CI resources than any other rules

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we do have quite a few jobs now. it's probably not strictly necessary to build in every permutation but I think at the least we should build everything or some subset of everything with each platform.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe just //internal/... is sufficient to get the coverage we need?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 that should do it for now as only node_binary/node_test vary the build based on platform. We can expand coverage in the future if some of the packages with build differences based on platform.

internal/node/node.bzl Outdated Show resolved Hide resolved
readonly node=$(rlocation "${vendored_node}")

if [ ! -f "${node}" ]; then
printf "\n>>>> FAIL: The vendored node binary '${vendored_node}' not found in runfiles. <<<<\n\n" >&2
Copy link
Collaborator

Choose a reason for hiding this comment

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

will users know what to do with this error?

Copy link
Collaborator Author

@gregmagolan gregmagolan Nov 11, 2019

Choose a reason for hiding this comment

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

It shouldn't happen as the vendored_node binary should be added to runfiles by nodejs_binary... but in the case where there is a bug or something unexpected happens better to have a semi-helpful error message & graceful exit than a crash.

internal/node/node_launcher.sh Show resolved Hide resolved
internal/node/test/BUILD.bazel Outdated Show resolved Hide resolved
packages/protractor/src/protractor.conf.js Outdated Show resolved Hide resolved
A bit hacky but the issue can be reproduced in run_targets in bazelci. There doesn’t seem to be a run_flags to pass —config=remote so I used shell_commands to set the --platform to linux in a new mac_fake_rbe job on buildkite. This sets up the same scenario where the build with --platform linux selected (as it would be on RBE) but the resulting nodejs_binary runnable target is run on osx.
@gregmagolan gregmagolan force-pushed the fix_mac_rbe branch 3 times, most recently from 6461dad to d341869 Compare November 12, 2019 16:33
* node_launcher.sh now picks the node binary at runtime instead of it being a templated arg evaluated at build time
* node_binary now adds the correct node tool_files to the nodejs_binary runfiles

Fixes bazel-contrib#1305

fix: node
…unfiles for the host platform

Runfiles are no longer tested as what should be tested is that ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"].nodeinfo.tool_files are for the correct `--platform`.
@alexeagle alexeagle merged commit b07f65f into bazel-contrib:master Nov 13, 2019
gregmagolan added a commit to gregmagolan/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE angular#33708
* build: update zone.js to use the new rollup_bundle angular#33329
gregmagolan added a commit to gregmagolan/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE angular#33708
* build: update zone.js to use the new rollup_bundle angular#33329
gregmagolan added a commit to gregmagolan/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE angular#33708
* build: update zone.js to use the new rollup_bundle angular#33329

fix: fix
gregmagolan added a commit to gregmagolan/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE angular#33708
* build: update zone.js to use the new rollup_bundle angular#33329

fix: fix
kara pushed a commit to angular/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE #33708
* build: update zone.js to use the new rollup_bundle #33329

fix: fix

PR Close #33802
kara pushed a commit to angular/angular that referenced this pull request Nov 13, 2019
This release includes nodejs cross-platform RBE fix in bazel-contrib/rules_nodejs#1320 and adds `args` to terser_minified in bazel-contrib/rules_nodejs#1317. These changes are needed to land a few outstanding PRs.

* build: fixes for cross-platform RBE #33708
* build: update zone.js to use the new rollup_bundle #33329

fix: fix

PR Close #33802
gregmagolan pushed a commit to gregmagolan/angular that referenced this pull request Nov 13, 2019
* patch for build_bazel_rules_nodejs from bazel-contrib/rules_nodejs#1320
* patch for @bazel/protractor from bazel-contrib/rules_nodejs#1320
* work-around for rules_webtesting cross-platform RBE issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nodejs_binary incorrectly chooses the target platform with RBE
3 participants