mononoke: log size of object in lfs validation

Summary: Its useful to know the size as well as the fact its LFS

Reviewed By: mitrandir77, farnz

Differential Revision: D26945223

fbshipit-source-id: 42787b983626ceecf822380e8ec6268646b3338f
This commit is contained in:
Alex Hornby 2021-03-10 06:49:22 -08:00 committed by Facebook GitHub Bot
parent b707609eb3
commit 44474c8d8a
2 changed files with 19 additions and 4 deletions

View File

@ -26,10 +26,10 @@ validate with LFS enabled, shallow
Check scuba data is logged for lfs and that it contains useful hg changeset and path in via_node_key and node_path. As its shallow walk expect all via_node_key to be the same
$ wc -l < scuba-validate-shallow.json
3
$ jq -r '.int * .normal | [ .check_fail, .check_type, .node_key, .node_path, .node_type, .repo, .src_node_type, .via_node_key, .via_node_type, .walk_type, .error_msg ] | @csv' < scuba-validate-shallow.json | sort
0,"file_content_is_lfs","content.blake2.55662471e2a28db8257939b2f9a2d24e65b46a758bac12914a58f17dcde6905f","B","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
0,"file_content_is_lfs","content.blake2.896ad5879a5df0403bfc93fc96507ad9c93b31b11f3d0fa05445da7918241e5d","C","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
0,"file_content_is_lfs","content.blake2.eb56488e97bb4cf5eb17f05357b80108a4a71f6c3bab52dfcaec07161d105ec9","A","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
$ jq -r '.int * .normal | [ .check_fail, .check_type, .check_size, .node_key, .node_path, .node_type, .repo, .src_node_type, .via_node_key, .via_node_type, .walk_type, .error_msg ] | @csv' < scuba-validate-shallow.json | sort
0,"file_content_is_lfs",1,"content.blake2.55662471e2a28db8257939b2f9a2d24e65b46a758bac12914a58f17dcde6905f","B","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
0,"file_content_is_lfs",1,"content.blake2.896ad5879a5df0403bfc93fc96507ad9c93b31b11f3d0fa05445da7918241e5d","C","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
0,"file_content_is_lfs",1,"content.blake2.eb56488e97bb4cf5eb17f05357b80108a4a71f6c3bab52dfcaec07161d105ec9","A","FileContentMetadata","repo","HgFileEnvelope","hgchangeset.sha1.26805aba1e600a82e93661149f2313866a221a7b","HgChangeset","validate",
Make a commit for a file in a subdir path
$ cd repo-hg

View File

@ -68,6 +68,7 @@ pub const NODE_PATH: &str = "node_path";
pub const EDGE_TYPE: &str = "edge_type";
pub const CHECK_TYPE: &str = "check_type";
pub const CHECK_FAIL: &str = "check_fail";
pub const CHECK_SIZE: &str = "check_size";
pub const WALK_TYPE: &str = "walk_type";
pub const REPO: &str = "repo";
pub const ERROR_MSG: &str = "error_msg";
@ -98,6 +99,8 @@ struct ValidateInfo {
via_node: Option<Node>,
// if the walk has extra path tracking enabled, this is the resolved path of the resolved node
resolved_path: Option<WrappedPath>,
// if the check wants to report a size
check_size: Option<u64>,
}
impl ValidateInfo {
@ -105,11 +108,13 @@ impl ValidateInfo {
source_node: Option<Node>,
via_node: Option<Node>,
resolved_path: Option<WrappedPath>,
check_size: Option<u64>,
) -> Self {
Self {
source_node,
via_node,
resolved_path,
check_size,
}
}
}
@ -260,12 +265,14 @@ fn check_bonsai_phase_is_public(
route.map(|r| r.src_node.clone()),
via,
None,
None,
))
}
_ => CheckStatus::Fail(ValidateInfo::new(
route.map(|r| r.src_node.clone()),
None,
None,
None,
)),
}
}
@ -294,6 +301,7 @@ fn check_linknode_populated(
route.map(|r| r.src_node.clone()),
via,
None,
None,
))
}
}
@ -327,6 +335,7 @@ fn check_file_content_is_lfs(
route.map(|r| r.src_node.clone()),
via,
resolved.path.clone(),
Some(content_meta.total_size),
));
CheckStatus::Pass(info)
}
@ -336,6 +345,7 @@ fn check_file_content_is_lfs(
route.map(|r| r.src_node.clone()),
None,
None,
None,
)),
}
}
@ -751,6 +761,11 @@ impl ProgressRecorderUnprotected<CheckData> for ValidateProgressState {
validate_info.resolved_path.as_ref(),
&mut scuba,
);
if let Some(check_size) = validate_info.check_size {
scuba.add(CHECK_SIZE, check_size);
}
scuba
.add(CHECK_TYPE, k.stats_key())
.add(CHECK_FAIL, check_fail)