#1093 List package name in failed state reason
Merged 5 years ago by mprahl. Opened 5 years ago by cqi.
cqi/fm-orchestrator detailed-failed-msg  into  master

@@ -100,8 +100,11 @@ 

          if failed_components_in_batch:

              log.info("Batch done, but not tagging because of failed component builds. Will "

                       "transition the module to \"failed\"")

-             parent.transition(config, state=models.BUILD_STATES['failed'],

-                               state_reason="Some components failed to build.")

+             state_reason = 'Component(s) {} failed to build.'.format(

+                 ', '.join(c.package for c in failed_components_in_batch))

+             parent.transition(config,

+                               state=models.BUILD_STATES['failed'],

+                               state_reason=state_reason)

              session.commit()

              return []

          elif not built_components_in_batch:

@@ -87,14 +87,18 @@ 

      # Assemble the list of all successful components in the batch.

      good = [c for c in current_batch if c.state == koji.BUILD_STATES['COMPLETE']]

  

+     failed_states = (koji.BUILD_STATES['FAILED'],

+                      koji.BUILD_STATES['CANCELED'])

+ 

      # If *none* of the components completed for this batch, then obviously the

      # module fails.  However!  We shouldn't reach this scenario.  There is

      # logic over in the component handler which should fail the module build

      # first before we ever get here.  This is here as a race condition safety

      # valve.

      if module_build.component_builds and not good:

-         module_build.transition(config, models.BUILD_STATES['failed'],

-                                 "Some components failed to build.")

+         state_reason = 'Component(s) {} failed to build.'.format(

+             ', '.join(c.package for c in current_batch if c.state in failed_states))

+         module_build.transition(config, models.BUILD_STATES['failed'], state_reason)

          session.commit()

          log.warning("Odd!  All components in batch failed for %r." % module_build)

          return
@@ -121,8 +125,7 @@ 

      for c in module_build.component_builds:

          if c.state in [None, koji.BUILD_STATES['BUILDING']]:

              has_unbuilt_components = True

-         elif (c.state in [koji.BUILD_STATES['FAILED'],

-                           koji.BUILD_STATES['CANCELED']]):

+         elif (c.state in failed_states):

              has_failed_components = True

  

      further_work = []
@@ -141,8 +144,13 @@ 

  

      else:

          if has_failed_components:

-             module_build.transition(config, state=models.BUILD_STATES['failed'],

-                                     state_reason="Some components failed to build.")

+             state_reason = 'Component(s) {} failed to build.'.format(

+                 ', '.join(c.package for c in module_build.component_builds

+                           if c.state in failed_states)

+             )

+             module_build.transition(config,

+                                     state=models.BUILD_STATES['failed'],

+                                     state_reason=state_reason)

          else:

              module_build.transition(config, state=models.BUILD_STATES['done'])

          session.commit()

@@ -697,13 +697,13 @@ 

              # we had a failing component in batch 2.

              elif c.package == "tangerine":

                  assert c.state == koji.BUILD_STATES['FAILED']

-                 assert c.state_reason == "Some components failed to build."

+                 assert c.state_reason == "Component(s) perl-Tangerine failed to build."

              else:

                  assert c.state == koji.BUILD_STATES['COMPLETE']

  

              # Whole module should be failed.

              assert c.module_build.state == models.BUILD_STATES['failed']

-             assert c.module_build.state_reason == "Some components failed to build."

+             assert c.module_build.state_reason == "Component(s) perl-Tangerine failed to build."

  

              # We should end up with batch 2 and never start batch 3, because

              # there were failed components in batch 2.
@@ -750,7 +750,8 @@ 

  

              # Whole module should be failed.

              assert c.module_build.state == models.BUILD_STATES['failed']

-             assert c.module_build.state_reason == "Some components failed to build."

+             assert c.module_build.state_reason == \

+                 "Component(s) perl-Tangerine, perl-List-Compare failed to build."

  

              # We should end up with batch 2 and never start batch 3, because

              # there were failed components in batch 2.

Client tool like module-build-watch and `module-build --watch' could
output failed reason. However, original message "Some components failed
to buld" is not informative enough. Instead, list package names of
failed builds would be helpful.

Signed-off-by: Chenxiong Qi cqi@redhat.com

Could you make this Component(s) instead of Components? That way the grammar is improved when it just says Component(s) perl-tangerine failed to build.

rebased onto 5c2b411

5 years ago

Commit 8bb50cf fixes this pull-request

Pull-Request has been merged by mprahl

5 years ago

Pull-Request has been merged by mprahl

5 years ago