-
Notifications
You must be signed in to change notification settings - Fork 146
More reproducibility fixes / switch to canon-json #1347
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ use crate::sysroot::SysrootLock; | |
| use crate::utils::ResultExt; | ||
| use anyhow::{anyhow, Context}; | ||
| use camino::{Utf8Path, Utf8PathBuf}; | ||
| use canon_json::CanonJsonSerialize; | ||
| use cap_std_ext::cap_std; | ||
| use cap_std_ext::cap_std::fs::{Dir, MetadataExt}; | ||
| use cap_std_ext::cmdext::CapStdExtCommandExt; | ||
|
|
@@ -603,9 +604,13 @@ impl ImageImporter { | |
| Self::CACHED_KEY_MANIFEST_DIGEST, | ||
| manifest_digest.to_string(), | ||
| ); | ||
| let cached_manifest = serde_json::to_string(manifest).context("Serializing manifest")?; | ||
| let cached_manifest = manifest | ||
| .to_canon_json_string() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: this isn't a new problem, but we probably should have always been storing the original manifest instead of re-serializing. |
||
| .context("Serializing manifest")?; | ||
| commitmeta.insert(Self::CACHED_KEY_MANIFEST, cached_manifest); | ||
| let cached_config = serde_json::to_string(config).context("Serializing config")?; | ||
| let cached_config = config | ||
| .to_canon_json_string() | ||
| .context("Serializing config")?; | ||
| commitmeta.insert(Self::CACHED_KEY_CONFIG, cached_config); | ||
| let commitmeta = commitmeta.to_variant(); | ||
| // Clone these to move into blocking method | ||
|
|
@@ -1042,15 +1047,19 @@ impl ImageImporter { | |
| let _ = self.layer_byte_progress.take(); | ||
| let _ = self.layer_progress.take(); | ||
|
|
||
| let serialized_manifest = serde_json::to_string(&import.manifest)?; | ||
| let serialized_config = serde_json::to_string(&import.config)?; | ||
| let mut metadata = HashMap::new(); | ||
| metadata.insert( | ||
| META_MANIFEST_DIGEST, | ||
| import.manifest_digest.to_string().to_variant(), | ||
| ); | ||
| metadata.insert(META_MANIFEST, serialized_manifest.to_variant()); | ||
| metadata.insert(META_CONFIG, serialized_config.to_variant()); | ||
| metadata.insert( | ||
| META_MANIFEST, | ||
| import.manifest.to_canon_json_string()?.to_variant(), | ||
| ); | ||
| metadata.insert( | ||
| META_CONFIG, | ||
| import.config.to_canon_json_string()?.to_variant(), | ||
| ); | ||
| metadata.insert( | ||
| "ostree.importer.version", | ||
| env!("CARGO_PKG_VERSION").to_variant(), | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the progress stuff needs reproducibility, but I guess it doesn't hurt either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but ideally i would like to just ban
serde_json::to_{vec,string,writer}with some linter (haven't looked how to do it yet)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cgwalters ok to add those 3 functions to clippy disallowed-methods ? (in a follow up PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to it but not really excited by it either...it doesn't seem to me we will have that many places where we really need the reproducibility that we need to explicitly ban it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will leave it as is then