Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-node
Commits
9bcbc99b
Commit
9bcbc99b
authored
13 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
various drbd changes
parent
009e5e45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ccnode/drbd.py
+22
-20
22 additions, 20 deletions
ccnode/drbd.py
ccnode/handlers.py
+13
-9
13 additions, 9 deletions
ccnode/handlers.py
ccnode/jobs.py
+12
-10
12 additions, 10 deletions
ccnode/jobs.py
with
47 additions
and
39 deletions
ccnode/drbd.py
+
22
−
20
View file @
9bcbc99b
...
...
@@ -124,19 +124,18 @@ class DRBD(object):
def
destroy
(
self
):
'''
'''
with
self
.
_mutex
.
write
:
# bring down drbd device
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
detach
'
])
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
down
'
])
# release device from the pool
self
.
_manager
.
_release_device
(
self
.
_minor
)
# suicide
self
.
_path
=
None
self
.
_minor
=
None
# bring down drbd device
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
detach
'
])
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
down
'
])
# release device from the pool
self
.
_manager
.
_release_device
(
self
.
_minor
)
# suicide
self
.
_path
=
None
self
.
_minor
=
None
def
get_minor
(
self
):
'''
...
...
@@ -179,6 +178,10 @@ class DRBD(object):
status
[
'
rdisk
'
]
=
self
.
DSTATES
.
get
(
xres
.
getAttribute
(
'
ds2
'
))
status
[
'
role
'
]
=
self
.
NROLES
.
get
(
xres
.
getAttribute
(
'
ro1
'
))
status
[
'
rrole
'
]
=
self
.
NROLES
.
get
(
xres
.
getAttribute
(
'
ro2
'
))
if
xres
.
hasAttribute
(
'
resynced_percent
'
):
status
[
'
percent
'
]
=
xres
.
getAttribute
(
'
resynced_percent
'
)
else
:
status
[
'
percent
'
]
=
None
return
status
except
Exception
as
err
:
return
{
'
conn
'
:
None
}
...
...
@@ -258,11 +261,10 @@ class DRBD(object):
def
disconnect
(
self
):
'''
'''
with
self
.
_mutex
.
write
:
# disconnect from remote node
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
disconnect
'
])
# disconnect from remote node
Exec
.
silent
([
self
.
DRBDSETUP
,
self
.
_path
,
'
disconnect
'
])
def
primary
(
self
):
'''
...
...
@@ -321,7 +323,7 @@ class DRBD(object):
# FIXME magic sleep, seems to be mandatory
sleep
(
0.5
)
status
=
self
.
status
()
print
status
,
self
.
DSTATES
.
UP_TO_DATE_str
if
(
rc
!=
0
or
not
status
or
status
[
'
disk
'
]
!=
self
.
DSTATES
.
UP_TO_DATE
):
(
'
disk
'
in
status
and
status
[
'
disk
'
]
!=
self
.
DSTATES
.
UP_TO_DATE
)):
raise
DRBDError
(
'
synchronization failed
'
)
This diff is collapsed.
Click to expand it.
ccnode/handlers.py
+
13
−
9
View file @
9bcbc99b
...
...
@@ -946,17 +946,22 @@ class NodeHandler(RpcHandler):
job
.
drbd_takeover
(
state
)
@pure
def
drbd_sync
(
self
,
res
):
def
drbd_sync
_status
(
self
,
res
):
'''
Wait for the live copy engine to complete a pending initial disk
synchronization.
Get status information about a running sync
'''
# facilities
jobmgr
=
self
.
_host_handle
.
jobmgr
# get the job
job
=
jobmgr
.
get_job
(
res
[
'
jid
'
])
# wait for sync completion
job
.
drbd_waitsync
()
# get drbd status
status
=
job
.
drbd_status
()
# return status
return
{
'
done
'
:
status
[
'
disk
'
]
==
job
.
_drbd
.
DSTATES
.
UP_TO_DATE
,
'
completion
'
:
status
[
'
percent
'
],
'
speed
'
:
None
,
}
@pure
def
drbd_shutdown
(
self
,
res
):
...
...
@@ -965,10 +970,9 @@ class NodeHandler(RpcHandler):
'''
# facilities
jobmgr
=
self
.
_host_handle
.
jobmgr
# get the job
job
=
jobmgr
.
get_job
(
res
[
'
jid
'
])
# FIXME
job
.
drbd_stop
()
# cancel the job so it can clean itself
# FIXME: check type, we don't want to cancel anything
jobmgr
.
cancel
(
res
[
'
jid
'
])
##################################
# Job management
...
...
This diff is collapsed.
Click to expand it.
ccnode/jobs.py
+
12
−
10
View file @
9bcbc99b
...
...
@@ -610,8 +610,14 @@ class DrbdCopyJob(BaseJob):
'''
'''
# release some pending calls
self
.
_event_connected_ready
.
set
()
self
.
_event_connected
.
set
()
self
.
_event_rolechosen_ready
.
set
()
self
.
_event_rolechosen
.
set
()
self
.
_event_sleep_ready
.
set
()
self
.
_event_sleep
.
set
()
# disconnect the node
self
.
_drbd
.
disconnect
()
def
_cleanup
(
self
):
'''
...
...
@@ -731,7 +737,7 @@ class DrbdCopyJob(BaseJob):
self
.
_drbd
.
get_path
())
self
.
_drbd
.
setup
(
self
.
_copy_path
,
self
.
_meta_path
)
self
.
_drbd_table
=
'
0 %d linear %s 0
'
%
(
self
.
_source_size
/
512
,
self
.
_
source
_path
)
,
self
.
_
drbd
.
get
_path
()
)
except
Exception
as
err
:
self
.
_log
.
append
(
'
failed to configure the drbd device
'
)
raise
err
...
...
@@ -772,6 +778,8 @@ class DrbdCopyJob(BaseJob):
self
.
_log
.
append
(
'
waiting for initial device sync
'
)
self
.
_drbd
.
wait_sync
()
except
Exception
as
err
:
import
traceback
traceback
.
print_exc
()
self
.
_log
.
append
(
'
failed to sync the DRBD
'
)
raise
err
else
:
...
...
@@ -828,7 +836,7 @@ class DrbdCopyJob(BaseJob):
self
.
_log
.
append
(
'
waiting for sync
'
)
# wait for initial sync and setup to be completed
self
.
_event_sleep_ready
.
wait
()
# wait for DRBD sync
# wait for
additionnal
DRBD sync
with
self
.
_mutex_step
:
self
.
_drbd
.
wait_sync
()
...
...
@@ -849,16 +857,10 @@ class DrbdCopyJob(BaseJob):
#
self
.
_lvm
.
dm_set_table
(
self
.
_source_dm
,
table
)
def
drbd_st
op
(
self
):
def
drbd_st
atus
(
self
):
'''
'''
self
.
_event_sleep_ready
.
wait
(
5
)
# to fix thread sync issue
if
self
.
_event_sleep_ready
.
is_set
():
with
self
.
_mutex_step
:
# unlock job termination
self
.
_event_sleep
.
set
()
else
:
raise
DrbdCopyJobError
(
'
can
\'
t stop now
'
)
return
self
.
_drbd
.
status
()
class
TCPTunnelJob
(
BaseJob
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment