Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-2567

Python binding method 'declineOffer(offerid, filters=None)' raises exception when 'filters=None' is assigned explicitly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Reviewable
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: python api
    • Labels:
      None

      Description

      def launchTasks(self, offerIds, tasks, filters=None):  # The method's signature.
         ...
      
      declineOffer(offerId)  # OK to call it this way
      declineOffer(offerId, filters=None)  # Error when calling it this way
      

      The error is printed from here

      https://github.com/apache/mesos/blob/04f8302c0cf81196e33ac538710dc5f48cd809d9/src/python/native/src/mesos/native/module.hpp#L66

      if (obj == Py_None) {
          std::cerr << "None object given where protobuf expected" << std::endl;
          return false;
       }
      

      And I think it's because when parsing the arguments the missing optional argument is interpreted as NULL and an explicit 'None' as Py_None and we didn't check the result properly here: https://github.com/apache/mesos/blob/04f8302c0cf81196e33ac538710dc5f48cd809d9/src/python/native/src/mesos/native/mesos_scheduler_driver_impl.cpp#L632

        if (filtersObj != NULL) {
          if (!readPythonProtobuf(filtersObj, &filters)) {
            PyErr_Format(PyExc_Exception,
                         "Could not deserialize Python Filters");
            return NULL;
          }
        }
      

        Attachments

          Activity

            People

            • Assignee:
              haosdent@gmail.com haosdent
              Reporter:
              xujyan Yan Xu
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: