actions: fix cycle when multiple actions are triggered across multiple events #37591
+37
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug in actions that occurs when multiple actions target multiple events. When we were connecting edges in the apply graph, between action invocations, we make sure that actions that are defined "later" in the configuration execute after actions that are defined earlier. But, this only matters if the actions are defined within the same "triggering event", an action that is triggered "after_create" should always happen after a "before_create" action. If an "after_create" action was defined before a "before_create" action, we'd get a cycle as the logic would draw an edge between those actions.
This PR updates the logic for working out those edges, and only draws edges between nodes within the same trigger. Nodes in different triggers are already connecting to the actual resource in the correct ordering so we can simply exclude actions in different triggers.
In addition, this fixes a small n^2 operation against the number of action invocations in the configuration, instead we map the actions to the triggering resource and we don't need to iterate through all the action invocations to find the ones that are mapped against the same resource.
Target Release
1.14.x
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
CHANGELOG entry