Skip to content

Commit 64575c0

Browse files
autopilot: address comments
1 parent 86a2bc2 commit 64575c0

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

autopilot/alerts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ func newRefreshHealthFailedAlert(err error) alerts.Alert {
170170
Severity: alerts.SeverityCritical,
171171
Message: "Health refresh failed",
172172
Data: map[string]interface{}{
173-
"migrationsInterrupted": false,
174-
"error": err.Error(),
173+
"error": err.Error(),
175174
},
176175
Timestamp: time.Now(),
177176
}

autopilot/migrator.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -206,28 +206,20 @@ func (m *migrator) performMigrations(p *workerPool) {
206206
default:
207207
}
208208

209-
OUTER:
210-
for {
211-
// fetch currently configured set
212-
autopilot, err := m.ap.Config(m.ap.shutdownCtx)
213-
if err != nil {
214-
m.logger.Errorf("failed to fetch autopilot config: %w", err)
215-
return
216-
}
217-
set := autopilot.Config.Contracts.Set
218-
if set == "" {
219-
m.logger.Error("could not perform migrations, no contract set configured")
220-
return
221-
}
222-
223-
// recompute health.
224-
start := time.Now()
225-
if err := b.RefreshHealth(m.ap.shutdownCtx); err != nil {
226-
m.ap.RegisterAlert(m.ap.shutdownCtx, newRefreshHealthFailedAlert(err))
227-
m.logger.Errorf("failed to recompute cached health before migration: %v", err)
228-
}
229-
m.logger.Infof("recomputed slab health in %v", time.Since(start))
209+
// fetch currently configured set
210+
autopilot, err := m.ap.Config(m.ap.shutdownCtx)
211+
if err != nil {
212+
m.logger.Errorf("failed to fetch autopilot config: %w", err)
213+
return
214+
}
215+
set := autopilot.Config.Contracts.Set
216+
if set == "" {
217+
m.logger.Error("could not perform migrations, no contract set configured")
218+
return
219+
}
230220

221+
// helper to update 'toMigrate'
222+
updateToMigrate := func() {
231223
// fetch slabs for migration
232224
toMigrateNew, err := b.SlabsForMigration(m.ap.shutdownCtx, m.healthCutoff, set, migratorBatchSize)
233225
if err != nil {
@@ -266,7 +258,19 @@ OUTER:
266258
sort.Slice(newSlabs, func(i, j int) bool {
267259
return newSlabs[i].Health < newSlabs[j].Health
268260
})
269-
migrateNewMap = nil // free map
261+
}
262+
263+
OUTER:
264+
for {
265+
// recompute health.
266+
start := time.Now()
267+
if err := b.RefreshHealth(m.ap.shutdownCtx); err != nil {
268+
m.ap.RegisterAlert(m.ap.shutdownCtx, newRefreshHealthFailedAlert(err))
269+
m.logger.Errorf("failed to recompute cached health before migration: %v", err)
270+
} else {
271+
m.logger.Infof("recomputed slab health in %v", time.Since(start))
272+
updateToMigrate()
273+
}
270274

271275
// log the updated list of slabs to migrate
272276
m.logger.Infof("%d slabs to migrate", len(toMigrate))

0 commit comments

Comments
 (0)