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

terraform plugin framework external client & connectors #329

Merged
merged 24 commits into from
Jan 31, 2024

Conversation

erhancagirici
Copy link
Collaborator

@erhancagirici erhancagirici commented Jan 16, 2024

Description of your changes

Introduces new external clients for terraform plugin framework resources

I have:

  • Read and followed Upjet's [contribution process].
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested with crossplane-contrib/provider-upjet-aws#1086.

}
}

p.Resources[name] = DefaultResource(name, terraformResource, terraformPluginFrameworkResource, providerMetadata.Resources[name], p.DefaultResourceOptions...)
p.Resources[name].useNoForkClient = isNoFork
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we are introducing TerraformPluginFramework terminology, could we please refactor "noFork" terminology to TerraformPluginSDK throughout the code base for uniformity and clearer understanding?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's keep renaming the no-fork external client out of scope for this PR and we will follow-up with a new PR after we merge this one. Thank you.

@ulucinar ulucinar marked this pull request as ready for review January 26, 2024 16:54
Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thank you @erhancagirici & @mergenci for attacking the remaining issue of reconciling the Terraform plugin framework resources natively without the TF CLI. Outstanding work here. Left some comments for you to consider. Also planning a second pass.

@erhancagirici, could you please also update the description of the PR and briefly discuss the architecture and the newly introduced APIs (tf plugin fw external connecter/client, extensions to the async tracker, etc.) with this PR?

pkg/config/provider.go Show resolved Hide resolved
pkg/config/common.go Outdated Show resolved Hide resolved
pkg/config/common_test.go Outdated Show resolved Hide resolved
pkg/config/provider.go Outdated Show resolved Hide resolved
pkg/config/resource.go Outdated Show resolved Hide resolved
"but either config.Provider.TerraformProvider is not configured or the Go schema does not exist for the resource", name))
}

for _, resourceFunc := range terraformPluginFrameworkResourceFunctions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for _, resourceFunc := range terraformPluginFrameworkResourceFunctions {
for _, resourceFunc := range p.TerraformPluginFrameworkProvider.Resources(ctx) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as mentioned in #329 (comment), we prefer to call p.TerraformPluginFrameworkProvider.Resources(ctx) one time out of the main loop.

Copy link
Member

Choose a reason for hiding this comment

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

For loop here is now removed, as part of a further performance improved. See the comment above.

pkg/config/resource.go Show resolved Hide resolved
pkg/controller/nofork_store.go Outdated Show resolved Hide resolved
pkg/controller/nofork_store.go Show resolved Hide resolved
@@ -122,6 +123,8 @@ type Setup struct {
Scheduler ProviderScheduler

Meta any

FrameworkProvider fwprovider.Provider
Copy link
Collaborator

Choose a reason for hiding this comment

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

Leaving a comment here as a reminder for what we had discussed previously: Because we initialize the framework server and the framework provider at each reconciliation, we may try to extend the provider configuration framework and have the provider directly initialized at each reconciliation in the ExternalConnecter.Connect instead of the provider's terraform.SetupFn so that we don't have to carry it via the terraform.Setup. Let's keep it out of scope for this PR though. We may attempt this "optimization" in a follow-up PR.

Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thank you @erhancagirici & @mergenci. We will also need to implement the unit tests for these changes.

pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
pkg/controller/external_terraform_plugin_framework.go Outdated Show resolved Hide resolved
mergenci and others added 20 commits January 30, 2024 21:22
Configuring provider server with a nil configuration request lets
server retrieve already-configured provider's configuration.

Signed-off-by: Cem Mergenci <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Speedup in upbound/provider-aws, obtained via non-rigorous measurement
techniques, is around 1.1x. Performance benefits would be higher, if
there were more Terraform Plugin Framework resources configured.

Signed-off-by: Cem Mergenci <[email protected]>
Signed-off-by: Cem Mergenci <[email protected]>
Signed-off-by: Erhan Cagirici <[email protected]>
Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thanks @erhancagirici & @mergenci for tackling with the framework resources. It's been a really fruitful journey with lots of learning and at the end we've been able to add support for framework resources natively. We will pursue increasing the unit test coverage in #336 in addition to the integration tests we've already performed. There are also two additional framework resources waiting for this PR and we will have validated the changes introduced here with those. In addition, changes from this PR are being tested as part crossplane-contrib/provider-upjet-aws#1086, which depends on this PR.

Thank you for the great work!

@ulucinar ulucinar merged commit af203bd into crossplane:main Jan 31, 2024
6 of 7 checks passed
@mergenci mergenci mentioned this pull request Feb 26, 2024
6 tasks
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.

4 participants