swift-drive-audit broken on python 3

Bug #1847955 reported by Tim Burke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
High
Unassigned

Bug Description

On python3, swift-drive-audit bombs out pretty quickly with something like

  Traceback (most recent call last):
    File ".../swift/common/utils.py", line 396, in backward
      f.seek(-blocksize, os.SEEK_CUR)
  io.UnsupportedOperation: can't do nonzero cur-relative seeks

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File ".../bin/swift-drive-audit", line 7, in <module>
      exec(compile(f.read(), __file__, 'exec'))
    File ".../bin/swift-drive-audit", line 184, in <module>
      errors = get_errors(error_re, log_file_pattern, minutes, logger)
    File ".../bin/swift-drive-audit", line 95, in get_errors
      for line in backward(f):
    File ".../swift/common/utils.py", line 399, in backward
      f.seek(-blocksize, os.SEEK_CUR)
  io.UnsupportedOperation: can't do nonzero cur-relative seeks

Per the docs [1],

> In text files (those opened without a `b` in the mode string), only
> seeks relative to the beginning of the file are allowed ...

... so I guess we need to open /var/log/kern.log et al. in binary mode. Now to figure out what an appropriate encoding would be...

[1] https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.opendev.org/688326
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=405a2b2a55866b74f196ad81eaafedeee4615fa8
Submitter: Zuul
Branch: master

commit 405a2b2a55866b74f196ad81eaafedeee4615fa8
Author: Tim Burke <email address hidden>
Date: Sun Oct 13 21:55:54 2019 -0700

    py3: Fix swift-drive-audit

    Walking through the kernel logs backwards requires that we open them
    in binary mode. Add a new option to allow users to specify which
    encoding should be used to interpret those logs; default to the same
    encoding that open() uses for its default.

    Change-Id: Iae332bb58388b5521445e75beba6ee2e9f06bfa6
    Closes-Bug: #1847955

Changed in swift:
status: Confirmed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/688766

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/train)

Reviewed: https://review.opendev.org/688766
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=bcb2016673434e720e92fe4e75969c3b518a92c8
Submitter: Zuul
Branch: stable/train

commit bcb2016673434e720e92fe4e75969c3b518a92c8
Author: Tim Burke <email address hidden>
Date: Sun Oct 13 21:55:54 2019 -0700

    py3: Fix swift-drive-audit

    Walking through the kernel logs backwards requires that we open them
    in binary mode. Add a new option to allow users to specify which
    encoding should be used to interpret those logs; default to the same
    encoding that open() uses for its default.

    Change-Id: Iae332bb58388b5521445e75beba6ee2e9f06bfa6
    Closes-Bug: #1847955
    (cherry picked from commit 405a2b2a55866b74f196ad81eaafedeee4615fa8)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.23.1

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (feature/losf)

Fix proposed to branch: feature/losf
Review: https://review.opendev.org/693283

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (feature/losf)
Download full text (9.6 KiB)

Reviewed: https://review.opendev.org/693283
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=dbfb6a6fc90cb3367ed2248572089ee3cbafc15a
Submitter: Zuul
Branch: feature/losf

commit 7cb92810acfd3cd598860aefadff8fba47e3efdd
Author: SeongSoo Cho <email address hidden>
Date: Wed Nov 6 15:32:56 2019 +0800

    Fix bug internal client's delete_object logs 499

    Internal Client's doest not read body for 404.
    So, When internal deleing object that not existed, proxy-server logs
    its response code to 499.

    In this patch, add a code that drain the reponse body to prevent
    unexpected disconnect in proxy-server

    Change-Id: I6d170fead798d0d539c69d27a6fa8a2d0123ca99
    Closes-Bug: #1835324

commit c512574e110c214396658743e75ae497ba76e2ff
Author: Tim Burke <email address hidden>
Date: Tue Nov 5 01:45:26 2019 +0000

    Make our py2 func tests more explicitly py2

    ...because otherwise, I think they might be running under py3 right now.

    Change-Id: I96ad9e5ed87a7e08d06e889233730cec476d3af7

commit a505d02b3762ecbe7ea80b968ddec90ca3446549
Author: Chris Smart <email address hidden>
Date: Sat Nov 2 20:48:47 2019 +1100

    Tweak Swift AIO docs, update CentOS and Fedora

    The Swift AIO documentation is out of date for CentOS and Fedora.

    This patch updates the documentation to ensure that the instructions are
    clear and accurate.

    It also cleans up a few other sections along the way and adds some new
    headings to make it easier to read. Some explanatory notes are added,
    such as the need for XFS storage and test directories. XFS tmp loopback
    device is moved out of the user's home directory to /srv to match
    storage.

    Change-Id: Ieb0341536b7149c99139a1cf620828eba25f4bc6
    Signed-off-by: Chris Smart <email address hidden>

commit 281ffab2a52f348aa3f8ad39e800a43c6047e1cf
Author: Thiago da Silva <email address hidden>
Date: Fri Nov 1 09:57:34 2019 +0200

    pin lower-constraints to run against python 2.7

    Change-Id: I5c856012a04ef8f910c28b0248ea7bcda47e4816

commit 0c1b485ad671fc0abac15cd0bbec894e517e1dd9
Author: John Dickinson <email address hidden>
Date: Thu Oct 17 09:43:55 2019 -0700

    exclude utf8 tests under py3

    These are known to not work until https://bugs.python.org/issue37093
    is addressed in CPython upstream.

    Change-Id: I4a6877907d14b632a9a477c887913488427b62b7

commit dd235b6ac0757e34805b041d331511c957764f3e
Author: Clay Gerrard <email address hidden>
Date: Mon Oct 28 11:27:58 2019 -0500

    use request_helpers import namespace for tests

    Change-Id: I8e18ff2036312d3049a420f3332a6ea6110447c4

commit b75d5939352c405ab82ab52c3a9a1c3ad030aa26
Author: Clay Gerrard <email address hidden>
Date: Fri Oct 25 14:34:41 2019 -0500

    Refactor timestamp iter in db backend tests

    Change-Id: I61d044a6d778e158af73a3f4d9fc75d642af0beb

commit 739c3704107bd991493472c18bfe7ac5f933077c
Author: OpenStack Proposal Bot <email address hidden>
Date: Fri Oct 18 07:10:33 2019 +0000

    Imported Translations from Zanata

    For more information about this automat...

Read more...

tags: added: in-feature-losf
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift 2.24.0

This issue was fixed in the openstack/swift 2.24.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.