#215 Validate early.
Merged 11 months ago by jkaluza. Opened a year ago by ralph.

@@ -549,8 +549,12 @@ 

  

          _write_repo_file(compose)

  

-     # If there is no exception generated by the pungi.run(), we know

-     # the compose has been successfully generated.

+     # Raises an exception if invalid

+     validate_pungi_compose(compose)

It's probably safe to run this for pulp compose types too because compose.packages will be falsey in that case, making it a noop. I think.

ralph commented a year ago

Good point, but it was previously only ever run for pungi composes. Let's keep it the way it is here to minimize the changes.

+ 

+     # If there is no exception generated by the pungi.run() and if

+     # validation didn't fail, then we know the compose has been

+     # successfully generated.

      compose.state = COMPOSE_STATES["done"]

      compose.state_reason = "Compose is generated successfully"

      log.info("%r: Compose done", compose)

@@ -609,7 +613,6 @@ 

                  generate_pulp_compose(compose)

              else:

                  generate_pungi_compose(compose)

-                 validate_pungi_compose(compose)

          except Exception as e:

              # Something went wrong, log the exception and update the compose

              # state in database.

@@ -463,6 +463,9 @@ 

          self.patch_update_cache = patch("odcs.server.backend.KojiTagCache.update_cache")

          self.update_cache = self.patch_update_cache.start()

  

+         self.patch_validate_pungi_compose = patch("odcs.server.backend.validate_pungi_compose")

+         self.validate_pungi_compose = self.patch_validate_pungi_compose.start()

+ 

          # Mocked method to store Pungi.pungi_cfg to self.pungi_cfg, so we can

          # run asserts against it.

          self.pungi_config = None

@@ -482,6 +485,7 @@ 

          self.patch_pungi_run.stop()

          self.patch_reuse_cached.stop()

          self.patch_update_cache.stop()

+         self.validate_pungi_compose.stop()

          self.patch_is_cached.stop()

          self.pungi_config = None

  

@@ -500,6 +504,7 @@ 

          self.is_cached.assert_called_once_with(c)

          self.reuse_cached.assert_called_once_with(c)

          self.update_cache.assert_called_once_with(c)

+         self.validate_pungi_compose.assert_called_once_with(c)

  

          self.assertEqual(self.pungi_config.gather_method, "deps")

          self.assertEqual(self.pungi_config.pkgset_koji_inherit, True)

Fixes FACTORY-2883.

Without this, ODCS may transition a compose to done and commit to the DB, but
only then validate it, find a missing package, and mark the compose as failed.
This makes the compose flipflop from "complete" to "failed", when it should
just go straight to "failed".

It's probably safe to run this for pulp compose types too because compose.packages will be falsey in that case, making it a noop. I think.

Good point, but it was previously only ever run for pungi composes. Let's keep it the way it is here to minimize the changes.

Pull-Request has been merged by jkaluza

11 months ago