Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use librbd for rbd management in ceph-integration #273

Closed
wants to merge 3 commits into from

Conversation

GowthamShanmugam
Copy link

tendrl-bug-id: #150

Signed-off-by: GowthamShanmugam [email protected]

@GowthamShanmugam
Copy link
Author

@r0h4n @shtripat @nthomas-redhat please review

@GowthamShanmugam
Copy link
Author

verified

try:
if operation == "create":
rbd_inst = rbd.RBD()
rbd_inst.create(ioctx, attr["name"], int(attr["size"]))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here RBD creation function takes size as byte so from UI they have to pass rbd size in bytes
e.g
for 1gb they have to pass like 1073741824 bytes

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GowthamShanmugam you should mention the UI folks if there's some assumption like above

cc: @Tendrl/tendrl_frontend

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GowthamShanmugam you can convert the size to bytes in backend wherever rbd_operation is called.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will convert this

Copy link

@r0h4n r0h4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve merge conflicts

@GowthamShanmugam
Copy link
Author

@r0h4n solved

@@ -10,11 +10,15 @@
import sys
import tempfile
import time
import rbd
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python rbd needs to be added to dependencies?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm yes

try:
if operation == "create":
rbd_inst = rbd.RBD()
rbd_inst.create(ioctx, attr["name"], int(attr["size"]))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GowthamShanmugam you can convert the size to bytes in backend wherever rbd_operation is called.

command_args
def rbd_operation(cluster_name, operation, attr, pool_name, result, queue):
import rados
cluster = rados.Rados(name=RADOS_NAME,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all rados.Rados() calls, use this file for reference

https://github.com/ceph/calamari/blob/v1.5.6/calamari-common/calamari_common/remote/mon_remote.py#L77

using above way you can simply do "with ClusterHandle(cluster_name) as cluster_handle"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

try:
ioctx = cluster.open_ioctx(pool_name)
try:
if operation == "create":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you implementing Create, Delete, Update as part of this issue?

cc: @shtripat

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we have to call a particular function
create have separate rbdlib func
update have separate function

image.close()
if operation == "usage":
args = "du --image %s" % attr['name']
cmd_args = "rbd --pool %s --cluster %s " % (pool_name, cluster_name) + \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant get this data from librbd? why are you using the rbd command again

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this is because i have checked all librbd func so no function si giving used detail so i have discussed this with @shtripat also so only used value i am using this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do we really need a usage operation here? In sds_sync we are already having logic to figure this.
Lets keep CRUD only to use librbd. Utilization still would be using command in sds_sync.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I would like lib_rbd stuff to be inside a separate source say librbd_utils.py and invoke function from ceph.py

result['out'] = ''
# Exchanging objects between processes
queue = multiprocessing.Queue()
p = multiprocessing.Process(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need a multiprocessing?

use http://www.gevent.org/gevent.queue.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will change that to gevent, multiprocessing timout is works like it wait unit process finish if the process finished before the specified time it automatically stops wait and executes further. that why i used this.
any way i will changed to gevent


finally:
cluster.shutdown()
queue.put(result)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this even gonna work? where have you declared the "queue" variable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will work def rbd_operation(cluster_name, operation, attr, pool_name, result, queue):

queue is used to Exchanging objects between processes
from multiprocessing import Queue

@@ -0,0 +1,106 @@
import multiprocessing
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r0h4n i have tried with gevent, problem with gevent is when cluster goes to error state then all librbd function call are not responding so i tried to timeout that function using gevent but gevent can't time out that subprocess. Because gevent required gevent.sleep in sub process function but librbd is built in library so we can't use it. i have tried all the option using gevent but it is not work for this case. Multi-process can timeout the the subprocess in this case.

def rbd_operation(cluster_name, attributes):
err = None
p = None
queue = multiprocessing.Queue()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r0h4n i am using multiprocessing for sub-process so i used multiprocessing queue


attributes = {}
attributes['pool_name'] = self._resolve_pool(pool_id)['pool_name']
attributes['operation'] = 'delete'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributes['operation'] = 'delete' to call specific function in librbd_util.py

@@ -164,8 +164,8 @@ namespace.ceph:
mandatory:
- Rbd.name
- Rbd.size
optional:
- Rbd.pool_id
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rbd.pool_id is must because librbd requires pool_name compulsory, so if we pass pool_id then only pool_name is identified and passed.

import multiprocessing
import os
import rados
import rbd
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r0h4n ceph already have rbd as dependency

@GowthamShanmugam
Copy link
Author

@shtripat @r0h4n please review

@r0h4n r0h4n closed this Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants