Skip to content

fix(aggregator): ancillary signing on evolving files #2425

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 5 commits into from
Apr 24, 2025

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Apr 18, 2025

Content

This PR make the aggregator copy the files that are included in an ancillary archive into a temporary folder so those files doesn't evolve while the snapshotting of ancillary is in progress, avoiding mismatch between sha of files in the ancillary manifest and the sha of files in the archive.

This PR also add a new test macro: assert_dir_eq! that allow comparison of two directories together or, more interestingly, against a string that codify the expected dir structure, i.e:

* folder 1/
** file 1
** file 2
* folder 2/
** file 3
* 100
* 20
* 300
* abc
* xyz

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • No new TODOs introduced

Issue(s)

Relates to #2362

@Alenar Alenar self-assigned this Apr 18, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes ancillary file signing during snapshotting by copying evolving files to a temporary directory and updates test assertions to use an enhanced directory structure comparison macro.

  • Introduces a new module (dir_eq) and macro (assert_dir_eq!) to compare directory structures in tests.
  • Updates tests across multiple modules to use the new assert_dir_eq! macro and replaces legacy temporary directory utilities with temp_dir_create!.
  • Adds functionality in the snapshotter to copy files to a temporary folder ensuring file consistency during ancillary signing.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

File Description
mithril-common/src/test_utils/mod.rs Added dir_eq module and re-export.
mithril-common/src/test_utils/dir_eq.rs Introduced DirStructure and assert_dir_eq! macro implementation.
mithril-client/* Replaced filesystem assertions with assert_dir_eq! in various tests.
mithril-aggregator/* Updated file archiver/appender and snapshotter tests to use assert_dir_eq! and refactored ancillary snapshot handling.
Comments suppressed due to low confidence (1)

mithril-aggregator/src/services/snapshotter/test_doubles.rs:320

  • The function name 'test_fake_snasphotter' appears to contain a typo. Consider renaming it to 'test_fake_snapshotter' for clarity.
async fn test_fake_snasphotter() {

@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from 49f8e90 to 45d73ba Compare April 18, 2025 07:48
Copy link

github-actions bot commented Apr 18, 2025

Test Results

    3 files  ± 0     57 suites  ±0   11m 42s ⏱️ +3s
1 867 tests +11  1 867 ✅ +11  0 💤 ±0  0 ❌ ±0 
2 329 runs  +11  2 329 ✅ +11  0 💤 ±0  0 ❌ ±0 

Results for commit 733e8bb. ± Comparison against base commit 03f079e.

♻️ This comment has been updated with latest results.

@Alenar Alenar temporarily deployed to testing-preview April 18, 2025 07:57 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from 45d73ba to 6e70001 Compare April 18, 2025 08:09
@Alenar Alenar temporarily deployed to testing-preview April 18, 2025 08:18 — with GitHub Actions Inactive
Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from 6e70001 to c504bad Compare April 18, 2025 09:54
@Alenar Alenar temporarily deployed to testing-preview April 18, 2025 10:03 — with GitHub Actions Inactive
Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch 3 times, most recently from 13b87bd to f872829 Compare April 18, 2025 15:07
Alenar added 5 commits April 24, 2025 09:59
- use `temp_dir_create!` when applicable
- remove uneeded intermediate variables
To avoid signing a manifest with files hashes that may be different from
the one in the archived files since they may be evolving between the two
operations.
Can be used against another directory or against a string that express
the expected structure using `*` to tell the depth of each items.
* mithril-aggregator from `0.7.34` to `0.7.35`
* mithril-client from `0.11.20` to `0.11.21`
* mithril-common from `0.5.22` to `0.5.23`
@Alenar Alenar force-pushed the djo/2362/fix-ancillary-signing-on-evolving-files branch from f872829 to 733e8bb Compare April 24, 2025 08:00
@Alenar Alenar temporarily deployed to testing-preview April 24, 2025 08:09 — with GitHub Actions Inactive
@Alenar Alenar merged commit 9c66ba2 into main Apr 24, 2025
38 of 39 checks passed
@Alenar Alenar deleted the djo/2362/fix-ancillary-signing-on-evolving-files branch April 24, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants