#335 Allow setting pungi_timeout per raw_config.
Merged 4 years ago by lsedlar. Opened 4 years ago by jkaluza.
jkaluza/odcs release  into  master

file modified
+3
@@ -88,6 +88,9 @@ 

    - ``config_filename`` - Name of the main Pungi configuration file.

    - ``schema_override`` [optional] - If set, defines the path to JSON schema

      override file to be used when validating the main Pungi configuration file.

+   - ``pungi_timeout`` - [optional] - If set, defines the timeout in seconds in

+     which the compose must be finished, otherwise the compose is marked as

+     ``failed``.

  

  

  Enabling ``pungi-config-validate``

file modified
+7 -1
@@ -42,6 +42,9 @@ 

  

  class BasePungiConfig(object):

  

+     def __init__(self):

+         self.pungi_timeout = conf.pungi_timeout

+ 

      def _write(self, path, cfg):

          """

          Writes configuration string `cfg` to file defined by `path`.
@@ -66,6 +69,7 @@ 

  class RawPungiConfig(BasePungiConfig):

  

      def __init__(self, compose_source):

+         super(RawPungiConfig, self).__init__()

          source_name, source_hash = compose_source.split("#")

  

          url_data = copy.deepcopy(conf.raw_config_urls[source_name])
@@ -74,6 +78,7 @@ 

          if "commit" not in url_data:

              url_data["commit"] = source_hash

  

+         self.pungi_timeout = url_data.get("pungi_timeout", conf.pungi_timeout)

          self.pungi_cfg = url_data

          self.pungi_koji_args = conf.raw_config_pungi_koji_args.get(

              source_name, conf.pungi_koji_args)
@@ -146,6 +151,7 @@ 

                   multilib_arches=None, multilib_method=0, builds=None,

                   flags=0, lookaside_repos=None, modular_koji_tags=None,

                   module_defaults_url=None):

+         super(PungiConfig, self).__init__()

          self.release_name = release_name

          self.release_version = release_version

          self.bootable = False
@@ -440,7 +446,7 @@ 

              with open(log_out_path, "w") as log_out:

                  with open(log_err_path, "w") as log_err:

                      odcs.server.utils.execute_cmd(

-                         pungi_cmd, cwd=td, timeout=conf.pungi_timeout,

+                         pungi_cmd, cwd=td, timeout=self.pungi_cfg.pungi_timeout,

                          stdout=log_out, stderr=log_err)

          finally:

              try:

@@ -514,6 +514,26 @@ 

              stderr=AnyStringWith("pungi-config-validate-stderr.log"),

              stdout=AnyStringWith("pungi-config-validate-stdout.log")))

  

+     @patch("odcs.server.utils.execute_cmd")

+     def test_pungi_run_raw_config_custom_timeout(self, execute_cmd):

+         fake_raw_config_urls = {

+             'pungi.conf': {

+                 "url": "http://localhost/test.git",

+                 "config_filename": "pungi.conf",

+                 "pungi_timeout": 7200,

+             }

+         }

+         with patch.object(conf, 'raw_config_urls', new=fake_raw_config_urls):

+             pungi = Pungi(1, RawPungiConfig('pungi.conf#hash'))

+             pungi.run(self.compose)

+ 

+         execute_cmd.assert_called_once_with(

+             ['pungi-koji', AnyStringWith('pungi.conf'),

+              AnyStringWith('--compose-dir='), '--nightly'],

+             cwd=AnyStringWith('/tmp/'), timeout=7200,

+             stderr=AnyStringWith("pungi-stderr.log"),

+             stdout=AnyStringWith("pungi-stdout.log"))

+ 

  

  class TestPungiLogs(ModelsBaseTest):

  

If we are going to generate full composes including all the images
using ODCS, we might need to increase the pungi_timeout for
particular raw_configs. This is mainly needed for custom Fedora
composes.

Signed-off-by: Jan Kaluza jkaluza@redhat.com

Pull-Request has been merged by lsedlar

4 years ago