Skip to content

Commit 18cfa5a

Browse files
committed
Merge branch '341-lost-snapshots' into 'master'
fix(engine): avoid losing the snapshot list on configuration reload (#341) Closes #341 See merge request postgres-ai/database-lab!506
2 parents d3ca0bb + db12a1d commit 18cfa5a

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

engine/internal/cloning/base.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ func (c *Base) Run(ctx context.Context) error {
7878
return errors.Wrap(err, "failed to run cloning service")
7979
}
8080

81-
c.provision.DiscoverSnapshots()
82-
8381
if _, err := c.GetSnapshots(); err != nil {
8482
log.Err("No available snapshots: ", err)
8583
}

engine/internal/provision/mode_local.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,6 @@ func (p *Provisioner) ResetSession(session *resources.Session, snapshotID string
298298
return snapshotModel, nil
299299
}
300300

301-
// DiscoverSnapshots discovers snapshots from active pools.
302-
func (p *Provisioner) DiscoverSnapshots() {
303-
for _, fsManager := range p.pm.GetAvailableFSManagers() {
304-
fsManager.RefreshSnapshotList()
305-
}
306-
}
307-
308301
// GetSnapshots provides a snapshot list from active pools.
309302
func (p *Provisioner) GetSnapshots() ([]resources.Snapshot, error) {
310303
snapshots := []resources.Snapshot{}

engine/internal/provision/pool/pool_manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ func (pm *Manager) examineEntries(entries []os.DirEntry) (map[string]FSManager,
333333
continue
334334
}
335335

336+
fsm.RefreshSnapshotList()
337+
336338
fsManagers[pool.Name] = fsm
337339

338340
front := poolList.Front()

engine/internal/provision/thinclones/zfs/zfs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,9 @@ func buildSizeCommand(snapshot string) string {
658658
func (m *Manager) listDetails(filter snapshotFilter) ([]*ListEntry, error) {
659659
// TODO(anatoly): Return map.
660660
// TODO(anatoly): Generalize.
661-
out, err := m.runner.Run(buildListCommand(filter), false)
661+
listCommand := buildListCommand(filter)
662+
663+
out, err := m.runner.Run(listCommand, false)
662664
if err != nil {
663665
return nil, errors.Wrap(err, "failed to list details")
664666
}
@@ -718,7 +720,7 @@ func (m *Manager) listDetails(filter snapshotFilter) ([]*ListEntry, error) {
718720

719721
if err := rule.setFunc(rule.field); err != nil {
720722
return nil, errors.Errorf("ZFS error: cannot parse output.\nCommand: %s.\nOutput: %s\nErr: %v",
721-
buildListCommand(filter), out, err)
723+
listCommand, out, err)
722724
}
723725
}
724726

engine/internal/srv/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ func (s *Server) InitHandlers() {
176176
r.HandleFunc("/clone/{id}", authMW.Authorized(s.patchClone)).Methods(http.MethodPatch)
177177
r.HandleFunc("/clone/{id}", authMW.Authorized(s.getClone)).Methods(http.MethodGet)
178178
r.HandleFunc("/clone/{id}/reset", authMW.Authorized(s.resetClone)).Methods(http.MethodPost)
179-
r.HandleFunc("/clone/{id}", authMW.Authorized(s.getClone)).Methods(http.MethodGet)
180179
r.HandleFunc("/observation/start", authMW.Authorized(s.startObservation)).Methods(http.MethodPost)
181180
r.HandleFunc("/observation/stop", authMW.Authorized(s.stopObservation)).Methods(http.MethodPost)
182181
r.HandleFunc("/observation/summary/{clone_id}/{session_id}", authMW.Authorized(s.sessionSummaryObservation)).Methods(http.MethodGet)

0 commit comments

Comments
 (0)