-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
import blocks are evaluated in the root module #33897
Conversation
Even though import block evaluation is done in conjunction with their target resource block, their evaluation scope must always be the containing module of the import block. Since import blocks currently are only valid in the root module, that means the context must always always be the root module.
It looks like |
When an import block is being evaluated by a resource within a module, the references for the import evaluation must be scoped to the root module where the block was written. In order to accomplish that without adding a new import node type to the graph, we instead can opt to add a new method which separates the import references from the config references. The ReferenceTransformer can then use the correct root module path to lookup the referenced subjects when they come from ImportReferences as opposed to References.
I decided to handle the reference scope directly in this PR since it wasn't too daunting of a change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as to why the first commit only failed the race tests. I also couldn't replicate that failure locally.
It wasn't specifically a race condition that failed, it just happened to fail an import test during that run. Without the correctly scoped references, there wasn't anything preventing the import block form being evaluated before any of its dependencies. |
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
Shouldn't merging this have closed #33896 automatically? |
GH is experiencing some delays processing PR related events. Notification are coming in late too |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Even though import block evaluation is done in conjunction with their target resource block, their evaluation scope must always be the containing module of the import block. Since import blocks currently are only valid in the root module, that means the context must always always be the root module.
The references for the import evaluation must also be scoped to the root module where the block was written. In order to accomplish that without adding a new import node type to the graph, we instead can opt to add a new method (and associated
GraphNodeImportReferencer
interface) which separates the import references from the config references. TheReferenceTransformer
can then use the correct root module path to lookup the referenced subjects when they come fromImportReferences
as opposed toReferences
.Fixes #33896