Skip to content

fix: Allow nested Terraform resources #1093

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

Merged
merged 2 commits into from
Apr 20, 2022
Merged

fix: Allow nested Terraform resources #1093

merged 2 commits into from
Apr 20, 2022

Conversation

kylecarbs
Copy link
Member

This fixes the dependency tree by adding recursion. It
now finds indirect connections and associates it with
an agent.

An example is attached which surfaced this issue.

This fixes the dependency tree by adding recursion. It
now finds indirect connections and associates it with
an agent.

An example is attached which surfaced this issue.
@kylecarbs kylecarbs requested a review from johnstcn April 20, 2022 03:18
@kylecarbs kylecarbs self-assigned this Apr 20, 2022
@codecov
Copy link

codecov bot commented Apr 20, 2022

Codecov Report

Merging #1093 (4aa794f) into main (e35a4fd) will decrease coverage by 0.04%.
The diff coverage is 74.54%.

@@            Coverage Diff             @@
##             main    #1093      +/-   ##
==========================================
- Coverage   66.53%   66.48%   -0.05%     
==========================================
  Files         255      255              
  Lines       15671    15675       +4     
  Branches      152      152              
==========================================
- Hits        10426    10421       -5     
- Misses       4180     4184       +4     
- Partials     1065     1070       +5     
Flag Coverage Δ
unittest-go-macos-latest 53.42% <0.00%> (-0.01%) ⬇️
unittest-go-postgres- 65.81% <74.54%> (+0.08%) ⬆️
unittest-go-ubuntu-latest 55.91% <74.54%> (+0.04%) ⬆️
unittest-go-windows-2022 52.81% <0.00%> (-0.02%) ⬇️
unittest-js 66.83% <ø> (ø)
Impacted Files Coverage Δ
provisionersdk/agent.go 100.00% <ø> (ø)
provisioner/terraform/provision.go 70.96% <74.54%> (+2.85%) ⬆️
cli/cliui/agent.go 77.19% <0.00%> (-5.27%) ⬇️
provisionerd/provisionerd.go 80.14% <0.00%> (-1.62%) ⬇️
coderd/provisionerdaemons.go 59.86% <0.00%> (-1.03%) ⬇️
peer/conn.go 78.17% <0.00%> (-1.02%) ⬇️
provisionersdk/transport.go 85.10% <0.00%> (+6.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e35a4fd...4aa794f. Read the comment docs.

Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TEMP\sshd.exe
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
$env:CODER_AUTH = "${AUTH_TYPE}"
$env:CODER_URL = "${ACCESS_URL}"
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru
`,
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪟🔌🐚

for _, dep := range resourceNode {
var has bool
agent, has := agents[dep]
if !has {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
direct[label] = dependencies
label, exists := dependencyNode.Attrs["label"]
if !exists {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// findAgents recursively searches through resource dependencies
// to find associated agents. Nested is required for indirect
// dependency matching.
func findAgents(resourceDependencies map[string][]string, agents map[string]*proto.Agent, resourceKey string) []*proto.Agent {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have an upper bound on recursion depth "just in case"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We limit payload file size, so I don't think it'd be possible to bomb it beyond 10mb.

@kylecarbs kylecarbs merged commit 65d7738 into main Apr 20, 2022
@kylecarbs kylecarbs deleted the nestedresource branch April 20, 2022 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants