swift-get-nodes ValueError on non-legacy rings

Bug #1668736 reported by clayg
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Cheng Li

Bug Description

Using the -P option the `objects-1` dir is correct:

ubuntu@saio:~$ swift-get-nodes -P ec -p 673

Account None
Container None
Object None

Partition 673
Hash None

</snip>

Use your own device location of servers:
such as "export DEVICE=/srv/node"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb14/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb13/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb10/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb11/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb2/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb5/objects-1/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb12/objects-1/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb15/objects-1/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb4/objects-1/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb7/objects-1/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb8/objects-1/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb9/objects-1/673" # [Handoff]

If specified policy by ring, it's wrong:

ubuntu@saio:~$ swift-get-nodes /etc/swift/object-1.ring.gz -p 673

Account None
Container None
Object None

Partition 673
Hash None

<snip>

Use your own device location of servers:
such as "export DEVICE=/srv/node"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb14/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb13/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb10/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb11/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb2/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb5/objects-/673"
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb12/objects-/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb15/objects-/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb4/objects-/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb7/objects-/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb8/objects-/673" # [Handoff]
ssh 127.0.0.1 "ls -lah ${DEVICE:-/srv/node*}/sdb9/objects-/673" # [Handoff]

Oh, it also blows up:

ubuntu@saio:~$ swift-get-nodes /etc/swift/object-1.ring.gz a c o
Traceback (most recent call last):
  File "/usr/local/bin/swift-get-nodes", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/vagrant/swift/bin/swift-get-nodes", line 66, in <module>
    print_item_locations(ring, ring_name, *args, **vars(options))
  File "/vagrant/swift/swift/cli/info.py", line 572, in print_item_locations
    policy_index = int(ring_name.rsplit('-', 1)[1])
ValueError: invalid literal for int() with base 10: ''

Revision history for this message
YongWang (chenyongwang) wrote :

change swift-get-nodes ring_name = basename(ring_path)[:len('ring.gz')] to ring_name = basename(ring_path)[:-len('.ring.gz')] will resolve this problem.

clayg (clay-gerrard)
tags: added: low-hanging-fruit
Changed in swift:
status: New → Confirmed
Cheng Li (shcli)
Changed in swift:
assignee: nobody → Cheng Li (shcli)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/447183

Changed in swift:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/447183
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=99412d48309e071eb190a2f4735df577a22cdb87
Submitter: Jenkins
Branch: master

commit 99412d48309e071eb190a2f4735df577a22cdb87
Author: cheng <email address hidden>
Date: Sat Mar 18 03:43:32 2017 +0000

    fix get ring name

    replace ring_name = basename(ring_path)[:len('ring.gz')]
    with ring_name = basename(ring_path)[:-len('.ring.gz')]

    Change-Id: I741e46d116c8fc7c2e91a51da4284302eec3aa41
    Closes-bug: #1668736

Changed in swift:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.14.0

This issue was fixed in the openstack/swift 2.14.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.