If not specifying full path of the object data file, it can't not parse the policy from the data_dir. swift-object-info returns policy name not match while the policy_name in the option. Here's four examples :
Correct results with full data dir
```
root@ssnode-n1:~# swift-object-info /srv/node/d31/objects-5/111/245/1bfd2957f9a05fa0292f1c4609e21245/1435265145.42895#7.data
HUGO policy_name : None and policy_index : 5
Path: /AUTH_demo/ec-test1/1229
Account: AUTH_demo
Container: ec-test1
Object: 1229
Object hash: 1bfd2957f9a05fa0292f1c4609e21245
Content-Type: application/octet-stream
Timestamp: 2015-06-25T20:45:45.428950 (1435265145.42895)
User Metadata: {u'X-Object-Sysmeta-Ec-Frag-Index': '7', u'X-Object-Sysmeta-Ec-Content-Length': '2097152', u'X-Object-Sysmeta-Ec-Etag': '9828bfafd6e9b3f797dc364435ba8bf6', u'X-Object-Sysmeta-Ec-Scheme': 'isa_l_rs_vand 6+4', 'X-Object-Meta-Mtime': '1434522970.981133', u'X-Object-Sysmeta-Ec-Segment-Size': '1048576'}
ETag: bdfe2bbee6b98ac31ad422e33a125ce4 (valid)
Content-Length: 349686 (valid)
Partition 111
Hash 1bfd2957f9a05fa0292f1c4609e21245
curl -I -XHEAD "http://192.168.56.9:6000/d25/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d38/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d24/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d28/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d20/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d35/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d11/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d31/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d22/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d39/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d30/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d10/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d13/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d34/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d33/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d16/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d27/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d14/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d32/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d15/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
```
```
root@ssnode-n1:~# swift-object-info /srv/node/d31/objects-5/111/245/1bfd2957f9a05fa0292f1c4609e21245/1435265145.42895#7.data -P ec1
HUGO policy_name : ec1 and policy_index : 5
Path: /AUTH_demo/ec-test1/1229
Account: AUTH_demo
Container: ec-test1
Object: 1229
Object hash: 1bfd2957f9a05fa0292f1c4609e21245
Content-Type: application/octet-stream
Timestamp: 2015-06-25T20:45:45.428950 (1435265145.42895)
User Metadata: {u'X-Object-Sysmeta-Ec-Frag-Index': '7', u'X-Object-Sysmeta-Ec-Content-Length': '2097152', u'X-Object-Sysmeta-Ec-Etag': '9828bfafd6e9b3f797dc364435ba8bf6', u'X-Object-Sysmeta-Ec-Scheme': 'isa_l_rs_vand 6+4', 'X-Object-Meta-Mtime': '1434522970.981133', u'X-Object-Sysmeta-Ec-Segment-Size': '1048576'}
ETag: bdfe2bbee6b98ac31ad422e33a125ce4 (valid)
Content-Length: 349686 (valid)
Partition 111
Hash 1bfd2957f9a05fa0292f1c4609e21245
curl -I -XHEAD "http://192.168.56.9:6000/d25/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d38/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d24/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d28/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d20/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d35/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d11/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d31/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.9:6000/d22/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d39/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5"
curl -I -XHEAD "http://192.168.56.10:6000/d30/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d10/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d13/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d34/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d33/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d16/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d27/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d14/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d32/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d15/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 5" # [Handoff]
```
Incorrect results
```
root@ssnode-n1:/srv/node/d31/objects-5/111/245/1bfd2957f9a05fa0292f1c4609e21245# swift-object-info 1435265145.42895#7.data
HUGO policy_name : None and policy_index : 0
Path: /AUTH_demo/ec-test1/1229
Account: AUTH_demo
Container: ec-test1
Object: 1229
Object hash: 1bfd2957f9a05fa0292f1c4609e21245
Content-Type: application/octet-stream
Timestamp: 2015-06-25T20:45:45.428950 (1435265145.42895)
User Metadata: {u'X-Object-Sysmeta-Ec-Frag-Index': '7', u'X-Object-Sysmeta-Ec-Content-Length': '2097152', u'X-Object-Sysmeta-Ec-Etag': '9828bfafd6e9b3f797dc364435ba8bf6', u'X-Object-Sysmeta-Ec-Scheme': 'isa_l_rs_vand 6+4', 'X-Object-Meta-Mtime': '1434522970.981133', u'X-Object-Sysmeta-Ec-Segment-Size': '1048576'}
ETag: bdfe2bbee6b98ac31ad422e33a125ce4 (valid)
Content-Length: 349686 (valid)
Partition 111
Hash 1bfd2957f9a05fa0292f1c4609e21245
curl -I -XHEAD "http://192.168.56.9:6000/d6/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.10:6000/d3/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.10:6000/d2/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.9:6000/d5/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d0/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d7/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
```
```
root@ssnode-n1:/srv/node/d31/objects-5/111/245/1bfd2957f9a05fa0292f1c4609e21245# swift-object-info 1435265145.42895#7.data -P ec1
HUGO policy_name : ec1 and policy_index : 0
Attention: Ring does not match policy!
Double check your policy name!
Path: /AUTH_demo/ec-test1/1229
Account: AUTH_demo
Container: ec-test1
Object: 1229
Object hash: 1bfd2957f9a05fa0292f1c4609e21245
Content-Type: application/octet-stream
Timestamp: 2015-06-25T20:45:45.428950 (1435265145.42895)
User Metadata: {u'X-Object-Sysmeta-Ec-Frag-Index': '7', u'X-Object-Sysmeta-Ec-Content-Length': '2097152', u'X-Object-Sysmeta-Ec-Etag': '9828bfafd6e9b3f797dc364435ba8bf6', u'X-Object-Sysmeta-Ec-Scheme': 'isa_l_rs_vand 6+4', 'X-Object-Meta-Mtime': '1434522970.981133', u'X-Object-Sysmeta-Ec-Segment-Size': '1048576'}
ETag: bdfe2bbee6b98ac31ad422e33a125ce4 (valid)
Content-Length: 349686 (valid)
Partition 111
Hash 1bfd2957f9a05fa0292f1c4609e21245
curl -I -XHEAD "http://192.168.56.9:6000/d6/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.10:6000/d3/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.10:6000/d2/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0"
curl -I -XHEAD "http://192.168.56.9:6000/d5/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
curl -I -XHEAD "http://192.168.56.10:6000/d0/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
curl -I -XHEAD "http://192.168.56.9:6000/d7/111/AUTH_demo/ec-test1/1229" -H "X-Backend-Storage-Policy-Index: 0" # [Handoff]
```
Reviewed: https:/ /review. openstack. org/205344 /git.openstack. org/cgit/ openstack/ swift/commit/ ?id=3d9b2d077a1 57279fb6cd107a0 c83727106af3ef
Committed: https:/
Submitter: Jenkins
Branch: master
commit 3d9b2d077a15727 9fb6cd107a0c837 27106af3ef
Author: Daisuke Morita <email address hidden>
Date: Fri Jul 24 10:42:10 2015 +0900
Fix swift-object-info to show policy index at deep working directory
If swift-object-info command is executed at deeper working directory
than 'objects-*' directory, it cannot parse policy index from file path
so it does not show appropriate policy index. This patch fixes this
problem by simply extracting the full path of a target object file.
Change-Id: Idb734106a44b61 21119c9b1dc8cda af4c6c28c31
Closes-Bug: 1469951