fix9247: Protect VolumeSnapshot field

Signed-off-by: 0xLeo258 <noixe0312@gmail.com>
This commit is contained in:
0xLeo258
2025-09-11 14:45:39 +08:00
parent 1ec281a64e
commit f2a27c3864
2 changed files with 5 additions and 1 deletions

View File

@@ -699,6 +699,8 @@ func (ib *itemBackupper) takePVSnapshot(obj runtime.Unstructured, log logrus.Fie
snapshot.Status.Phase = volume.SnapshotPhaseCompleted
snapshot.Status.ProviderSnapshotID = snapshotID
}
ib.backupRequest.requestLock.Lock()
defer ib.backupRequest.requestLock.Unlock()
ib.backupRequest.VolumeSnapshots = append(ib.backupRequest.VolumeSnapshots, snapshot)
// nil errors are automatically removed

View File

@@ -17,6 +17,8 @@ limitations under the License.
package backup
import (
"sync"
"github.com/vmware-tanzu/velero/internal/hook"
"github.com/vmware-tanzu/velero/internal/resourcepolicies"
"github.com/vmware-tanzu/velero/internal/volume"
@@ -36,7 +38,7 @@ type itemKey struct {
// materialized (e.g. backup/snapshot locations, includes/excludes, etc.)
type Request struct {
*velerov1api.Backup
requestLock sync.Mutex
StorageLocation *velerov1api.BackupStorageLocation
SnapshotLocations []*velerov1api.VolumeSnapshotLocation
NamespaceIncludesExcludes *collections.IncludesExcludes