Skip to content

Commit c1cd9bb

Browse files
sagor999roboquat
authored andcommitted
[ws-daemon] fix restore from snapshot not working
1 parent 791163b commit c1cd9bb

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

components/content-service/pkg/storage/gcloud.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (rs *DirectGCPStorage) download(ctx context.Context, destination string, bk
192192

193193
rc, _, err := rs.ObjectAccess(ctx, bkt, obj)
194194
if rc == nil {
195-
return false, nil
195+
return false, err
196196
}
197197
defer rc.Close()
198198

components/content-service/pkg/storage/minio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (rs *DirectMinIOStorage) download(ctx context.Context, destination string,
205205

206206
rc, err := rs.ObjectAccess(ctx, bkt, obj)
207207
if rc == nil {
208-
return false, nil
208+
return false, err
209209
}
210210
defer rc.Close()
211211

components/ws-daemon/pkg/content/initializer.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,19 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora
7777
rc[storage.DefaultBackup] = *backup
7878
}
7979

80-
if si := initializer.GetSnapshot(); si != nil {
80+
si := initializer.GetSnapshot()
81+
pi := initializer.GetPrebuild()
82+
if ci := initializer.GetComposite(); ci != nil {
83+
for _, c := range ci.Initializer {
84+
if c.GetSnapshot() != nil {
85+
si = c.GetSnapshot()
86+
}
87+
if c.GetPrebuild() != nil {
88+
pi = c.GetPrebuild()
89+
}
90+
}
91+
}
92+
if si != nil {
8193
bkt, obj, err := storage.ParseSnapshotName(si.Snapshot)
8294
if err != nil {
8395
return nil, err
@@ -92,8 +104,8 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora
92104

93105
rc[si.Snapshot] = *info
94106
}
95-
if si := initializer.GetPrebuild(); si != nil && si.Prebuild != nil && si.Prebuild.Snapshot != "" {
96-
bkt, obj, err := storage.ParseSnapshotName(si.Prebuild.Snapshot)
107+
if pi != nil && pi.Prebuild != nil && pi.Prebuild.Snapshot != "" {
108+
bkt, obj, err := storage.ParseSnapshotName(pi.Prebuild.Snapshot)
97109
if err != nil {
98110
return nil, err
99111
}
@@ -103,7 +115,7 @@ func collectRemoteContent(ctx context.Context, rs storage.DirectAccess, ps stora
103115
} else if err != nil {
104116
return nil, xerrors.Errorf("cannot find prebuild: %w", err)
105117
} else {
106-
rc[si.Prebuild.Snapshot] = *info
118+
rc[pi.Prebuild.Snapshot] = *info
107119
}
108120
}
109121

0 commit comments

Comments
 (0)