| 32 | } |
| 33 | |
| 34 | func (ei *EngineInstance) format(ctx context.Context) error { |
| 35 | idx := ei.Index() |
| 36 | |
| 37 | ei.log.Debugf("instance %d: checking if storage is formatted", idx) |
| 38 | if err := ei.awaitStorageReady(ctx); err != nil { |
| 39 | return errors.Wrap(err, "awaitStorageReady") |
| 40 | } |
| 41 | if err := ei.createSuperblock(); err != nil { |
| 42 | return errors.Wrap(err, "createSuperblock") |
| 43 | } |
| 44 | |
| 45 | if !ei.hasSuperblock() { |
| 46 | return errors.Errorf("instance %d: no superblock after format", idx) |
| 47 | } |
| 48 | |
| 49 | // After we know that the instance storage is ready, fire off |
| 50 | // any callbacks that were waiting for this state. |
| 51 | for _, readyFn := range ei.onStorageReady { |
| 52 | if err := readyFn(ctx); err != nil { |
| 53 | return errors.Wrap(err, "onStorageReady readyFn") |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | func (ei *EngineInstance) initIncarnationFromSuperblock() error { |
| 61 | if ei.incarnation > 0 { |