MCPcopy
hub / github.com/hashicorp/vault / storageMigrationActive

Method storageMigrationActive

command/server.go:2407–2439  ·  view source on GitHub ↗

storageMigrationActive checks and warns against in-progress storage migrations. This function will block until storage is available.

(backend physical.Backend)

Source from the content-addressed store, hash-verified

2405// storageMigrationActive checks and warns against in-progress storage migrations.
2406// This function will block until storage is available.
2407func (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
2441type StorageMigrationStatus struct {
2442 Start time.Time `json:"start"`

Callers 1

RunMethod · 0.95

Calls 8

flushLogMethod · 0.95
CheckStorageMigrationFunction · 0.85
wrapAtLengthFunction · 0.85
FormatMethod · 0.65
ErrorMethod · 0.65
WarnMethod · 0.65
NewTimerMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected