#4348 kojid --single mode
Merged 6 months ago by mikem. Opened 11 months ago by mikem.
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
@@ -6752,6 +6755,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,
@@ -6789,6 +6794,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.

Fixes https://pagure.io/koji/issue/4440

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
11 months ago

Metadata Update from @mikem:
- Pull-request tagged with: testing-basic

6 months ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

6 months ago

rebased onto 49338e9

6 months ago

Commit 67cc2cd fixes this pull-request

Pull-Request has been merged by mikem

6 months ago