swift-object-relinker does not handle unmounted disks well

Bug #1910470 reported by Tim Burke on 2021-01-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Undecided
Unassigned

Bug Description

If you followed best practices and made sure that root owns the mount point while your swift user owns the root of the filesystem that's usually mounted there, things aren't pretty but at least they're not misleading:

vagrant@saio:~/swift$ sudo umount /srv/node2/sdb2
vagrant@saio:~/swift$ swift-object-relinker relink --devices /srv/node2/
Relinking files for policy default under /srv/node2/
Traceback (most recent call last):
  File "/usr/local/bin/swift-object-relinker", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/vagrant/swift/bin/swift-object-relinker", line 43, in <module>
    sys.exit(main(args))
  File "/vagrant/swift/swift/cli/relinker.py", line 317, in main
    return relink(
  File "/vagrant/swift/swift/cli/relinker.py", line 189, in relink
    for fname, _, _ in locations:
  File "/vagrant/swift/swift/common/utils.py", line 3257, in audit_location_generator
    hook_pre_device(os.path.join(devices, device))
  File "/vagrant/swift/swift/cli/relinker.py", line 48, in hook_pre_device
    fd = os.open(lock_file, os.O_CREAT | os.O_WRONLY)
PermissionError: [Errno 13] Permission denied: '/srv/node2/sdb2/.relink.objects.lock'

If you *didn't* do that, though (or you ran the relinker as root), there's no indication that there was a problem at all:

vagrant@saio:~/swift$ sudo swift-object-relinker relink --devices /srv/node2/
Relinking files for policy default under /srv/node2/
Relinked 0 diskfiles (0 errors)

We don't even log the "Skipping ..." message (https://github.com/openstack/swift/blob/2.26.0/swift/obj/diskfile.py#L533) since we don't pass a logger to audit_location_generator!

Much better would be to log the message and exit with a status of 2 (like we do with other warnings).

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

Other bug subscribers