Skip to content
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

RecursionError: maximum recursion depth exceeded during pulumi up #11887

Closed
piotr-bzdyl-vertexinc opened this issue Jan 17, 2023 · 5 comments
Closed
Labels
area/sdks Pulumi language SDKs awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec language/python p2 Bugs of moderate severity to be assigned to an engineer in the next iteration resolution/no-repro This issue wasn't able to be reproduced

Comments

@piotr-bzdyl-vertexinc
Copy link

What happened?

pulumi up failed with:

error: Program failed with an unhandled exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/pulumi/3.43.1/x64/pulumi-language-python-exec", line 179, in <module>
    loop.run_until_complete(coro)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/work/taxamo-infrastructure-github/taxamo-infrastructure-github/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
    await run_pulumi_func(lambda: Stack(func))
  File "/home/runner/work/taxamo-infrastructure-github/taxamo-infrastructure-github/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
    await wait_for_rpcs()
  File "/home/runner/work/taxamo-infrastructure-github/taxamo-infrastructure-github/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 73, in wait_for_rpcs
    await RPC_MANAGER.rpcs.pop()
RecursionError: maximum recursion depth exceeded

Steps to reproduce

I'm not sure - it happens sometimes in a program managing >2k resources (most of them managed by Github and AWS providers). When I tried to check the actual number of the resources @ https://app.pulumi.com, it was really slow to render so maybe it's related to slowness/issues of https://app.pulumi.com.

Expected Behavior

No RecursionError.

Actual Behavior

RecursionError occurs.

Output of pulumi about

pulumi up is run on Github Actions: pulumi cli version 3.43.1.

From my local machine:

$ pulumi about
CLI          
Version      3.51.1
Go Version   go1.19.5
Go Compiler  gc

Plugins
NAME       VERSION
aws        5.17.0
github     5.0.0
python     unknown
terraform  5.6.7
tls        4.6.1

...

Dependencies:
NAME              VERSION
deepdiff          6.2.1
pip               22.2.2
pulumi-aws        5.17.0
pulumi-github     5.0.0
pulumi-terraform  5.6.7
pulumi-tls        4.6.1
pydantic          1.10.2
setuptools        63.4.3

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@piotr-bzdyl-vertexinc piotr-bzdyl-vertexinc added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 17, 2023
@dixler
Copy link
Contributor

dixler commented Jan 17, 2023

Hi. Thanks for filing this. I'll try reproducing this in python.

I'd suggest taking a look at the PULUMI_SKIP_CHECKPOINTS environment variable. It can improve performance of large stacks at the cost of not checkpointing on every operation that is performed. It should go much faster, but if the update fails, fixing the state may be more complicated.
blog

@dixler dixler added area/sdks Pulumi language SDKs language/python p1 Bugs severe enough to be the next item assigned to an engineer and removed needs-triage Needs attention from the triage team labels Jan 17, 2023
@Frassle
Copy link
Member

Frassle commented Jan 17, 2023

Given this crashed in Python code I'd expect PULUMI_SKIP_CHECKPOINTS to have no effect on solving it.

I think the stacktrace in this case is mis-leading. RPC_MANAGER.rpcs is a list of awaitables (generally asyncio futures), and awaiting an awaitable that has failed re-throws the exception but with the stacktrace of the await statement, not the original.

We should probably see if that can be tweaked so that we can get stacktraces of where the recursion limit was actually broken.

abhinav added a commit that referenced this issue Jan 18, 2023
When the `await RPC_MANAGER.rpcs.pop()` explodes,
the traceback is for `RPC_MANAGER.rpcs.pop()`, e.g.

```
error: Program failed with an unhandled exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/pulumi/3.43.1/x64/pulumi-language-python-exec", line 179, in <module>
    loop.run_until_complete(coro)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
    await run_pulumi_func(lambda: Stack(func))
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
    await wait_for_rpcs()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 73, in wait_for_rpcs
    await RPC_MANAGER.rpcs.pop()
RecursionError: maximum recursion depth exceeded
```

This isn't super helpful in debugging these errors.

RPC_MANAGER already tracks uncaught excpetions from such RPCs
but wait_for_rpcs doesn't account for these until aftewards.

This changes wait_for_rpcs to reproduce the original tracebacks
when it encounters errors in waiting for RPCs.

The included test verifies that the more helpful traceback is produced.

Refs #11887
@abhinav
Copy link
Contributor

abhinav commented Jan 18, 2023

We should probably see if that can be tweaked so that we can get stacktraces of where the recursion limit was actually broken.

Trying to get a better stack trace here in #11911, but looking at the related code,
it seems that the original stack trace was also logged somewhere by RPC_MANAGER.
Access to that would help debug this issue.
If the logs aren't accessible, then we'll probably need #11911 to debug this.

abhinav added a commit that referenced this issue Jan 19, 2023
When the `await RPC_MANAGER.rpcs.pop()` explodes,
the traceback is for `RPC_MANAGER.rpcs.pop()`, e.g.

```
error: Program failed with an unhandled exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/pulumi/3.43.1/x64/pulumi-language-python-exec", line 179, in <module>
    loop.run_until_complete(coro)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
    await run_pulumi_func(lambda: Stack(func))
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
    await wait_for_rpcs()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 73, in wait_for_rpcs
    await RPC_MANAGER.rpcs.pop()
RecursionError: maximum recursion depth exceeded
```

This isn't super helpful in debugging these errors.

RPC_MANAGER already tracks uncaught excpetions from such RPCs
but wait_for_rpcs doesn't account for these until aftewards.

This changes wait_for_rpcs to reproduce the original tracebacks
when it encounters errors in waiting for RPCs.

The included test verifies that the more helpful traceback is produced.

Refs #11887
bors bot added a commit that referenced this issue Jan 19, 2023
11911: sdk/py/stack: Original traceback in wait_for_rpcs r=abhinav a=abhinav

When the `await RPC_MANAGER.rpcs.pop()` explodes,
the traceback is for `RPC_MANAGER.rpcs.pop()`, e.g.

```
error: Program failed with an unhandled exception:
Traceback (most recent call last):
  File "/opt/hostedtoolcache/pulumi/3.43.1/x64/pulumi-language-python-exec", line 179, in <module>
    loop.run_until_complete(coro)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
    await run_pulumi_func(lambda: Stack(func))
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
    await wait_for_rpcs()
  File "[..]/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 73, in wait_for_rpcs
    await RPC_MANAGER.rpcs.pop()
RecursionError: maximum recursion depth exceeded
```

This isn't super helpful in debugging these errors.

RPC_MANAGER already tracks uncaught excpetions from such RPCs
but wait_for_rpcs doesn't account for these until aftewards.

This changes wait_for_rpcs to reproduce the original tracebacks
when it encounters errors in waiting for RPCs.

The included test verifies that the more helpful traceback is produced.

Refs #11887


Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
bors bot added a commit that referenced this issue Jan 19, 2023
11803: Display text-based diff if yaml/json diff is semantically equal r=aq17 a=aq17

Fixes #11799 

#9380 and #9484 introduced changes that render JSON/YAML parsable strings as objects in diffs – therefore, examples such as`"foo:\n  bar: {}\n  baz: {}\n"` and `"#foo\nfoo:\n  bar: {}\n  baz: {}\n"` are recognized as equal.

This change causes the display to fall back to showing the text-based diff if the JSON/YAML rendering does not indicate any diff.
It also prints all object keys even if the value is empty, i.e. `bar: {}` or `bar: ""` will be printed instead of `bar` being omitted.

11893: update package details anchors r=sean1588 a=sean1588

fixes: pulumi/registry#1819

OK taking this for round 2. The first [PR](#11861) to make this change I ended up reverting because there were some pages (the function pages and module pages) still being generated with empty href tags. 

I have addressed this and updated the change to define the DisplayName and RepositoryName props on the `packageDetails` struct for the individual module pages and function pages. This updates the repository anchor in the Package Details section of the api docs pages. I updated it to display `<package name> repository` for the anchor text in place of the url that was previously shown there. 

![image](https://user-images.githubusercontent.com/16751381/213036900-2938a9ad-1992-4170-9b83-0fbbcef409a0.png)

So now this will show the following on the following pages:
1. the root index package pages
2. the module pages
3. the resource pages
4. the function pages

11903: ApplyT: Coerce new type wrappers r=abhinav a=abhinav

Adds support to ApplyT to automatically coerce new type wrappers
when calling the provided functions.

With this change, the following is valid:

    var idout pu.IDOutput = ...
    idout.ApplyT(func(id string) string {
        // ...
    })

Note that this does not use `To{Type}Output` methods at this time.
We will likely want to add that in the future given #11750.
We can do that in a backwards compatible way.

This coerces only those values that are defined
with language-level type wrappers in the following form:

    type ID string

This *does not* coerce types with different undedrlying representations.
Specifically, the following conversons are not supported
even though they're supported by Go using the `T(v)` syntax.

    string => int
    string => []byte
    []byte => string

The choice to convert between these types
should be made explicitly by the user
so that they get the semantics they want.

Resolves #11784


11922: ci: freeze 3.52.1 for release r=dixler a=dixler

Patch release to provide better stack traces for python #11887

Co-authored-by: aq17 <aqiu@pulumi.com>
Co-authored-by: Sean Holung <sean.holung@gmail.com>
Co-authored-by: Robbie McKinstry <robbie@pulumi.com>
Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
Co-authored-by: Kyle Dixler <kyle@pulumi.com>
@dixler
Copy link
Contributor

dixler commented Jan 19, 2023

Hi, @piotr-bzdyl-vertexinc we're cutting a release v3.52.1. If you upgrade your pulumi program's python SDK to that version when it's released, it should contain a better stack trace that you can post here.

@dixler dixler added awaiting-feedback Blocked on input from the author p2 Bugs of moderate severity to be assigned to an engineer in the next iteration and removed p1 Bugs severe enough to be the next item assigned to an engineer labels Jan 20, 2023
@abhinav abhinav removed their assignment Feb 28, 2023
@justinvp justinvp added the resolution/no-repro This issue wasn't able to be reproduced label Mar 31, 2023
@justinvp
Copy link
Member

Hi @piotr-bzdyl-vertexinc, since we haven't heard back, I'm going to close this issue. If you are able to upgrade your program's Pulumi Python SDK and are still seeing an error, please open a new issue with the improved stack trace (or reopen this issue). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks Pulumi language SDKs awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec language/python p2 Bugs of moderate severity to be assigned to an engineer in the next iteration resolution/no-repro This issue wasn't able to be reproduced
Projects
None yet
Development

No branches or pull requests

5 participants