-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only add an explicit dependency on an existing resource when the deployments engine will use the GET response #15580
Open
jeskew
wants to merge
11
commits into
main
Choose a base branch
from
jeskew/15513-bis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… ResourceDependencyVisitor
Test this change out locally with the following install scripts (Action run 12017232635) VSCode
Azure CLI
|
Dotnet Test Results 78 files - 39 78 suites - 39 29m 33s ⏱️ - 15m 13s Results for commit 7f65b4d. ± Comparison against base commit c63bad7. This pull request removes 1845 and adds 659 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
# Conflicts: # src/Bicep.Core.IntegrationTests/ScenarioTests.cs
jeskew
force-pushed
the
jeskew/15513-bis
branch
from
November 15, 2024 21:28
74bd307
to
56d041c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #15513
Resolves #15686
Microsoft Reviewers: Open in CodeFlow
Bicep will normally generate an explicit dependency when one resource refers to another. For example, if the body of
b
includes a symbolic reference toa
, then in the compiled JSON template, the declaration forb
will have adependsOn
property that includesa
.However, if
a
is anexisting
resource and the template is not being compiled to language version 2.0, then the compiler will "skip over"a
and haveb
depend on whatevera
depends on. For example, for the following template:the non-symbolic name output will have
b
depend onc
.#15447 added a couple of scenarios in which Bicep would skip over an existing resource even if compiling with symbolic name support. This was done because the ARM backend will perform a
GET
request on anyexisting
resource in the template unless its body properties are never read and no deployed resource explicitly depends on it. The extraGET
requests could sometimes cause template deployments to fail, for example if the deploying principal had permission to use secrets from a key vault as part of a deployment but did not have more generic /read permissions on the vault.#15447 reused some existing logic for skipping over an intermediate existing dependency that unfortunately had an underlying bug that manifested when the skipped over resource was looped and used its loop iterator to index into the dependency once removed. For example, if we modify the earlier example slightly:
Then in the compiled output,
b
will have an explicit dependency on[resourceId('type', format('c[{0}]', copyIndex()))]
. Becauseb
is not looped, the deployment will fail. Related issues will occur ifb
indexes intoa
with a more complex expression or if there is an intervening variable.This PR updates explicit dependency generation to take all steps between a depending resource and its dependency into account when generating index expressions. For example, in the following template:
vault
will depend onvnets[(range(20, 10)[k - 11] - 20) % 2]
. Prior to this PR,vault
will instead depend onvnets[k % 2]
, which is the wrong vnet.