#367 play nice with older hubs and new volume options
Merged 6 years ago by mikem. Opened 6 years ago by mikem.
mikem/koji all_volumes_legacy  into  master

file modified
+18 -5
@@ -508,7 +508,7 @@ 

              if _isDone(session, task_id):

                  tasklist.remove(task_id)

  

-             output = session.listTaskOutput(task_id, all_volumes=True)

+             output = list_task_output_all_volumes(session, task_id)

              # convert to list of (file, volume)

              files = []

              for filename, volumes in output.iteritems():
@@ -542,6 +542,19 @@ 

  

          time.sleep(options.poll_interval)

  

+ 

+ def list_task_output_all_volumes(session, task_id):

+     """List task output with all volumes, or fake it"""

+     try:

+         return session.listTaskOutput(task_id, all_volumes=True)

+     except koji.GenericError, e:

+         if 'got an unexpected keyword argument' not in str(e):

+             raise

+     # otherwise leave off the option and fake it

+     output = session.listTaskOutput(task_id)

+     return dict([fn, ['DEFAULT']] for fn in output)

+ 

+ 

  def handle_add_group(options, session, args):

      "[admin] Add a group to a tag"

      usage = _("usage: %prog add-group <tag> <group>")
@@ -4690,7 +4703,7 @@ 

      buildroot_infos = session.listBuildroots(taskID=task_id)

      build_info = session.listBuilds(taskID=task_id)

  

-     files = session.listTaskOutput(task_id, all_volumes=True)

+     files = list_task_output_all_volumes(session, task_id)

      logs = []

      output = []

      for filename in files:
@@ -6820,7 +6833,7 @@ 

          task_info = session.getTaskInfo(task_id)

          if task_info is None:

              error(_("No such task id: %i" % task_id))

-         files = session.listTaskOutput(task_id, all_volumes=True)

+         files = list_task_output_all_volumes(session, task_id)

          logs = [] # list of tuples (filename, volume)

          for filename in files:

              if not filename.endswith(".log"):
@@ -6908,7 +6921,7 @@ 

      downloads = []

  

      for task in downloadable_tasks:

-         files = session.listTaskOutput(task["id"], all_volumes=True)

+         files = list_task_output_all_volumes(session, task["id"])

          for filename in files:

              if filename.endswith(".log") and suboptions.logs:

                  for volume in files[filename]:
@@ -7324,7 +7337,7 @@ 

          print("User interrupt: canceling runroot task")

          session.cancelTask(task_id)

          raise

-     output = session.listTaskOutput(task_id, all_volumes=True)

+     output = list_task_output_all_volumes(session, task_id)

      if 'runroot.log' in output:

          for volume in output['runroot.log']:

              log = session.downloadTaskOutput(task_id, 'runroot.log', volume=volume)

file modified
+17 -5
@@ -2474,13 +2474,16 @@ 

          full_chksum = util.adler32_constructor()

          # cycle is need to run at least once (for empty files)

          first_cycle = True

+         callopts = {'overwrite': overwrite}

+         if volume and volume != 'DEFAULT':

+             callopts['volume'] = volume

          while True:

              lap = time.time()

              chunk = fo.read(blocksize)

              if not chunk and not first_cycle:

                  break

              first_cycle = False

-             result = self._callMethod('rawUpload', (chunk, ofs, path, name), {'overwrite':overwrite, 'volume': volume})

+             result = self._callMethod('rawUpload', (chunk, ofs, path, name), callopts)

              if self.retries > 1:

                  problems = True

              hexdigest = util.adler32_constructor(chunk).hexdigest()
@@ -2499,7 +2502,9 @@ 

                  callback(ofs, size, len(chunk), t1, t2)

          if ofs != size:

              self.logger.error("Local file changed size: %s, %s -> %s", localfile, size, ofs)

-         chk_opts = {'volume': volume}

+         chk_opts = {}

+         if volume and volume != 'DEFAULT':

+             chk_opts['volume'] = volume

          if problems:

              chk_opts['verify'] = 'adler32'

          result = self._callMethod('checkUpload', (path, name), chk_opts)
@@ -2549,9 +2554,13 @@ 

          if name is None:

              name = os.path.basename(localfile)

  

+         volopts = {}

+         if volume and volume != 'DEFAULT':

+             volopts['volume'] = volume

+ 

          # check if server supports fast upload

          try:

-             self._callMethod('checkUpload', (path, name), {'volume': volume})

+             self._callMethod('checkUpload', (path, name), volopts)

              # fast upload was introduced in 1.7.1, earlier servers will not

              # recognise this call and return an error

          except GenericError:
@@ -2590,7 +2599,7 @@ 

              while True:

                  if debug:

                      self.logger.debug("uploadFile(%r,%r,%r,%r,%r,...)" %(path, name, sz, digest, offset))

-                 if self.callMethod('uploadFile', path, name, encode_int(sz), digest, encode_int(offset), data, volume=volume):

+                 if self.callMethod('uploadFile', path, name, encode_int(sz), digest, encode_int(offset), data, **volopts):

                      break

                  if tries <= retries:

                      tries += 1
@@ -2623,7 +2632,10 @@ 

          """

          if self.multicall:

              raise GenericError('downloadTaskOutput() may not be called during a multicall')

-         result = self.callMethod('downloadTaskOutput', taskID, fileName, offset=offset, size=size, volume=volume)

+         dlopts = {'offset': offset, 'size': size}

+         if volume and volume != 'DEFAULT':

+             dlopts['volume'] = volume

+         result = self.callMethod('downloadTaskOutput', taskID, fileName, **dlopts)

          return base64.decodestring(result)

  

  class DBHandler(logging.Handler):

2 new commits added

  • only pass volume opt to downloadTaskOutput if needed
  • missed one listTaskOutput call
6 years ago

1 new commit added

  • for volume compat fixes
6 years ago

Thank, fixed! :thumbsup:

1 new commit added

  • typo
6 years ago

Commit 725b395 fixes this pull-request

Pull-Request has been merged by mikem@redhat.com

6 years ago