← Back to team overview

sts-sponsors team mailing list archive

Re: [Merge] ~igor-brovtsin/maas:report-bulk-action-errors into maas:master

 


Diff comments:

> diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
> index 63b181f..d150cb5 100644
> --- a/src/maasserver/websockets/handlers/machine.py
> +++ b/src/maasserver/websockets/handlers/machine.py
> @@ -1012,25 +1012,28 @@ class MachineHandler(NodeHandler):
>  
>      def _bulk_action(
>          self, filter_params, action_name, extra_params
> -    ) -> tuple[int, list[str]]:
> +    ) -> tuple[int, list[str], dict[list[str]]]:
>          """Find nodes that match the filter, then apply the given action to them."""
>          machines = self._filter(
>              self.get_queryset(for_list=True), None, filter_params
>          )
>          success_count = 0
>          failed_system_ids = []
> +        failure_details = {}
>          for machine in machines:
>              try:
>                  self._action(machine, action_name, extra_params)
>              except NodeActionError as e:
>                  failed_system_ids.append(machine.system_id)
> +                failure_details.setdefault(str(e), [])

instead of this, make failure_details a defaultdict(list) and just do the lookup and append

> +                failure_details[str(e)].append(machine.system_id)
>                  log.error(
>                      f"Bulk action ({action_name}) for {machine.system_id} failed: {e}"
>                  )
>              else:
>                  success_count += 1
>  
> -        return success_count, failed_system_ids
> +        return success_count, failed_system_ids, failure_details
>  
>      def _bulk_clone(self, source, filter_params, extra_params):
>          """Bulk clone - special case of bulk_action."""


-- 
https://code.launchpad.net/~igor-brovtsin/maas/+git/maas/+merge/441297
Your team MAAS Maintainers is requested to review the proposed merge of ~igor-brovtsin/maas:report-bulk-action-errors into maas:master.



References