Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/notes/2.31.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Java first party dependency inference logic [now](https://github.com/pantsbuild/

Updated to use Coursier v2.1.24 by default to pick up a bug fix allowing us to [simplify our code a bit](https://github.com/pantsbuild/pants/pull/22906).


#### Python

A variety of Pex options to support building [native executables
Expand Down
7 changes: 7 additions & 0 deletions docs/notes/2.32.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ The plugin API's `Get()` and `MultiGet()` constructs, deprecated in 2.30, are no

### Backends

### Remote Execution

Upgraded RE API to v2.2
- Checked in the latest dump of proto files from googleapis and bazelbuild_remote-apis reporisotires
- RE API v2.1 deprecates separate Command.output_files and Command.output_directories and unifies into single Command.output_paths field
- RE API v2.2 migrates Platform field from Command to Action

#### Docker

The option `[docker].push_on_package` can be used to prevent Docker images from being pushed during packaging, i.e. when `--output` contains `push=True` or `type=registry`.
Expand Down
59 changes: 26 additions & 33 deletions src/rust/process_execution/remote/src/remote_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,8 @@ impl CommandRunner {
digest {trie_digest:?} contained a symlink instead.",
trie_digest = root_trie.compute_root_digest(),
)),
Some(directory::Entry::Directory(_)) => Err(format!(
"Declared output file path {file_path:?} in output \
digest {trie_digest:?} contained a directory instead.",
trie_digest = root_trie.compute_root_digest(),
)),
// Return None for directories so they can be handled as output_directories
Some(directory::Entry::Directory(_)) => Ok(None),
}
}

Expand Down Expand Up @@ -221,36 +218,32 @@ impl CommandRunner {
digests.insert(result.stdout_digest);
digests.insert(result.stderr_digest);

for output_directory in &command.output_directories {
let (tree, file_digests) = match Self::make_tree_for_output_directory(
// Use output_paths (v2.1+ API) instead of deprecated output_files/output_directories
for output_path in &command.output_paths {
// Check if this path is a file first (more common case)
if let Some(output_file) = Self::extract_output_file(&output_trie, output_path)? {
// It's a file
digests.insert(require_digest(output_file.digest.as_ref())?);
action_result.output_files.push(output_file);
} else if let Some((tree, file_digests)) = Self::make_tree_for_output_directory(
&output_trie,
RelativePath::new(output_directory).unwrap(),
RelativePath::new(output_path).unwrap(),
)? {
Some(res) => res,
None => continue,
};

let tree_digest = crate::remote::store_proto_locally(&self.store, &tree).await?;
digests.insert(tree_digest);
digests.extend(file_digests);

action_result
.output_directories
.push(remexec::OutputDirectory {
path: output_directory.to_owned(),
tree_digest: Some(tree_digest.into()),
is_topologically_sorted: false,
});
}

for output_file_path in &command.output_files {
let output_file = match Self::extract_output_file(&output_trie, output_file_path)? {
Some(output_file) => output_file,
None => continue,
};

digests.insert(require_digest(output_file.digest.as_ref())?);
action_result.output_files.push(output_file);
// It's a directory
let tree_digest = crate::remote::store_proto_locally(&self.store, &tree).await?;
digests.insert(tree_digest);
digests.extend(file_digests);

action_result
.output_directories
.push(remexec::OutputDirectory {
path: output_path.to_owned(),
tree_digest: Some(tree_digest.into()),
is_topologically_sorted: false,
root_directory_digest: None,
});
}
// If neither file nor directory, skip (path doesn't exist in output)
}

Ok((action_result, digests.into_iter().collect::<Vec<_>>()))
Expand Down
18 changes: 9 additions & 9 deletions src/rust/process_execution/remote/src/remote_cache_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![allow(deprecated)]

use std::collections::{BTreeMap, HashSet};
use std::convert::TryInto;
use std::sync::Arc;
Expand Down Expand Up @@ -702,13 +704,11 @@ async fn extract_output_file() {
.is_none()
);

// Error if a path has been declared as a file but isn't.
assert_eq!(
crate::remote_cache::CommandRunner::extract_output_file(&input_tree.digest_trie(), "cats",),
Err(format!(
"Declared output file path \"cats\" in output digest {:?} contained a directory instead.",
TestDirectory::nested().digest()
))
// When a directory is encountered, return None so it can be handled as output_directories
assert!(
crate::remote_cache::CommandRunner::extract_output_file(&input_tree.digest_trie(), "cats",)
.unwrap()
.is_none()
);
}

Expand Down Expand Up @@ -792,8 +792,7 @@ async fn make_action_result_basic() {

let command = remexec::Command {
arguments: vec!["this is a test".into()],
output_files: vec!["pets/cats/roland.ext".into()],
output_directories: vec!["pets/cats".into()],
output_paths: vec!["pets/cats/roland.ext".into(), "pets/cats".into()],
..Default::default()
};

Expand Down Expand Up @@ -846,6 +845,7 @@ async fn make_action_result_basic() {
path: "pets/cats".to_owned(),
tree_digest: Some(TestTree::roland_at_root().digest().into()),
is_topologically_sorted: false,
root_directory_digest: None,
}
);

Expand Down
Loading