[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pulp-list] Feedback on sync_repo() result reporting for v2 plugins

Based on the current status of the v2 APIs, I now have some working rsync-based importer plugins up and running:


(If you want to look at the code for the sync operations themselves, they're in pulpdist.core: http://git.fedorahosted.org/git/?p=pulpdist.git;a=blob;f=src/pulpdist/core/sync_trees.py)

However, I think the error reporting API leaves a bit to be desired as it currently stands. I'd like to be able to raise an exception to indicate a problem, but provide additional details in the result as structured data.

Currently, I jam everything I want to report into an exception message:

        et, ev, tb = sys.exc_info()
        msg_format = (
            "exception: {0}\n"
            "error_message: {1}\n"
        raise RuntimeError(msg.format(et, ev,

I'd prefer it if I could do something more like what I'm able to do in the success case via sync_conduit.build_report():

        et, ev, tb = sys.exc_info()
        err_summary = {
            "result": command.SYNC_FAILED
            "exception": str(et)
            "message": str(ev)
        err_details = {
            "sync_log": sync_log.getvalue()
            "traceback": traceback.format_tb(tb)
        raise sync_conduit.sync_error(err_summary, err_details)

If I had that richer API, I could also correctly report SYNC_PARTIAL as an error without losing data by replacing the current build_report() call with the following:

    if result == command.SYNC_PARTIAL:
        raise sync_conduit.sync_error(summary, details)
        report = sync_conduit.build_report(summary, details)


Nick Coghlan
Red Hat Engineering Operations, Brisbane

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]