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

deferred download tests hang when the repo is defined in MODULE.bazel #23234

Closed
meteorcloudy opened this issue Aug 7, 2024 · 6 comments
Closed
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@meteorcloudy
Copy link
Member

Description of the bug:

Discovered while migrating tests from WORKSPACE to Bzlmod: #23087

After changing

  cat > WORKSPACE <<'EOF'
load("defer.bzl", "defer")
defer(name="defer")
EOF

to

  cat > MODULE>bazel <<'EOF'
defer = use_repo_rule("defer.bzl", "defer")
defer(name="defer")
EOF

All test cases using deferred.wait() seems to hang indefinitely.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Apply the above change in test_deferred_download_smoke then

bazel test //src/test/shell/bazel:external_integration_test --test_filter test_deferred_download_smoke

Which operating system are you running Bazel on?

Linux, macOS

What is the output of bazel info release?

No response

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

Related commit is 73c1a1e

Any other information, logs, or outputs that you want to share?

No response

@meteorcloudy meteorcloudy added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Aug 7, 2024
@meteorcloudy
Copy link
Member Author

/cc @Wyverald @lberki

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Aug 13, 2024
@Wyverald
Copy link
Member

Wyverald commented Sep 10, 2024

This one is almost funny... This line is invalid MODULE.bazel: defer = use_repo_rule("defer.bzl", "defer") (the label needs to be "//:defer.bzl"). Bazel immediately crashes (which is I think the same as #23138), but the test setup is such that it waits for an "ack" from Bazel before continuing, and obviously that "ack" never comes. So the test hangs forever.

@meteorcloudy
Copy link
Member Author

Thanks for figuring it out!!

@meteorcloudy
Copy link
Member Author

It is possible to somehow fix the test setup to let it fail with a meaningful error?

@Wyverald
Copy link
Member

there's apparently a "timeout" command on GNU/Linux (https://stackoverflow.com/questions/7270622/reading-with-cat-stop-when-not-receiving-data) but it's not available on macOS.

other solutions seem rather messy (one requires a & sleep 5 ; kill $! tagged on to every cat or echo to a pipe). not sure what the best way here is, maybe @lberki has an idea.

@lberki
Copy link
Contributor

lberki commented Sep 12, 2024

By "test setup" do you mean the cat "${server_dir}/gate_socket" statements that wait until Bazel does something by synchronizing on a named pipe?

If so, I don't have any wisdom to offer other than that it's very reasonable to encapsulate the "sleep then kill" functionality in a function, which would result in less pollution. Something like this (wrote in half a minute, don't expect this to be perfect):

function timeout() {
  local T=$1;
  shift;
  (bash -c "$@") &
  WORK=$!; 
  sleep $T; kill $WORK) &
  WATCHDOG=$!;
  wait $WORK;
  kill -9 $WATCHDOG
}

timeout 5 "cat $FIFO"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants