-
Notifications
You must be signed in to change notification settings - Fork 44
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
Allow tfgen to use pulumi convert for examples conversion #1401
Conversation
Diff for pulumi-azuread with merge commit 0679f5a |
Diff for pulumi-random with merge commit 0679f5a |
@Frassle @iwahbe @mjeffryes @mikhailshilkov This is rough around the edges but it's promising. I've got it to render pulumi-gcp example set through the new converter engaged out of process via
We can parallelize it to stand up N*CPU copies. Before parallelization as things stand the total timings for schema generation with this on GCP are:
That's not bad we can take that. The appeal of the new converter is high. |
The annoying bits:
|
On the positive side, the code shouldn't panic so we don't need to inject recover and lose track panics. I will hook up example metrics to get them right (that's on the TODO). Perhaps could also push through a bulk examples.json interface for all the other converters (ts,py,yaml,java,cs)? Or is that too ambitious? |
440d362
to
99b08cd
Compare
Diff for pulumi-random with merge commit 4ea49c1 |
Diff for pulumi-azuread with merge commit 4ea49c1 |
Diff for pulumi-random with merge commit 6ab56be |
Diff for pulumi-azuread with merge commit 6ab56be |
def6b6c
to
9ab59aa
Compare
Diff for pulumi-random with merge commit de3eab7 |
Diff for pulumi-azuread with merge commit de3eab7 |
Diff for pulumi-random with merge commit 8eed677 |
Diff for pulumi-azuread with merge commit 8eed677 |
Diff for pulumi-random with merge commit 74e9ffa |
Diff for pulumi-azuread with merge commit 74e9ffa |
limit reached on GitHub API is resolved; was a bug in this code. A few more low level issues are resolved. This is working better. |
Diff for pulumi-random with merge commit 33f79a8 |
Diff for pulumi-azuread with merge commit 33f79a8 |
Codecov Report
@@ Coverage Diff @@
## master #1401 +/- ##
==========================================
+ Coverage 57.01% 57.37% +0.36%
==========================================
Files 147 147
Lines 24400 24714 +314
==========================================
+ Hits 13911 14180 +269
- Misses 9505 9527 +22
- Partials 984 1007 +23
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Diff for pulumi-random with merge commit 0e7435a |
Diff for pulumi-azuread with merge commit 0e7435a |
bf6dcc4
to
e046f4e
Compare
Diff for pulumi-azuread with merge commit 9d47b37 |
Diff for pulumi-azuread with merge commit 837c1cd |
Diff for pulumi-random with merge commit 9d47b37 |
Diff for pulumi-random with merge commit 837c1cd |
Diff for pulumi-azuread with merge commit 42a5c98 |
Diff for pulumi-random with merge commit 42a5c98 |
Diff for pulumi-azuread with merge commit 7b2c036 |
Diff for pulumi-random with merge commit 7b2c036 |
Diff for pulumi-azuread with merge commit 79ed526 |
Diff for pulumi-random with merge commit 79ed526 |
@@ -106,3 +106,4 @@ tfgen, the command that generates Pulumi schema/code for a bridged provider supp | |||
* `PULUMI_SKIP_MISSING_MAPPING_ERROR`: If truthy, tfgen will not fail if a data source or resource in the TF provider is not mapped to the Pulumi provider. Instead, a warning is printed. Default is `false`. | |||
* `PULUMI_SKIP_EXTRA_MAPPING_ERROR`: If truthy, tfgen will not fail if a mapped data source or resource does not exist in the TF provider. Instead, warning is printed. Default is `false`. | |||
* `PULUMI_MISSING_DOCS_ERROR`: If truthy, tfgen will fail if docs cannot be found for a data source or resource. Default is `false`. | |||
* `PULUMI_CONVERT`: If truthy, tfgen will shell out to `pulumi convert` for converting example code from TF HCL to Pulumi PCL |
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.
Do we expect to use this ourselves?
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.
Yes. The idea is to roll this out to Tier 1 providers as soon as we can. In terms of retiring this flag, we'd need to make sure our entire fleet has migrated (including Tier 2-3) and then stakeholders and community have migrated, then we can retire it and make it the default.
// This may need to be coarse-grain parallelized to speed up larger providers at the cost of more | ||
// memory, for example run 4 instances of `pulumi convert` on 25% of examples each. |
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 would prefer if this kind of speedup could happen in the engine, where we just pass the number of concurrent processes to run at once. It is safe to parallelize within process because there is no shared mutable state.1
Footnotes
-
If there is shared mutable state, then parallelizing by process splitting will be non-deterministic. ↩
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.
It is safe to parallelize within process because there is no shared mutable state.
Famous last words. Prove there's no shared mutable state in large go systems (think static var
).
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.
Hence the footnote: It will be either safe to parallelize within a single process or it isn't, in which case I'll be scared to parallelize across processes because each update shares mutable state.
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.
At a first approximation, yes, but it's not apples to apples.
If you're parallelizing in-process, you can get issues related to say panics on concurrent map element access for shared state.
If you're parallelizing outside of process, you can get issues related to using shared OS resources such as file handles or folders.
It's just a guess at this point, I don't know if any of those are actual issues. We could try and see at some point.
if runtime.GOOS == "windows" { | ||
// Currently there is a test issue in CI/test setup: | ||
// | ||
// convertViaPulumiCLI: failed to clean up temp bridge-examples.json file: The |
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.
Have we manually tested running the new convert workflow on windows? We do support authoring bridged providers on windows AFAIK.
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.
Nope, we haven't. It's not on the critical path. I can add it to the bottom of the epic.
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.
It's necessary for removing the old convert logic, but shouldn't be blocking for us to use the new logic. We might want to add a warning for users who turn on the new converter on windows computers.
I would really like a plan for how this change will roll out. |
The plan is included in the epic #1280 |
Diff for pulumi-azuread with merge commit 60260d4 |
Diff for pulumi-random with merge commit 60260d4 |
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.
LGTM
Fixes #1352
Requires a modified pulumi/pulumi-converter-terraform#29
A new option is added for tfgen, via the environment variable PULUMI_CONVERT. IF this option is truthy,
make tfgen
will now be usingpulumi convert
when converting examples, specifically for the TF HCL to Pulumi PCL phase of the conversion.How this was tested. Tried on these providers:
Ensured conversion rates improve. Ensured COVERAGE_OUTPUT_DIR, if set, continues to populate sensible conversion metrics. Ensured printed warnings and example conversion metrics out of
make tfgen
are still sensible.When rolling this out to providers, recommend making sure that Pulumi CLI in use is pinned first, as the repositories are sensitive to small changes in the generated examples and a floating Pulumi CLI reference can introduce breaking CI checks.