G’day - we are experiencing a `fatal error: stack ...
# atmos
t
G’day - we are experiencing a
fatal error: stack overflow
when using atmos > v1.200.0. Are we up against a stack count limit? import limit? we do make use of go templates and functions (!terraform.state). Seemingly all atmos commands (describe component, validate stacks, validate schema, etc.) complete successfully, with the exception of
atmos describe stacks -s <stack>
. Recent change to cloudposse/utils v1.32.0 bumped atmos above v1.200.0, and now all of our remote-state stacks are failing with a generic terraform error
failed to find import
. Pinning utils to
v1.31.0
resolves this, which i believe uses an older atmos version < 1.200.0. Any tips for the best path to resolution? We’d like to use the latest version of atmos. TIA!
✅ 1
Reviewing some trace logs, it seems to error out
ProcessTmplWithDatasources
. Here are 2 examples:
Copy code
## atmos v1.209.0 - fail

 TRCE  Processing import structs count=0 file=workflows/okta-oidc-eks-auth.yaml track_provenance=false
 DEBU  CreateAndAuthenticateManager called identityName="" hasAuthConfig=true
 DEBU  No identity resolved, returning nil
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0x1403384a4f0 stack=[0x1403384a000, 0x1405384a000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x1058278c2?, 0x0?})
	runtime/panic.go:1094 +0x34 fp=0x16e5e2da0 sp=0x16e5e2d70 pc=0x1020c68f4
runtime.newstack()
	runtime/stack.go:1159 +0x44c fp=0x16e5e2ed0 sp=0x16e5e2da0 pc=0x1020ab6ac
runtime.morestack()
	runtime/asm_arm64.s:392 +0x70 fp=0x16e5e2ed0 sp=0x16e5e2ed0 pc=0x1020cd440

goroutine 1 gp=0x140000021c0 m=15 mp=0x14001780808 [running]:
<http://github.com/cloudposse/atmos/internal/exec.processBaseComponentConfigInternal(0x140012a8208|github.com/cloudposse/atmos/internal/exec.processBaseComponentConfigInternal(0x140012a8208>, 0x140546506e0, 0x14004e9b3e0, {0x140021054e0, 0x1c}, {0x14001520125, 0xe}, {0x14001660108, 0x13}, {0x0, ...}, ...)
	<http://github.com/cloudposse/atmos/internal/exec/stack_processor_utils.go:1246|github.com/cloudposse/atmos/internal/exec/stack_processor_utils.go:1246> +0x18ac fp=0x1403465a4f0 sp=0x1403465a4f0 pc=0x10560229c
<http://github.com/cloudposse/atmos/internal/exec.processBaseComponentConfigInternal(0x140012a8208|github.com/cloudposse/atmos/internal/exec.processBaseComponentConfigInternal(0x140012a8208>, 0x140546506e0, 0x14004e9b3e0, {0x1400185e720, 0x25}, {0x14001520125, 0xe}, {0x140021054e0, 0x1c}, {0x0, ...}, ...)
	<http://github.com/cloudposse/atmos/internal/exec/stack_processor_utils.go:1298|github.com/cloudposse/atmos/internal/exec/stack_processor_utils.go:1298> +0x364 fp=0x1403465a940 sp=0x1403465a4f0 pc=0x105600d54
There are many `ProcessTmplWithDatasources entries here:
Copy code
## atmos v1.200.0 - success
 DEBU  Skipping imported file (will be processed via parent) file=catalog/vpc/staging.yaml
 DEBU  CreateAndAuthenticateManager called identityName="" hasAuthConfig=true
 DEBU  No identity resolved, returning nil
 TRCE  ProcessTmplWithDatasources template=describe-stacks-all-sections
 TRCE  ProcessTmplWithDatasources template=describe-stacks-all-sections evaluation=1
 TRCE  ProcessTmplWithDatasources: processed template=describe-stacks-all-sections
a
@Tyler Rankin there should be no stack limits, and we have optimized Atmos to be 10x faster processing YAML files. What old Atmos version are you on now?
regarding the first issue, please execute
atmos describe stacks -s <stack> --process-templates=false --process-functions=false
to see if if solves the issue. If it does, the issue is with some of your templates. Let me know, I'll help you to debug it
--- regarding
Copy code
Recent change to cloudposse/utils v1.32.0 bumped atmos above v1.200.0, and now all of our remote-state stacks are failing with a generic terraform error failed to find import
1.31.0 used an old Atmos version (which did not detect the same issues with your stacks as the Atmos CLI). 1.32.0 uses the latest Atmos I think all of that reletaes to some issues with templates in your stacks. Let's try to debug it step by step - execute the command above an let me know
🤞 1
t
regarding the first issue, please execute
atmos describe stacks -s <stack> --process-templates=false --process-functions=false
This produces the same fatal stack overflow error, seemingly at the same spot looking at the Trace. We are now running
v1.208.0
. The above describe stacks commands fails on anything above 1.200.0
a
ok (there are some isues in the stacks that affects the Atmos CLI and the utils provider. We'd like to get to the root of it and fix (which we can reproduce using your stacks 🙂 )
atmos describe stacks -s <stack>
- does it throw the error for all stacks, or for a specific stack only?
•
atmos describe stacks -s <stack>
- does it throw the error for all your stacks, or only for specific stacks? • Find Go templates
{{ }}
in your stacks and try to disable them one by one (not sure if that's possible depending on how many of them you have) • Try to disable Go templates in your
atmos.yaml
Copy code
templates:
  settings:
    enabled: false
once we get to the root of the issue, it should 'fix' both the Atmos CLi and the utils provider (and we'll know what to improve in Atmos to not go into 'stack overflow', but print an error instead)
besides the templates, it could also relate to Atmos Auth, from the error
Copy code
DEBU  CreateAndAuthenticateManager called identityName="" hasAuthConfig=true
 DEBU  No identity resolved, returning nil
runtime: goroutine stack exceeds 1000000000-byte limit
are you using Atmos Auth?
t
Thanks for the tips. 1. this happens to all stacks 2. disabling
templates.settings.enabled
still fails the same way 3. we have a lot of
{{ }}
but did a bulk find/replace, hopefully removing all. still fails in the same 4. we are not using Atmos Auth Sorry not much help 🙂
a
this is exactly the situation why we are working on Atmos AI 🙂 • https://atmos.tools/ai/ • https://atmos.tools/examples/ai • https://github.com/cloudposse/atmos/pull/2171 But it will not work for you (it's in the latest Atmos version, and the
--ai
flag is not relased yet)
🤓 1
anyway, can I ask you to share your stacks with me? (e.g. DM me). we'll be able to find the issue and fix it fast. If not possible, maybe some parts of the stacks which still throw the same error?
t
interesting - i just make a pretty empty stack file without any imports and it still errored on 1.209.0. Again, switching to 1.200.0 was successful, it returned
{}
. Here’s the file:
Copy code
settings:
  spacelift:
    autodeploy: true
    space_id: space-dev-id
    labels:
      - tenant:customer
      - environment:gbl
      - stage:dev
    local_preview_enabled: true

vars:
  stage: dev

terraform:
  vars: {}

components: {}
We are seeing this on our spaceift CI runs as well, so i don’t think it is just my machine. Would there be any clues in the atmos config file?
atmos.ayml
a
please review this doc https://atmos.tools/changelog/base-path-behavior-change please set
base_path: "."
in
atmos.yaml
and try again let me know if it's working for you. If not, we'll continue debugging
t
No change when setting
base_path
or not
a
i just make a pretty empty stack file without any imports and it still errored on 1.209.0. Again, switching to 1.200.0 was successful, it returned
{}
. Here’s the file:
do you have just this one file, or all other stacks are still in the repo when you tested it?
t
Just the one, but I had the catalog files present. I think there is some issue with templating / imports as you mentioned. I will try to narrow it down by removing files that use these and see how it goes adding them back. We also make use of yaml anchors and abstract component definitions. Lots of import processing to get us to our final values 🥲
a
if you find the file(s) that is causing the issue, please share with me (yes, the best way to debug is to remove and then add all YAML manifests. To speed it up exponentially, you can use
Copy code
The half-split troubleshooting technique isolatess faults by systematically dividing a system, process, or code in half to locate the issue. By testing at the midpoint, you determine if the issue is in the first or second half, eliminating 50% of possibilities with each check. This methodical approach continues, cutting the remaining faulty segment in half until the problem is identified.
t
Might be on to something. We have a number of abstract components where we set defaults that get inherited elsewhere. It seems like we are setting the component within
metadata
on the abstract definitions - is that necessary? For instance we have:
Copy code
components:
  terraform:
    iam-delegated-roles-defaults:
      metadata:
        component: iam-delegated-roles
        type: abstract

    iam-delegated-roles:
      metadata:
        component: iam-delegated-roles
        type: real
        inherits:
          - iam-delegated-roles-defaults
When i remove
metadata.component
from
iam-delegated-roles-defaults
the
atmos describe stacks
command completes!!
Yet still, my in-repo terraform plans that use remote-state are continuing to fail. I have
ATMOS_BASE_PATH
being set to the monorepo module path on the spacelift worker - and am reproducing the same error locally
Copy code
│ Error: failed to find import
│ 
│   with module.account_map.data.utils_component_config.config[0],
│   on .terraform/modules/account_map/modules/remote-state/main.tf line 1, in data "utils_component_config" "config":
│    1: data "utils_component_config" "config" {
│
a
remove
metadata.component
from
iam-delegated-roles-defaults
the
atmos describe stacks
command completes
is it working with the latest atmos version? if it is, then we'll review the code - it should not panic when you have
metadata.component
on
type: abstract
thanks for reporting
also, please now try the latest
utils
provider
1.33.0
and let me know the result
@Tyler Rankin
t
The stack overflow when running describe stacks seems to be resolved. Not sure if it contributed to the issue but some of the inherited components use !terraform.state in their definitions. However, terraform plan still fails on latest utils. It just gives that generic import error. I can see the cloned monorepo in the path we expect, and if I do
terraform console
I am even able to see the correct values for module.account_map. This error is still an atmos query not working correctly?
a
The stack overflow when running describe stacks seems to be resolved. Not sure if it contributed to the issue but some of the inherited components use !terraform.state in their definitions.
what did you do to solve this issue? did you just remove
component: iam-delegated-roles
from the abstract components, e.g.
Copy code
iam-delegated-roles-defaults:
      metadata:
        component: iam-delegated-roles
        type: abstract
or someting else?
t
That’s correct. i just removed
metadata.component
from the abstract components. I had to do this on 2
iam-delegated-roles
, and
eks
. I think there are some dependencies between the two, but once they are both removed the atmos commands complete. I can probably share these files in DM
a
we can review and fix that, thanks for finding.
metadata.component
on abstract components does not do anything (since the abstract components can't be applied), but it should not fail as well I'll let you know if we need your files
🙌 1
regarding the utils provider, please run it again, make sure the latest provider gets installed (1.33.0), and share the terraform output with the error
t
Yes - confirming. Atmos v1.209.0, utils 1.33.0
e
@Andriy Knysh (Cloud Posse)
metadata.component
on abstract components does not do anything (since the abstract components can't be applied), b
But now with metadata inheritance it should "do something": populate the default component
t
Here is a snippet from utils v1.31.0, which plans successfully. I need to compare this on a failed run but i am making note of the EOF right before the utils provider exits
Here is a snippet from utils v1.33.0 - something is failing to get setup (before the remote state call i am guessing?) because this fails before the provider exits
a
thanks @Tyler Rankin
>
metadata.component
on abstract components does not do anything (since the abstract components can't be applied), b
But now with metadata inheritance it should "do something": populate the default component
yes after we merged the PR for
metadata
inheritance, it introduced some changes which affected the @Tyler Rankin infra. i'll open a PR for the fix soon
🙌 1
t
Do you expect that will correct the
failed to find import
error here as well? I’m not sure i’m headed in the right path, and feel this might be devolving from
atmos
but i do notice there are a couple differences on the terraform packages being installed, some with recent breaking changes: •
cloudposse/utils v1.31.0
◦ terraform-plugin-go@v0.27.0 ◦ terraform-plugin-sdk@2v2.37.0 •
cloudposse/utils v1.33.0
◦ terraform-plugin-go@v0.31.0 ◦ terraform-plugin-sdk@2v2.40.0 https://github.com/hashicorp/terraform-plugin-go/releases https://github.com/hashicorp/terraform-plugin-sdk/releases
a
failed to find import
- I'll get to it next (it's prob not related to the fix for
fatal error: stack overflow
at all)
t
Let me know if there’s anything else I can provide. We are either pinning a lot of versions.tf files or finding a better way to manage these dependencies so that we aren’t affected by changes like this in the future. And I want to be sure it isn’t a config we are missing on our end.
a
@Tyler Rankin the fix for
fatal error: stack overflow
is in the new release - please try it out https://github.com/cloudposse/atmos/releases/tag/v1.210.0 https://github.com/cloudposse/atmos/pull/2214
t
I continue to get a stack overflow on 1.210.0, but we can move past that i will just remove all
metadata.component
references from our abstract definitions
e
@Andriy Knysh (Cloud Posse) we should still try to get to the bottom of this
a
@Tyler Rankin w/o your stacks, I'm not sure we can find the issue - we have a lot of tests that exercise all of that including
metadata.component
in abstract components help us to understand the issue
👍 1
t
Can we focus on the failed import error from the remote-state / utils lookup?
a
do you see the issue on CI, or locally as well?
regarding the failed import, https://github.com/cloudposse/atmos/pull/2215 we'll release it as a patch release soon
👀 1
t
CI shows the same. I’m trying to pass in skip-functions functionality (we forked https://github.com/cloudposse/github-action-atmos-affected-trigger-spacelift/tree/main)
we’ll release it as a patch release soon
Then
cloudposse/utils
will pickup that patch release? Trying to get the dependencies straight in my mind
a
we'll release Atmos, then a new utils provider (it uses the Atmos code)
🫡 1
c
@Andriy Knysh (Cloud Posse) Something wrong with the
cloudposse/utils
v2.2.0 checksums I'm getting this error during
terraform init
Copy code
Error while installing cloudposse/utils v2.2.0: checksum list has unexpected SHA-256 hash 1f75418c5a89d8f6fd95b9dd58903574cf8b2c58fdd9dddf21a019d2d7da34d (expected c4f8282b0664d27f4c475a800c244a87fd844e73b67aeb737d8479f84fe8b155)
a
@Igor Rodionov can you please take a look at this?
i
let me cut new release
a
please cut a new v2 release, and 1.210.1 as well
i
@Andriy Knysh (Cloud Posse) may I have an approval https://github.com/cloudposse/terraform-provider-utils/pull/534 ?
a
approved
but we also need to be able to cut v1 releases
🤞 1
t
I upgraded
remote-state
to v2, but i still receive failed to find import on terraform plan (with utils using v2.3.0), when setting
ATMOS_BASE_PATH
to relative path from CWD. It succeeds with absolute path
e
We're still working on publishing the updated provider.
There's some issue with the release process. I'd expect it to be fixed in the next one to two hours.
🙌 1
cc @Igor Rodionov
a
@Tyler Rankin apologies for all the issues, let's get to the bottom of it and fix it Can I ask you to run it again using the latest Atmos 1.210.1 and the latest utils provider 2.3.0, and report the issues, show the error
t
I want to be sure i’m understanding this correctly - my version of atmos almost doesn’t’ matter right? We run atmos in spacelift to generate the tf vars file, and then spacelift just run
terraform plan <vars-file>
. The remote-state module calls the utils provider which ultimately defines the version of atmos. Assuming I have that correct - my terraform plan still fails.
Copy code
module.yaml_config.module.maps_deepmerge.data.utils_deep_merge_yaml.all_map_configs: Reading...
module.yaml_config.module.maps_deepmerge.data.utils_deep_merge_yaml.all_map_configs: Read complete after 0s [id=02338e6bebdc5adb05d28a654095b7397a2cad9e]

Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: failed to find import
│ 
│   with module.account_map.data.utils_component_config.config[0],
│   on .terraform/modules/account_map/modules/remote-state/main.tf line 1, in data "utils_component_config" "config":
│    1: data "utils_component_config" "config" {
│ 
╵
╷
│ Error: failed to find import
│ 
│   with module.iam_roles.module.account_map.data.utils_component_config.config[0],
│   on .terraform/modules/iam_roles.account_map/modules/remote-state/main.tf line 1, in data "utils_component_config" "config":
│    1: data "utils_component_config" "config" {
│ 
╵
Releasing state lock. This may take a few moments...
 ⧉  BrightAI 
 √ . [bai-mgmt-gbl-identity-admin] (HOST) terraform ⨠ echo $ATMOS_BASE_PATH
.terraform/modules/monorepo
a
utils provider 2.3.0?
(your understanding about Atmos CLI version is correct)
t
yes
Copy code
√ . [bai-mgmt-gbl-identity-admin] (HOST) terraform ⨠ terraform version
Terraform v1.5.7
on linux_arm64
+ provider <http://registry.terraform.io/cloudposse/template|registry.terraform.io/cloudposse/template> v2.2.0
+ provider <http://registry.terraform.io/cloudposse/utils|registry.terraform.io/cloudposse/utils> v2.3.0
+ provider <http://registry.terraform.io/hashicorp/aws|registry.terraform.io/hashicorp/aws> v6.37.0
+ provider <http://registry.terraform.io/hashicorp/external|registry.terraform.io/hashicorp/external> v2.3.5
+ provider <http://registry.terraform.io/hashicorp/http|registry.terraform.io/hashicorp/http> v3.5.0
+ provider <http://registry.terraform.io/hashicorp/local|registry.terraform.io/hashicorp/local> v2.7.0
+ provider <http://registry.terraform.io/hashicorp/time|registry.terraform.io/hashicorp/time> v0.13.1

Your version of Terraform is out of date! The latest version
is 1.14.7. You can update by downloading from <https://www.terraform.io/downloads.html>
if i use absolute path it works
a
ok, thanks again, let me get to it
t
@Andriy Knysh (Cloud Posse) are you able to repro or should we consider switching to absolute paths in our environment?
a
we fixed it in a PR and merged to main. we'll cut a new Atmos release next week, then update the provider to use it
🙌 1
(sorry, the fix is in the Atmos
main
branch, but not in the provider yet, so you can't test it yet)
t
excellent! Thank you!
i
Here is the postmortem about the issue
Copy code
Error while installing cloudposse/utils v2.2.0: checksum list has unexpected SHA-256 hash 1f75418c5a89d8f6fd95b9dd58903574cf8b2c58fdd9dddf21a019d2d7da34d (expected c4f8282b0664d27f4c475a800c244a87fd844e73b67aeb737d8479f84fe8b155)
https://github.com/cloudposse/terraform-provider-utils/issues/536
c
Nice. When I get my paycheck?
e
Appreciate everyone helping surface issues here—it really helps us move quickly 🙏
t
@Andriy Knysh (Cloud Posse) we still get failed to find import on the new utils v1.34.0. i think at this point, if there are no ill effects, we will migrate to absolutely path
a
@Tyler Rankin we have not released a new provider version yet, just a new Atmos release https://github.com/cloudposse/atmos/releases/tag/v1.211.0 (30 mins ago) we'll release new provider tomorrow morning
🙌 1
t
ah, got it. apologies! I saw the 1.34 release an hour ago and thought that might’ve held the key.
a
@Tyler Rankin one more attempt 🙂 We have released: • https://github.com/cloudposse/terraform-provider-utils/releases/tag/v2.5.0 • https://github.com/cloudposse/atmos/releases/tag/v1.211.0 Can I ask you to test it (before we release a new version v1 of the utils provider)? You mentioned before that you were able to test utils provider v2 Thank you
party parrot 1
t
v2.5.0 looks good!
Copy code
- Installing cloudposse/utils v2.5.0...
- Installed cloudposse/utils v2.5.0 (self-signed, key ID 7B22D099488F3D11)
I kept my relative path set in
ATMOS_BASE_PATH
during the spacelift run and the plan completed successfully
a
finally, we did it 🙂
👏 1
thanks for staying with me
we'll release a new v1 version of the provider today
i
@Andriy Knysh (Cloud Posse) @Tyler Rankin we cut 1.35.0 release for utils provider
✅ 1
t
Awesome, thank you all! I just ran a successful plan on v1 🎉
e
Excellent! 😌