Account for deferred retirements in apply budget
This commit is contained in:
+14
-3
@@ -65,7 +65,7 @@ def build_parser():
|
||||
"--max-changes",
|
||||
type=_nonnegative_int,
|
||||
default=None,
|
||||
help="Maximum CREATE/UPDATE actions allowed with --apply",
|
||||
help="Maximum planned mutations allowed with --apply",
|
||||
)
|
||||
|
||||
sub.add_parser("plugins", help="Show the configured source/provider plugins")
|
||||
@@ -202,11 +202,21 @@ def run_reconcile(args):
|
||||
for action in plan.actions
|
||||
)
|
||||
|
||||
retirement_count = sum(
|
||||
len(plan.retirements)
|
||||
for plan in result.plans
|
||||
)
|
||||
mutation_count = (
|
||||
change_count
|
||||
+ retirement_count
|
||||
)
|
||||
|
||||
print()
|
||||
print(
|
||||
"Plan summary: "
|
||||
f"{create_count} create, "
|
||||
f"{update_count} update, "
|
||||
f"{retirement_count} retirement, "
|
||||
f"{noop_count} unchanged"
|
||||
)
|
||||
|
||||
@@ -221,10 +231,10 @@ def run_reconcile(args):
|
||||
|
||||
if (
|
||||
args.max_changes is not None
|
||||
and change_count > args.max_changes
|
||||
and mutation_count > args.max_changes
|
||||
):
|
||||
raise RuntimeError(
|
||||
f"Refusing to apply {change_count} change(s); "
|
||||
f"Refusing to apply {mutation_count} mutation(s); "
|
||||
f"--max-changes allows {args.max_changes}"
|
||||
)
|
||||
|
||||
@@ -241,6 +251,7 @@ def run_reconcile(args):
|
||||
print(
|
||||
"APPLY COMPLETE: "
|
||||
f"{len(execution.applied)} action(s) applied and verified; "
|
||||
f"{len(execution.retired)} retirement(s) completed; "
|
||||
f"{len(execution.skipped)} unchanged/skipped."
|
||||
)
|
||||
return 0
|
||||
|
||||
@@ -42,6 +42,7 @@ class ExecutedAction:
|
||||
class ExecutionResult:
|
||||
applied: tuple[ExecutedAction, ...]
|
||||
skipped: tuple[PlanAction, ...]
|
||||
retired: tuple[tuple[str, RetireRequest], ...]
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -555,6 +556,9 @@ def execute_endpoint_plans(
|
||||
retired_identities: set[
|
||||
tuple[str, str, str]
|
||||
] = set()
|
||||
retired_requests: list[
|
||||
tuple[str, RetireRequest]
|
||||
] = []
|
||||
|
||||
for endpoint_id, retirement in pending_retirements:
|
||||
retired = retirement.object
|
||||
@@ -580,8 +584,15 @@ def execute_endpoint_plans(
|
||||
)
|
||||
|
||||
retire(retirement)
|
||||
retired_requests.append(
|
||||
(
|
||||
endpoint_id,
|
||||
retirement,
|
||||
)
|
||||
)
|
||||
|
||||
return ExecutionResult(
|
||||
applied=tuple(applied),
|
||||
skipped=tuple(skipped),
|
||||
retired=tuple(retired_requests),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user