Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-63307

Refactor "clear_wraparound" OOP hack in cbcollect_info

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • Morpheus
    • None
    • ns_server
    • None
    • Untriaged
    • 0
    • Unknown

    Description

      There's a bit of a "hack" in cbcollect_info where we call a hook that only exists on some variants of the class we are operating on.. Namely, it involves when to call "clear_wraparound". The hack currently just double checks that it's defined, before calling it in the Task.on_execute method. The longer-term solution would likely be to make Task abstract and instead have a "ProcessPipeTask" or some other variation that is meant for what we use the current Task class for now. That, and some other OOP refactoring will be required to get rid of:

      # due to the fact that we overload usage of builtin containers like
      # BytesIO we need to double check if the method is defined on the
      # object or not before calling it.
      # TODO: handle in a more graceful / OOP way
        if "clear_wraparound" in dir(outstream):
            outstream.clear_wraparound()

      Additionally, we would need to divorce any usage of the builtin container types like BytesIO like how we have it currently. Such as:

      output_bytes = BytesIO()
      status = task.execute(output_bytes) 

      since we cannot add this hook to that type (technically you can monkey-patch it but that's more hacky stuff). 

      Maybe there are other solutions that I haven't considered yet.. It seems some reworking of the class hierarchy is gonna be required. 

      Attachments

        Activity

          People

            bryan.mccoid Bryan McCoid
            bryan.mccoid Bryan McCoid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              PagerDuty