Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Vault
Commits
3d1f6e6f
Unverified
Commit
3d1f6e6f
authored
6 years ago
by
Jim Kalafut
Committed by
GitHub
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Retry failing migration check instead of exiting (#5427)
parent
0e5c2c39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
command/server.go
+37
-10
command/server.go
with
37 additions
and
10 deletions
+37
-10
command/server.go
+
37
-
10
View file @
3d1f6e6f
...
...
@@ -463,16 +463,8 @@ func (c *ServerCommand) Run(args []string) int {
return
1
}
migrationStatus
,
err
:=
CheckMigration
(
backend
)
if
err
!=
nil
{
c
.
UI
.
Error
(
"Error checking migration status"
)
return
1
}
if
migrationStatus
!=
nil
{
startTime
:=
migrationStatus
.
Start
.
Format
(
time
.
RFC3339
)
c
.
UI
.
Error
(
wrapAtLength
(
fmt
.
Sprintf
(
"Storage migration in progress (started: %s). "
+
"Use 'vault operator migrate -reset' to force clear the migration lock."
,
startTime
)))
// Prevent server startup if migration is active
if
c
.
migrationActive
(
backend
)
{
return
1
}
...
...
@@ -1789,6 +1781,41 @@ func (c *ServerCommand) removePidFile(pidPath string) error {
return
os
.
Remove
(
pidPath
)
}
// migrationActive checks and warns against in-progress storage migrations.
// This function will block until storage is available.
func
(
c
*
ServerCommand
)
migrationActive
(
backend
physical
.
Backend
)
bool
{
first
:=
true
for
{
migrationStatus
,
err
:=
CheckMigration
(
backend
)
if
err
==
nil
{
if
migrationStatus
!=
nil
{
startTime
:=
migrationStatus
.
Start
.
Format
(
time
.
RFC3339
)
c
.
UI
.
Error
(
wrapAtLength
(
fmt
.
Sprintf
(
"ERROR! Storage migration in progress (started: %s). "
+
"Server startup is prevented until the migration completes. Use 'vault operator migrate -reset' "
+
"to force clear the migration lock."
,
startTime
)))
return
true
}
return
false
}
if
first
{
first
=
false
c
.
UI
.
Warn
(
"
\n
WARNING! Unable to read migration status."
)
// unexpected state, so stop buffering log messages
c
.
logGate
.
Flush
()
}
c
.
logger
.
Warn
(
"migration_check: "
+
err
.
Error
())
select
{
case
<-
time
.
After
(
2
*
time
.
Second
)
:
case
<-
c
.
ShutdownCh
:
return
true
}
}
return
false
}
type
MigrationStatus
struct
{
Start
time
.
Time
`json:"start"`
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help