Skip to content

[ws-daemon] fix restore from snapshot not working #9943

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 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/content-service/pkg/storage/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (rs *DirectGCPStorage) download(ctx context.Context, destination string, bk

rc, _, err := rs.ObjectAccess(ctx, bkt, obj)
if rc == nil {
return false, nil
return false, err
}
defer rc.Close()

Expand Down
2 changes: 1 addition & 1 deletion components/content-service/pkg/storage/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (rs *DirectMinIOStorage) download(ctx context.Context, destination string,

rc, err := rs.ObjectAccess(ctx, bkt, obj)
if rc == nil {
return false, nil
return false, err
}
defer rc.Close()

Expand Down
20 changes: 16 additions & 4 deletions components/ws-daemon/pkg/content/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora
rc[storage.DefaultBackup] = *backup
}

if si := initializer.GetSnapshot(); si != nil {
si := initializer.GetSnapshot()
pi := initializer.GetPrebuild()
if ci := initializer.GetComposite(); ci != nil {
for _, c := range ci.Initializer {
if c.GetSnapshot() != nil {
si = c.GetSnapshot()
}
if c.GetPrebuild() != nil {
pi = c.GetPrebuild()
}
}
}
if si != nil {
bkt, obj, err := storage.ParseSnapshotName(si.Snapshot)
if err != nil {
return nil, err
Expand All @@ -92,8 +104,8 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora

rc[si.Snapshot] = *info
}
if si := initializer.GetPrebuild(); si != nil && si.Prebuild != nil && si.Prebuild.Snapshot != "" {
bkt, obj, err := storage.ParseSnapshotName(si.Prebuild.Snapshot)
if pi != nil && pi.Prebuild != nil && pi.Prebuild.Snapshot != "" {
bkt, obj, err := storage.ParseSnapshotName(pi.Prebuild.Snapshot)
if err != nil {
return nil, err
}
Expand All @@ -103,7 +115,7 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora
} else if err != nil {
return nil, xerrors.Errorf("cannot find prebuild: %w", err)
} else {
rc[si.Prebuild.Snapshot] = *info
rc[pi.Prebuild.Snapshot] = *info
}
}

Expand Down