Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
57956ec9
Commit
57956ec9
authored
Oct 10, 2023
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master: if upstream unset, reject request to backup rather than crashing
parent
0fc95175
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
neo/master/app.py
neo/master/app.py
+8
-6
neo/master/handlers/administration.py
neo/master/handlers/administration.py
+2
-0
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+5
-0
No files found.
neo/master/app.py
View file @
57956ec9
...
@@ -59,6 +59,8 @@ class Application(BaseApplication):
...
@@ -59,6 +59,8 @@ class Application(BaseApplication):
backup_app
=
None
backup_app
=
None
truncate_tid
=
None
truncate_tid
=
None
no_upstream_msg
=
"No upstream cluster to backup defined in configuration"
def
setUUID
(
self
,
uuid
):
def
setUUID
(
self
,
uuid
):
node
=
self
.
nm
.
getByUUID
(
uuid
)
node
=
self
.
nm
.
getByUUID
(
uuid
)
if
node
is
not
self
.
_node
:
if
node
is
not
self
.
_node
:
...
@@ -171,10 +173,11 @@ class Application(BaseApplication):
...
@@ -171,10 +173,11 @@ class Application(BaseApplication):
def
run
(
self
):
def
run
(
self
):
try
:
try
:
self
.
_run
()
self
.
_run
()
except
Exception
:
except
BaseException
,
e
:
logging
.
exception
(
'Pre-mortem data:'
)
if
not
isinstance
(
e
,
SystemExit
)
or
e
.
code
:
self
.
log
()
logging
.
exception
(
'Pre-mortem data:'
)
logging
.
flush
()
self
.
log
()
logging
.
flush
()
raise
raise
def
_run
(
self
):
def
_run
(
self
):
...
@@ -309,8 +312,7 @@ class Application(BaseApplication):
...
@@ -309,8 +312,7 @@ class Application(BaseApplication):
# self.provideService only returns without raising
# self.provideService only returns without raising
# when switching to backup mode.
# when switching to backup mode.
if
self
.
backup_app
is
None
:
if
self
.
backup_app
is
None
:
raise
RuntimeError
(
"No upstream cluster to backup"
sys
.
exit
(
self
.
no_upstream_msg
)
" defined in configuration"
)
truncate
=
Packets
.
Truncate
(
truncate
=
Packets
.
Truncate
(
self
.
backup_app
.
provideService
())
self
.
backup_app
.
provideService
())
except
StoppedOperation
,
e
:
except
StoppedOperation
,
e
:
...
...
neo/master/handlers/administration.py
View file @
57956ec9
...
@@ -105,6 +105,8 @@ class AdministrationHandler(MasterHandler):
...
@@ -105,6 +105,8 @@ class AdministrationHandler(MasterHandler):
if
app
.
tm
.
hasPending
()
or
app
.
nm
.
getClientList
(
True
):
if
app
.
tm
.
hasPending
()
or
app
.
nm
.
getClientList
(
True
):
raise
AnswerDenied
(
"Can not switch to %s state with pending"
raise
AnswerDenied
(
"Can not switch to %s state with pending"
" transactions or connected clients"
%
state
)
" transactions or connected clients"
%
state
)
if
app
.
backup_app
is
None
:
raise
AnswerDenied
(
app
.
no_upstream_msg
)
conn
.
answer
(
Errors
.
Ack
(
'Cluster state changed'
))
conn
.
answer
(
Errors
.
Ack
(
'Cluster state changed'
))
if
state
!=
app
.
cluster_state
:
if
state
!=
app
.
cluster_state
:
...
...
neo/tests/threaded/test.py
View file @
57956ec9
...
@@ -2851,6 +2851,11 @@ class Test(NEOThreadedTest):
...
@@ -2851,6 +2851,11 @@ class Test(NEOThreadedTest):
with
self
.
expectedFailure
():
\
with
self
.
expectedFailure
():
\
self
.
assertFalse
(
s0m
.
isClosed
())
self
.
assertFalse
(
s0m
.
isClosed
())
@
with_cluster
()
def
testUnsetUpsteam
(
self
,
cluster
):
self
.
assertRaises
(
SystemExit
,
cluster
.
neoctl
.
setClusterState
,
ClusterStates
.
STARTING_BACKUP
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Write
Preview
Markdown
is supported
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