Sort the chunk list verifying that the chunks follow the order specified in the order options. :return: a tuple of a list of the ordered chunks and a list of errors
(
self, chunks: Iterable[LowChunk]
)
| 1601 | return _verify_high(high) |
| 1602 | |
| 1603 | def order_chunks( |
| 1604 | self, chunks: Iterable[LowChunk] |
| 1605 | ) -> tuple[list[LowChunk], list[str]]: |
| 1606 | """ |
| 1607 | Sort the chunk list verifying that the chunks follow the order |
| 1608 | specified in the order options. |
| 1609 | |
| 1610 | :return: a tuple of a list of the ordered chunks and a list of errors |
| 1611 | """ |
| 1612 | cap = 1 |
| 1613 | errors = [] |
| 1614 | disabled_reqs = self.opts.get("disabled_requisites", []) |
| 1615 | if not isinstance(disabled_reqs, list): |
| 1616 | disabled_reqs = [disabled_reqs] |
| 1617 | if not self.dependency_dag.dag: |
| 1618 | # if order_chunks was called without calling compile_high_data then |
| 1619 | # we need to add the chunks to the dag |
| 1620 | agg_opt = self.functions["config.option"]("state_aggregate") |
| 1621 | for chunk in chunks: |
| 1622 | self.dependency_dag.add_chunk( |
| 1623 | chunk, self._allow_aggregate(chunk, agg_opt) |
| 1624 | ) |
| 1625 | for chunk in chunks: |
| 1626 | chunk["name"] = salt.utils.data.decode(chunk["name"]) |
| 1627 | self._reconcile_watch_req(chunk) |
| 1628 | error = self.dependency_dag.add_requisites(chunk, disabled_reqs) |
| 1629 | if error: |
| 1630 | errors.append(error) |
| 1631 | elif "order" in chunk: |
| 1632 | if not isinstance(chunk["order"], int): |
| 1633 | continue |
| 1634 | |
| 1635 | chunk_order = chunk["order"] |
| 1636 | if chunk_order > cap - 1 and chunk_order > 0: |
| 1637 | cap = chunk_order + 100 |
| 1638 | |
| 1639 | try: |
| 1640 | # Get nodes in topological order also sorted by order attribute |
| 1641 | sorted_chunks = self.dependency_dag.aggregate_and_order_chunks(cap) |
| 1642 | except DiGraphCycle: |
| 1643 | sorted_chunks = [] |
| 1644 | cycle_edges = self.dependency_dag.get_cycles_str() |
| 1645 | errors.append(f"Recursive requisites were found: {cycle_edges}") |
| 1646 | return sorted_chunks, errors |
| 1647 | |
| 1648 | def _reconcile_watch_req(self, low: LowChunk): |
| 1649 | """ |
no test coverage detected