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

common: fix for broken rbdmap parameter parsing #24446

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@scoopex
Contributor

scoopex commented Oct 5, 2018

This improves the broken parameter parsing discussed in #36327
(https://tracker.ceph.com/issues/36327)

Test expression for the parsing function:

    PARAMS="options='lock_on_read,queue_depth=1024',id=archiv,keyring=/etc/ceph/ceph.client.archiv.keyring"
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
    
    PARAMS="id=archiv,keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024'"
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
    
    PARAMS=""
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
    
    PARAMS=",keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv,"
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
    
    PARAMS="'keyring'=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv,"
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
    
    PARAMS="--keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv, # a comment"
    echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"
@@ -14,16 +61,12 @@ do_map() {
DEV=rbd/$DEV
;;
esac
CMDPARAMS="$(create_cmd_params "${PARAMS}")"

This comment has been minimized.

@dillaman

dillaman Oct 5, 2018

Contributor

Perhaps an alternative is just something like $(echo ${PARAMS} | sed -E "s/([^ =,]+)[ =]+('[^']+'|\"[^\"]+\"|[^,]+),?/ --\1 \2/g")?

@dillaman

dillaman Oct 5, 2018

Contributor

Perhaps an alternative is just something like $(echo ${PARAMS} | sed -E "s/([^ =,]+)[ =]+('[^']+'|\"[^\"]+\"|[^,]+),?/ --\1 \2/g")?

@dillaman

This comment has been minimized.

Show comment
Hide comment
@dillaman

dillaman Oct 5, 2018

Contributor

@scoopex Can you add Fixes: https://tracker.ceph.com/issues/36327 to your commit message?

Contributor

dillaman commented Oct 5, 2018

@scoopex Can you add Fixes: https://tracker.ceph.com/issues/36327 to your commit message?

Marc Schoechlin
common: fix for broken rbdmap parameter parsing
This improves the broken parameter parsing discussed in #36327

Test expression for the parsing function:

PARAMS="options='lock_on_read,queue_depth=1024',id=archiv,keyring=/etc/ceph/ceph.client.archiv.keyring"
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

PARAMS="id=archiv,keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024'"
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

PARAMS=""
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

PARAMS=",keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv,"
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

PARAMS="'keyring'=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv,"
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

PARAMS="--keyring=/etc/ceph/ceph.client.archiv.keyring,options='lock_on_read,queue_depth=1024',id=archiv, # a comment"
echo -e " ORIGINAL PARAM: >>>$PARAMS<<<\nCONVERTED PARAM: >>>$(create_cmd_params "$PARAMS")<<<"

Fixes: https://tracker.ceph.com/issues/36327
Signed-off-by: Marc Schoechlin <ms@256bit.org]>

@liewegas liewegas requested a review from dillaman Oct 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment