storageMigrationActive checks and warns against in-progress storage migrations. This function will block until storage is available.
(backend physical.Backend)
| 2405 | // storageMigrationActive checks and warns against in-progress storage migrations. |
| 2406 | // This function will block until storage is available. |
| 2407 | func (c *ServerCommand) storageMigrationActive(backend physical.Backend) bool { |
| 2408 | first := true |
| 2409 | |
| 2410 | for { |
| 2411 | migrationStatus, err := CheckStorageMigration(backend) |
| 2412 | if err == nil { |
| 2413 | if migrationStatus != nil { |
| 2414 | startTime := migrationStatus.Start.Format(time.RFC3339) |
| 2415 | c.UI.Error(wrapAtLength(fmt.Sprintf("ERROR! Storage migration in progress (started: %s). "+ |
| 2416 | "Server startup is prevented until the migration completes. Use 'vault operator migrate -reset' "+ |
| 2417 | "to force clear the migration lock.", startTime))) |
| 2418 | return true |
| 2419 | } |
| 2420 | return false |
| 2421 | } |
| 2422 | if first { |
| 2423 | first = false |
| 2424 | c.UI.Warn("\nWARNING! Unable to read storage migration status.") |
| 2425 | |
| 2426 | // unexpected state, so stop buffering log messages |
| 2427 | c.flushLog() |
| 2428 | } |
| 2429 | c.logger.Warn("storage migration check error", "error", err.Error()) |
| 2430 | |
| 2431 | timer := time.NewTimer(2 * time.Second) |
| 2432 | select { |
| 2433 | case <-timer.C: |
| 2434 | case <-c.ShutdownCh: |
| 2435 | timer.Stop() |
| 2436 | return true |
| 2437 | } |
| 2438 | } |
| 2439 | } |
| 2440 | |
| 2441 | type StorageMigrationStatus struct { |
| 2442 | Start time.Time `json:"start"` |
no test coverage detected