common.utils.readconf SystemExit is noisy

Bug #1578321 reported by clayg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Wishlist
Christian Hugo

Bug Description

Anytime you want to use swift.common.utils.readconf if you don't want your program to exit when the config doesn't have the section you're looking for - you have to "handle" a SystemExit.

There's a couple of places in tree that do this, e.g.

https://github.com/openstack/swift/blob/2bf5eb775fe3ad6d3a2afddfc7572318e85d10be/swift/obj/auditor.py#L54

That's.... fine.... i guess - but the real problem is the message that gets spewed to STDOUT:

May 4 17:11:17 precisenode0 object-auditor: STDOUT: Unable to find object-replicator config section in /etc/swift/object-server/1.conf

^ happens every pass when a new AuditorWorker is created/forked.

1) refactor readconf to raise a different error if the section isn't defined (probably ValueError?) - include the helpful text *in* the Exception
2) find all the call-sites of readconf that want to exit - and catch the ValueError and translate the message to SystemExit
3) find all the call-sites of readconf that *don't* want to exit - and catch the ValueError and observe no messages are sent to stdout/logged

optional step 4 is to worry about all there that was handling readconf's SystemExit that will have to be updated to handle ValueError...

Changed in swift:
assignee: nobody → Annapoornima Koppad (annakoppad)
Changed in swift:
assignee: Annapoornima Koppad (annakoppad) → nobody
Changed in swift:
assignee: nobody → Christian Hugo (christianhugo)
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/393388

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

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

commit ffd5194a3be8cd5fced038cc25ea1d8f78be1ea9
Author: Christian Hugo <email address hidden>
Date: Thu Nov 3 17:01:35 2016 +0100

    Raise ValueError if a config section does not exist

    Instead of printing the error message and
    calling sys.exit() when a section not exists
    or reading the file failed rais an Exception
    from readconfig. Depending on the Value or IO-Error,
    the caller can decide if he wants to exit or continue.
    If an Exception reaches the wsgi utilities
    it bubbles all the way up.

    Change-Id: Ieb444f8c34e37f49bea21c3caf1c6c2d7bee5fb4
    Closes-Bug: 1578321

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

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