add additional pre-migration validations

This commit is contained in:
Steven Allen 2021-01-27 12:24:48 -08:00
parent 716f10e570
commit 854385168d

View File

@ -199,10 +199,18 @@ func (us UpgradeSchedule) Validate() error {
}
for _, m := range u.PreMigrations {
if m.When < 0 || m.NotAfter < 0 {
return xerrors.Errorf("pre-migration must specify non-negative epochs")
}
if m.When <= m.NotAfter {
return xerrors.Errorf("pre-migration cannot end before it starts: %d <= %d", m.When, m.NotAfter)
}
}
if !sort.SliceIsSorted(u.PreMigrations, func(i, j int) bool {
return u.PreMigrations[i].When < u.PreMigrations[j].When
}) {
return xerrors.Errorf("pre-migrations must be sorted by start epoch")
}
}
// Make sure the upgrade order makes sense.