Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@blackpiglet
Copy link
Contributor

@blackpiglet blackpiglet commented Jul 17, 2025

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

@codecov
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 59.07%. Comparing base (768c342) to head (a61a073).

Files with missing lines Patch % Lines
pkg/util/csi/volume_snapshot.go 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9092      +/-   ##
==========================================
+ Coverage   59.04%   59.07%   +0.02%     
==========================================
  Files         379      379              
  Lines       43509    43511       +2     
==========================================
+ Hits        25690    25702      +12     
+ Misses      16290    16281       -9     
+ Partials     1529     1528       -1     

☔ 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.

@blackpiglet blackpiglet marked this pull request as ready for review July 18, 2025 05:19
@kaovilai
Copy link
Collaborator

Thanks for this optimization! The refactoring to avoid unnecessary VSC lookups during the finalizing phase makes sense and improves efficiency.

I noticed the patch coverage is currently at 50%, with the new finalizing phase logic in volumesnapshot_action.go having only 11.11% coverage. Looking at the existing tests, TestVSExecute only covers BackupPhaseInProgress but not the finalizing phases.

Would it be possible to add test cases for the new code path? Something like:

// Add to TestVSExecute in volumesnapshot_action_test.go
{
    name: "Backup in finalizing phase - skip VSC lookup",
    backup: builder.ForBackup("velero", "backup").
        Phase(velerov1api.BackupPhaseFinalizing).Result(),
    vs: builder.ForVolumeSnapshot("velero", "vs").
        ObjectMeta(builder.WithLabels(
            velerov1api.BackupNameLabel, "backup")).
        Status().
        BoundVolumeSnapshotContentName("vsc").Result(),
    vsc:                     nil, // VSC won't be created/fetched
    expectedErr:             "",
    expectedAdditionalItems: nil,
    expectedItemToUpdate:    nil,
},
{
    name: "Backup in finalizing partially failed phase - skip VSC lookup",
    backup: builder.ForBackup("velero", "backup").
        Phase(velerov1api.BackupPhaseFinalizingPartiallyFailed).Result(),
    vs: builder.ForVolumeSnapshot("velero", "vs").
        ObjectMeta(builder.WithLabels(
            velerov1api.BackupNameLabel, "backup")).
        Status().
        BoundVolumeSnapshotContentName("vsc").Result(),
    vsc:                     nil, // VSC won't be created/fetched
    expectedErr:             "",
    expectedAdditionalItems: nil,
    expectedItemToUpdate:    nil,
},

This would verify the early return path and ensure DeleteReadyVolumeSnapshot is called without attempting to fetch the VSC, which should bring the coverage up significantly.

@ywk253100 ywk253100 added this to the v1.17 milestone Jul 21, 2025
Lyndon-Li
Lyndon-Li previously approved these changes Jul 21, 2025
@blackpiglet
Copy link
Contributor Author

@kaovilai
Thanks for the suggestion.
I added the UT cases according to the comments. PTAL.

@blackpiglet blackpiglet merged commit ddb3e3d into vmware-tanzu:main Jul 24, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants