Skip to content

Commit

Permalink
[7.2.0] Treat an IOException while logging a spawn as an error instea…
Browse files Browse the repository at this point in the history
…d of a warning. (#22253)

Although failing to write a log does not in principle affect the ability
to build successfully, treating it as a warning hides problems and makes
debugging them difficult (see e.g.
#21820). Spawn log
implementations must be able to inspect the spawn inputs even if they're
not present on disk (when building without the bytes) by using in-memory
data.

PiperOrigin-RevId: 631042310
Change-Id: Iabe48e524dcd77bc434037c3396956f30174f57f
  • Loading branch information
tjgq authored May 6, 2024
1 parent 72cc6c7 commit fed3603
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.devtools.build.lib.actions.SpawnResult.Status;
import com.google.devtools.build.lib.actions.Spawns;
import com.google.devtools.build.lib.actions.UserExecException;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.exec.Protos.Digest;
import com.google.devtools.build.lib.exec.SpawnCache.CacheHandle;
Expand Down Expand Up @@ -198,11 +197,16 @@ public ImmutableList<SpawnResult> exec(
: actionExecutionContext.getExecRoot().getFileSystem(),
context.getTimeout(),
spawnResult);
} catch (IOException | ForbiddenActionInputException e) {
actionExecutionContext
.getEventHandler()
.handle(
Event.warn("Exception " + e + " while logging properties of " + spawn.toString()));
} catch (IOException e) {
throw new EnvironmentalExecException(
e,
FailureDetail.newBuilder()
.setMessage("IOException while logging spawn")
.setSpawn(FailureDetails.Spawn.newBuilder().setCode(Code.SPAWN_LOG_IO_EXCEPTION))
.build());
} catch (ForbiddenActionInputException e) {
// Should have already been thrown during execution.
throw new IllegalStateException("ForbiddenActionInputException while logging spawn", e);
}
}
if (ex != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/protobuf/failure_details.proto
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ message Spawn {
UNSPECIFIED_EXECUTION_FAILURE = 12 [(metadata) = { exit_code: 1 }];
FORBIDDEN_INPUT = 13 [(metadata) = { exit_code: 1 }];
REMOTE_CACHE_EVICTED = 14 [(metadata) = { exit_code: 39 }];
SPAWN_LOG_IO_EXCEPTION = 15 [(metadata) = { exit_code: 36 }];
}
Code code = 1;

Expand Down

0 comments on commit fed3603

Please sign in to comment.