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

Python: Use async invokes to avoid hangs and stalls #2863

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

justinvp
Copy link
Member

@justinvp justinvp commented Mar 7, 2024

pulumi 3.109.0 introduces a new invoke_async function (pulumi/pulumi#15602) that allows calling invokes asynchronously. This change updates the Kubernetes Python SDK's yaml, helm, and kustomize components to use invoke_async to avoid hangs and stalls in resource registrations which severely limits parallelism.

It'd also be great to add some new tests (to complement existing tests), but I don't want to block on getting a fix out to customers:

  1. A test similar to the repro of the hang in Python program can hang when creating a helm Chart component with explicit provider pulumi#15462. It's difficult to repro this without mocking, though.
  2. Some kind of benchmark that demonstrates this improves performance.

Fixes pulumi/pulumi#15462
Fixes pulumi/pulumi#15591

pulumi 3.109.0 introduces a new `invoke_async` function that allows calling invokes asynchronously. This change updates the Kubernetes Python SDK's `yaml`, `helm`, and `kustomize` components to use `invoke_async` to avoid hangs and stalls in resource registrations which severely limits parallelism.
@@ -518,7 +518,7 @@ Use the navigation below to see detailed documentation for each of the supported
})
pkg.Language["python"] = rawMessage(map[string]any{
"requires": map[string]string{
"pulumi": ">=3.25.0,<4.0.0",
"pulumi": ">=3.109.0,<4.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, instead of bumping the min required version, we could dynamically check whether invoke_async exists in pulumi.runtime, and fallback to the old implementations if it's unavailable. That does add some complexity, though.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about that as well. I think that bumping the min version is probably a better idea, as it will ensure that the actual fix gets out into the world sooner. Otherwise we'd need to tell people to update p/p explicitly.

Copy link

github-actions bot commented Mar 7, 2024

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 25.46%. Comparing base (b7750fc) to head (065cf05).

Files Patch % Lines
provider/pkg/gen/schema.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2863   +/-   ##
=======================================
  Coverage   25.46%   25.46%           
=======================================
  Files          48       48           
  Lines        7532     7532           
=======================================
  Hits         1918     1918           
  Misses       5456     5456           
  Partials      158      158           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pgavlin
Copy link
Member

pgavlin commented Mar 7, 2024

  1. A test similar to the repro of the hang in Python program can hang when creating a helm Chart component with explicit provider pulumi#15462. It's difficult to repro this without mocking, though.
  2. Some kind of benchmark that demonstrates this improves performance.

I think both of these are relatively simple to do with mocks. we can definitely do these as a follow-up.

@@ -518,7 +518,7 @@ Use the navigation below to see detailed documentation for each of the supported
})
pkg.Language["python"] = rawMessage(map[string]any{
"requires": map[string]string{
"pulumi": ">=3.25.0,<4.0.0",
"pulumi": ">=3.109.0,<4.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about that as well. I think that bumping the min version is probably a better idea, as it will ensure that the actual fix gets out into the world sooner. Otherwise we'd need to tell people to update p/p explicitly.

@justinvp justinvp marked this pull request as ready for review March 7, 2024 22:15
Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

LGTM. I assume we should update the pu/pu dependency to v3.109.0 (once available), as part of this PR or as a prerequisite.
Update: I'll handle the broader pu/pu update in a follow-up PR: #2866

@justinvp justinvp merged commit e174e29 into master Mar 7, 2024
20 checks passed
@justinvp justinvp deleted the justin/python_invoke_async branch March 7, 2024 23:43
@EronWright EronWright added this to the 0.101 milestone Mar 7, 2024
EronWright added a commit that referenced this pull request Mar 8, 2024
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

<!--Give us a brief description of what you've done and what it solves.
-->

A follow-up to #2863 to
upgrade to pu/pu v3.109.0 across the board.

### Related issues (optional)

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes
#1234'.
Or link to full URLs to issues or pull requests in other GitHub
repositories. -->
rquitales pushed a commit that referenced this pull request Mar 13, 2024
pulumi 3.109.0 introduces a new `invoke_async` function
(pulumi/pulumi#15602) that allows calling
invokes asynchronously. This change updates the Kubernetes Python SDK's
`yaml`, `helm`, and `kustomize` components to use `invoke_async` to
avoid hangs and stalls in resource registrations which severely limits
parallelism.

It'd also be great to add some new tests (to complement existing tests),
but I don't want to block on getting a fix out to customers:
1. A test similar to the repro of the hang in
pulumi/pulumi#15462. It's difficult to repro
this without mocking, though.
2. Some kind of benchmark that demonstrates this improves performance.

Fixes pulumi/pulumi#15462
Fixes pulumi/pulumi#15591

(cherry picked from commit e174e29)
rquitales pushed a commit that referenced this pull request Mar 13, 2024
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

<!--Give us a brief description of what you've done and what it solves.
-->

A follow-up to #2863 to
upgrade to pu/pu v3.109.0 across the board.

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes
Or link to full URLs to issues or pull requests in other GitHub
repositories. -->

(cherry picked from commit 7246ed3)
lumiere-bot bot added a commit to coolguy1771/home-ops that referenced this pull request Mar 26, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@pulumi/kubernetes](https://pulumi.com)
([source](https://togithub.com/pulumi/pulumi-kubernetes)) | dependencies
| patch | [`4.9.0` ->
`4.9.1`](https://renovatebot.com/diffs/npm/@pulumi%2fkubernetes/4.9.0/4.9.1)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>pulumi/pulumi-kubernetes (@&#8203;pulumi/kubernetes)</summary>

###
[`v4.9.1`](https://togithub.com/pulumi/pulumi-kubernetes/blob/HEAD/CHANGELOG.md#491-March-13-2024)

[Compare
Source](https://togithub.com/pulumi/pulumi-kubernetes/compare/v4.9.0...v4.9.1)

- Use async invokes to avoid hangs/stalls in Python `helm`, `kustomize`,
and `yaml` components
([pulumi/pulumi-kubernetes#2863)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDQuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI1Ny4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants