#4348 kojid --single mode
Opened 2 months ago by mikem. Modified 2 months ago
mikem/koji kojid-single-mode  into  master

file modified
+9
@@ -189,6 +189,9 @@ 

                  # from getting overloaded.

                  logger.debug('Sleeping for %s', options.sleeptime)

                  time.sleep(options.sleeptime)

+             elif options.single:

+                 # exit after first task

+                 break

          except (SystemExit, KeyboardInterrupt):

              logger.warning("Exiting")

              break
@@ -6741,6 +6744,8 @@ 

      parser.add_option("-f", "--fg", dest="daemon",

                        action="store_false", default=True,

                        help="run in foreground")

+     parser.add_option("--single", action="store_true",

+                       help="run a single task in foreground, for debugging")

      parser.add_option("--force-lock", action="store_true", default=False,

                        help="force lock for exclusive session")

      parser.add_option("-v", "--verbose", action="store_true", default=False,
@@ -6778,6 +6783,10 @@ 

          # not reached

          assert False  # pragma: no cover

  

+     # --single implies --fg

+     if options.single:

+         options.daemon = False

+ 

      # load local config

      config = koji.read_config_files(options.configFile, raw=True)

      for x in config.sections():

file modified
+1 -1
@@ -1379,7 +1379,7 @@ 

                  return False

              # otherwise...

              raise

-         if handler.Foreground:

+         if handler.Foreground or getattr(self.options, "single"):

              self.logger.info("running task in foreground")

              handler.setManager(self)

              self.runTask(handler)

@@ -13,6 +13,7 @@ 

  

      def setUp(self):

          self.options = mock.MagicMock()

+         self.options.single = False

          self.session = mock.MagicMock()

          self.tm = koji.daemon.TaskManager(self.options, self.session)

          self.tm.readyForTask = mock.MagicMock()
@@ -65,6 +66,7 @@ 

  

      def setUp(self):

          self.options = mock.MagicMock()

+         self.options.single = False

          self.session = mock.MagicMock()

          self.tm = koji.daemon.TaskManager(self.options, self.session)

          self.tm.readyForTask = mock.MagicMock()

@@ -21,6 +21,7 @@ 

          # set up task handler

          self.session = mock.MagicMock()

          self.options = mock.MagicMock()

+         self.options.single = False

          self.options.plugin = []

          self.options.sleeptime = 1

          self.options.pluginpath = ''

This is an option for debugging kojid. I needed this to debug a build problem and thought it would be useful to keep.

Using this option makes it feasible to use the python debugger on a task handler.

Note: this is really only useful in situations where you can control the task the host gets. The easiest way to do that is to remove the host from all channels and manually assign tasks to it.

1 new commit added

  • fix unit tests
2 months ago