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 exception message to 'failed to create output directory' #17951

Conversation

EdSchouten
Copy link
Contributor

It looks like all of the similar code paths in this file properly attach the exception message to the error message, while this one does not. Omitting the message makes it hard to figure out the root cause.

While there, make a minor error message string formatting improvement.

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Apr 2, 2023
@sgowroji sgowroji added team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team and removed team-Local-Exec Issues and PRs for the Execution (Local) team labels Apr 3, 2023
@EdSchouten EdSchouten force-pushed the eschouten/20230402-error-message branch from 34d80b8 to cdb04dc Compare April 3, 2023 17:14
It looks like all of the similar code paths in this file properly attach
the exception message to the error message, while this one does not.
Omitting the message makes it hard to figure out the root cause.

While there, make a minor error message string formatting improvement.
@EdSchouten EdSchouten force-pushed the eschouten/20230402-error-message branch from cdb04dc to 67c6ec6 Compare April 4, 2023 07:13
EdSchouten added a commit to EdSchouten/bazel that referenced this pull request Apr 4, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend
its logging. See bazelbuild#17951. With
that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output
file at bazel-bin/some/path/foo, followed by attempting to build the
target. It looks like Bazel simply attempts to create output directories
without taking into consideration whether a file already exists at the
target location. This is problematic when someone alters an existing
build target to emit a directory instead of a regular file.

bb_clientd reports itself as being an
ActionFileSystemType.REMOTE_FILE_SYSTEM. Based on the documentation for
this enum value, I think this is correct. bb_clientd is capable of
persisting information on previous builds and reloading it. This means
that if a previous build yielded a regular file, a successive build
would need to explicitly remove it before replacing it with an output
directory.

reateActionFsOutputDirectories() assumes that it doesn't need to do any
cleanups. I therefore think it's only safe to use in case of
ActionFileSystemType.IN_MEMORY_ONLY_FILE_SYSTEM. We should therefore
only call it if !ActionFileSystemType.supportsLocalActions().
EdSchouten added a commit to EdSchouten/bazel that referenced this pull request Apr 4, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend
its logging. See bazelbuild#17951. With
that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output
file at bazel-bin/some/path, followed by attempting to build the target.
It looks like Bazel simply attempts to create output directories without
taking into consideration whether a file already exists at the target
location. This is problematic when someone alters an existing build
target to emit a directory instead of a regular file.

Note that this only an issue when the remote action file system is used.
Plain builds (ones that don't use Builds without the Bytes or
bb_clientd) are unaffected. This change addresses this issue by reusing
the same fallback path creation strategy that plain builds already use.
@brentleyjones
Copy link
Contributor

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Apr 4, 2023
@keertk
Copy link
Member

keertk commented Apr 4, 2023

@bazel-io fork 6.2.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Apr 4, 2023
@sgowroji
Copy link
Member

sgowroji commented Apr 5, 2023

Hi @justinhorvitz, Since I can see that this PR has been approved, please let me know whether I should proceed with importing it.Thanks!

@justinhorvitz
Copy link
Contributor

@sgowroji yes you may proceed with importing thank you

@sgowroji sgowroji added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Apr 5, 2023
copybara-service bot pushed a commit that referenced this pull request Apr 11, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend its logging. See #17951. With that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output file at bazel-bin/some/path, followed by attempting to build the target. It looks like Bazel simply attempts to create output directories without taking into consideration whether a file already exists at the target location. This is problematic when someone alters an existing build target to emit a directory instead of a regular file.

Note that this only an issue when the remote action file system is used.    Plain builds (ones that don't use Builds without the Bytes or    bb_clientd) are unaffected. This change addresses this issue by reusing    the same fallback path creation strategy that plain builds already use.

Closes #17968.

PiperOrigin-RevId: 523408378
Change-Id: I0d7559352687c317de72e0bf5bc6b5ba7452f97e
@ShreeM01 ShreeM01 removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Apr 11, 2023
ShreeM01 pushed a commit to ShreeM01/bazel that referenced this pull request Apr 12, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend its logging. See bazelbuild#17951. With that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output file at bazel-bin/some/path, followed by attempting to build the target. It looks like Bazel simply attempts to create output directories without taking into consideration whether a file already exists at the target location. This is problematic when someone alters an existing build target to emit a directory instead of a regular file.

Note that this only an issue when the remote action file system is used.    Plain builds (ones that don't use Builds without the Bytes or    bb_clientd) are unaffected. This change addresses this issue by reusing    the same fallback path creation strategy that plain builds already use.

Closes bazelbuild#17968.

PiperOrigin-RevId: 523408378
Change-Id: I0d7559352687c317de72e0bf5bc6b5ba7452f97e
ShreeM01 pushed a commit to ShreeM01/bazel that referenced this pull request Apr 12, 2023
It looks like all of the similar code paths in this file properly attach the exception message to the error message, while this one does not. Omitting the message makes it hard to figure out the root cause.

While there, make a minor error message string formatting improvement.

Closes bazelbuild#17951.

PiperOrigin-RevId: 523461253
Change-Id: I96e434d0934c26ecc696cf386362ee17a6588cc5
ShreeM01 added a commit that referenced this pull request Apr 13, 2023
It looks like all of the similar code paths in this file properly attach the exception message to the error message, while this one does not. Omitting the message makes it hard to figure out the root cause.

While there, make a minor error message string formatting improvement.

Closes #17951.

PiperOrigin-RevId: 523461253
Change-Id: I96e434d0934c26ecc696cf386362ee17a6588cc5

Co-authored-by: Ed Schouten <eschouten@apple.com>
ShreeM01 added a commit that referenced this pull request Apr 13, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend its logging. See #17951. With that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output file at bazel-bin/some/path, followed by attempting to build the target. It looks like Bazel simply attempts to create output directories without taking into consideration whether a file already exists at the target location. This is problematic when someone alters an existing build target to emit a directory instead of a regular file.

Note that this only an issue when the remote action file system is used.    Plain builds (ones that don't use Builds without the Bytes or    bb_clientd) are unaffected. This change addresses this issue by reusing    the same fallback path creation strategy that plain builds already use.

Closes #17968.

PiperOrigin-RevId: 523408378
Change-Id: I0d7559352687c317de72e0bf5bc6b5ba7452f97e

Co-authored-by: Ed Schouten <eschouten@apple.com>
fweikert pushed a commit to fweikert/bazel that referenced this pull request May 25, 2023
I would receive reports of build failures along these lines:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo'

In order to root cause this, I made a minor change to Bazel to extend its logging. See bazelbuild#17951. With that change applied, the error became:

> ERROR: some/path/BUILD:156:32: Executing genrule //some/path:some_target failed: failed to create output directory '.../some/path/foo': .../some/path/foo (Not a directory)

I was eventually able to reproduce this by manually creating an output file at bazel-bin/some/path, followed by attempting to build the target. It looks like Bazel simply attempts to create output directories without taking into consideration whether a file already exists at the target location. This is problematic when someone alters an existing build target to emit a directory instead of a regular file.

Note that this only an issue when the remote action file system is used.    Plain builds (ones that don't use Builds without the Bytes or    bb_clientd) are unaffected. This change addresses this issue by reusing    the same fallback path creation strategy that plain builds already use.

Closes bazelbuild#17968.

PiperOrigin-RevId: 523408378
Change-Id: I0d7559352687c317de72e0bf5bc6b5ba7452f97e
fweikert pushed a commit to fweikert/bazel that referenced this pull request May 25, 2023
It looks like all of the similar code paths in this file properly attach the exception message to the error message, while this one does not. Omitting the message makes it hard to figure out the root cause.

While there, make a minor error message string formatting improvement.

Closes bazelbuild#17951.

PiperOrigin-RevId: 523461253
Change-Id: I96e434d0934c26ecc696cf386362ee17a6588cc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants