Skip to content

Commit

Permalink
Merge pull request #3556 from Xiol/issue-3554-abort-lease-on-failure
Browse files Browse the repository at this point in the history
fix: Abort lease on upload failure
  • Loading branch information
dougm authored Oct 21, 2024
2 parents 26e9cb4 + 36cac69 commit c0321f8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ovf/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (imp *Importer) Import(ctx context.Context, fpath string, opts Options) (*t

info, err := lease.Wait(ctx, spec.FileItem)
if err != nil {
_ = lease.Abort(ctx, nil)
return nil, err
}

Expand All @@ -169,6 +170,11 @@ func (imp *Importer) Import(ctx context.Context, fpath string, opts Options) (*t

for _, i := range info.Items {
if err := imp.Upload(ctx, lease, i); err != nil {
_ = lease.Abort(ctx, &types.LocalizedMethodFault{
Fault: &types.FileFault{
File: i.Path,
},
})
return nil, err
}
}
Expand Down

0 comments on commit c0321f8

Please sign in to comment.