Skip to content

Conversation

@redgoat650
Copy link
Contributor

@redgoat650 redgoat650 commented Jun 2, 2025

  • Add read stats to snapshot verifier output.

  • Add periodic JSON progress output.

  • Refactor the use of directory summary.

  • Use stats mutex for all stats.

  • Add processedBytes to the snapshot verify output.

  • Output more frequently, when bytes processed changes.

  • Change depends on feat(snapshots): Add JSON output flag for snapshot verify #4644; full diff includes both changes until that PR merges. Please see commit c59be0f for changes introduced by this PR.

@codecov
Copy link

codecov bot commented Jun 2, 2025

Codecov Report

Attention: Patch coverage is 86.36364% with 18 lines in your changes missing coverage. Please review.

Project coverage is 76.44%. Comparing base (cb455c6) to head (a9ece98).
Report is 583 commits behind head on master.

Files with missing lines Patch % Lines
cli/command_snapshot_verify.go 75.60% 7 Missing and 3 partials ⚠️
snapshot/snapshotfs/snapshot_verifier.go 91.11% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4645      +/-   ##
==========================================
+ Coverage   75.86%   76.44%   +0.57%     
==========================================
  Files         470      530      +60     
  Lines       37301    40363    +3062     
==========================================
+ Hits        28299    30856    +2557     
- Misses       7071     7476     +405     
- Partials     1931     2031     +100     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jkowalski jkowalski requested a review from Copilot June 7, 2025 18:56
Copy link

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

Adds periodic JSON progress output to the snapshot verifier, enhances stats tracking, and updates CLI commands and tests to use the new VerifierResult pattern.

  • Extended Verifier to track bytes, files, and expected totals, with JSON and periodic logging.
  • Refactored InParallel to return VerifierResult including stats and error lists.
  • Updated CLI (snapshot verify) to support --json output and to seed expected totals from directory summaries.
  • Modified tests to assert on the new result structure and JSON fields.

Reviewed Changes

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

Show a summary per file
File Description
snapshot/snapshotfs/snapshot_verifier.go Added mutex-protected stats, JSONStats flag, VerifierStats struct, JSON output, and updated InParallel.
snapshot/snapshotfs/snapshot_verifier_test.go Updated tests to unpack (VerifierResult, error) and assert on stats and errors.
snapshot/snapshotfs/snapshot_tree_walker.go Added GetErrors() to expose accumulated errors and counts.
cli/command_snapshot_verify.go Introduced --json flag, JSON output handling, and expected-totals seeding.
cli/command_snapshot_verify_test.go New tests verifying JSON output of snapshot verify.
cli/command_snapshot_fix_invalid_files.go Adjusted VerifyFile calls to the new signature including file size.
Comments suppressed due to low confidence (2)

snapshot/snapshotfs/snapshot_verifier.go:130

  • [nitpick] The JSON tag for ExpectedTotalFiles is expectedTotalFileCount (singular "File"), but ExpectedTotalBytes uses expectedTotalBytes (plural); consider unifying the naming convention for consistency across stats fields.
ExpectedTotalFiles   int64 `json:"expectedTotalFileCount"`

cli/command_snapshot_verify_test.go:87

  • Tests validate processed counts and errors but do not assert on the new expected-totals (ExpectedTotalObjects, ExpectedTotalFiles, ExpectedTotalBytes). Consider adding assertions to cover these fields in the JSON output.
result := unmarshalSnapVerify(t, stdout[0])

statsMu sync.RWMutex

// +checklocks:statsMu
queued int32
Copy link

Copilot AI Jun 7, 2025

Choose a reason for hiding this comment

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

The field queued is incremented but never used in any stats output or logic; consider removing it or exposing it in the JSON stats if it's needed for progress reporting.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@redgoat650 as a followup, either:

  • include queued in the (JSON) stats; or
  • remove queued altogether, as it is only written to, not read.

The former may make sense now that the JSON stats are reported.

- Add read stats to snapshot verifier output
- Add periodic JSON progress output.
- Refactor the use of directory summary.
- Use stats mutex for all stats.
- Add processedBytes to the snapshot verify output
- Output more frequently, when bytes processed changes
@julio-lopez julio-lopez force-pushed the snap-verify-progress-output branch from 06a9099 to a9ece98 Compare June 24, 2025 20:32
Comment on lines +176 to +179
// addExpectedWorkFromDirSummaryToVerifier initializes the snapshot verifier with an
// expected amount of work that will take place during the tree walk for this Entry.
// If the entry is not a DirectoryWithSummary, or the Summary returns nil, no stats
// will be added to the totals.
Copy link
Collaborator

@julio-lopez julio-lopez Jun 23, 2025

Choose a reason for hiding this comment

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

@redgoat650
Concern: this may silently distort the expected numbers, and thus the expectations.
Also, it may create confusion when displaying (JSON) results where the verified number of files / bytes is greater than the expected values.

statsMu sync.RWMutex

// +checklocks:statsMu
queued int32
Copy link
Collaborator

Choose a reason for hiding this comment

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

@redgoat650 as a followup, either:

  • include queued in the (JSON) stats; or
  • remove queued altogether, as it is only written to, not read.

The former may make sense now that the JSON stats are reported.

@julio-lopez julio-lopez enabled auto-merge (squash) June 24, 2025 20:38
@julio-lopez julio-lopez disabled auto-merge June 24, 2025 22:14
@julio-lopez julio-lopez merged commit ed304e6 into kopia:master Jun 24, 2025
33 of 34 checks passed
@julio-lopez julio-lopez deleted the snap-verify-progress-output branch June 24, 2025 22:16
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.

2 participants