Removing several devices doesn't work

Bug #1937289 reported by Facundo Ciccioli
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Swift Proxy Charm
Fix Released
Medium
Bartłomiej Poniecki-Klotz

Bug Description

Everything on the docs of the remove-devices action, even the name, indicates it should be possible to remove more than device at a time. But that's currently not working due to swift-ring-builder asking for user confirmation by default whenever more than one device matches. This behavior can be overriden by passing it the -y flag.

For instance:

$ sudo swift-ring-builder /etc/swift/container.builder search ww.xx.yy.zz
Devices: id region zone ip address port replication ip replication port name weight partitions balance meta
            27 1 1 ww.xx.yy.zz 6001 ww.xx.yy.zz 6001 sdf 100.00 4234 -2.01
            28 1 1 ww.xx.yy.zz 6001 ww.xx.yy.zz 6001 sdg 100.00 4233 -2.04
            29 1 1 ww.xx.yy.zz 6001 ww.xx.yy.zz 6001 sde 100.00 4233 -2.04

And you try to remove all of that host's devices:

$ juju run-action --wait swift-proxy/4 remove-devices ring=all search-value=ww.xx.yy.zz
UnitId: swift-proxy/4
id: "11180"
message: 'Failed to remove device(s) for ww.xx.yy.zz pattern on /etc/swift/account.builder.
  Output: Command ''[''swift-ring-builder'', ''/etc/swift/account.builder'', ''remove'',
  ''ww.xx.yy.zz'']'' returned non-zero exit status 1.'
results:
  Stderr: |
    Traceback (most recent call last):
      File "/usr/bin/swift-ring-builder", line 24, in <module>
        sys.exit(main())
      File "/usr/lib/python2.7/dist-packages/swift/cli/ringbuilder.py", line 1516, in main
        getattr(Commands, command, Commands.unknown)()
      File "/usr/lib/python2.7/dist-packages/swift/cli/ringbuilder.py", line 840, in remove
        check_devs(devs, input_question, opts, abort_msg)
      File "/usr/lib/python2.7/dist-packages/swift/cli/ringbuilder.py", line 196, in check_devs
        if not opts.yes and input(input_question) != 'y':
    EOFError: EOF when reading a line
  Stdout: |
    Matched more than one device:
        d66r1z2-ww.xx.yy.zz:6002Rww.xx.yy.zz:6002/sdf_""
        d67r1z2-ww.xx.yy.zz:6002Rww.xx.yy.zz:6002/sdg_""
        d68r1z2-ww.xx.yy.zz:6002Rww.xx.yy.zz:6002/sde_""
status: failed
timing:
  completed: 2021-07-22 13:46:35 +0000 UTC

I believe this patch should be applied:

--- lib/swift_utils.py.orig 2021-07-22 13:59:04.744155567 +0000
+++ lib/swift_utils.py 2021-07-22 13:59:22.560895296 +0000
@@ -570,7 +570,7 @@
     :type search_value: str
     :raises: SwiftProxyCharmException
     """
- cmd = ['swift-ring-builder', ring_path, 'remove', search_value]
+ cmd = ['swift-ring-builder', '-y', ring_path, 'remove', search_value]
     try:
         subprocess.check_call(cmd)
     except subprocess.CalledProcessError as e:

Changed in charm-swift-proxy:
importance: Undecided → Medium
status: New → Triaged
tags: added: good-first-bug
Changed in charm-swift-proxy:
assignee: nobody → Bartłomiej Poniecki-Klotz (barteus)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-swift-proxy (master)
Changed in charm-swift-proxy:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-swift-proxy (master)

Reviewed: https://review.opendev.org/c/openstack/charm-swift-proxy/+/814415
Committed: https://opendev.org/openstack/charm-swift-proxy/commit/d92cf5756ed7ee7364e7b12061b69d51aa5bc684
Submitter: "Zuul (22348)"
Branch: master

commit d92cf5756ed7ee7364e7b12061b69d51aa5bc684
Author: Bartlomiej Poniecki-Klotz <email address hidden>
Date: Mon Oct 18 14:04:02 2021 +0200

    Fixed removing multiple devices

    Added a confirmation flag for swift-ring-builder command when multiple devices are found to be removed.

    func-test-pr: https://github.com/openstack-charmers/zaza-openstack-tests/pull/656
    Closes-Bug: #1937289
    Change-Id: Ieeb326e7d9af21a77954e95e909d6fcf20a3092c

Changed in charm-swift-proxy:
status: In Progress → Fix Committed
Changed in charm-swift-proxy:
milestone: none → 22.04
Changed in charm-swift-proxy:
status: Fix Committed → Fix Released
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.