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

Feature/530/migrate to plugin framework #567

Merged
merged 107 commits into from
Feb 27, 2023

Conversation

dimuon
Copy link
Contributor

@dimuon dimuon commented Dec 7, 2022

Description

Migration to TF Plugin Framework.
New schema for ec_deployment.

Limitations

  • State upgrade is not currently implemented for ec_deployment. The recommended way to port existing resources to the new provider version is state import.
  • The migration is based on the provider version 0.4.1. We plan to bring changes from 0.5.0 and master branch that were merged after the split (e.g. [feature] support template hardware migration API #487) in future releases.

Review notes
The change is quite big. The alternative way to review the change is reviewing PRs in the migration repo. Usually, it was a PR per resource/datasource, e.g. this PR migrated ec_deployment. Also, mind the fact that there are a number of JSON files with resources for acceptance and unit tests that contributed to the size of the PR.

Some design decisions were motivated by this TF issue that prevents from, e.g., using Computed + Optional nested attributes with underlying Computed attributes (e.g. deploymentresource.elasticsearch.topology.autoscaling is defined as Required while ideally it should be Optional + Computed).

Also, the current TF core logic makes it nearly impossible to use sets with computed + optional underlying attributes that means, in particular, that Elasticsearch topology (where each tier has computed and optional attributes) cannot be represented using sets (tfsdk.SetNestedAttributes). More details:

Related Issues

#506
#530

Motivation and Context

The change should resolve a number of Elasticsearch topology related issues in ec_deployment, e.g.
#336, #445, #466, #467.

The Plugin Framework represents TF vision of the future of plugin development.
So the migration was a question of time that got a priority with the idea to resolve a number of mentioned topology related issues.

How Has This Been Tested?

  • unit tests
  • acceptance tests
  • manual testing

There are 4 new acceptance tests that are disabled now. Prior to enabling them we need implement state upgrade for ec_deployment.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

dimuon and others added 18 commits September 6, 2022 14:33
Introduce mux and port the provider to v6.
Migrate data sources to terraform-provider-framework
Migrate resource ec_deployment_traffic_filter_association to terraform-provider-framework
…ork-0.12

Update to terraform-plugin-framework 0.12 and fix import order
…ramework

The behavior of the default_value plan_modifier changes, so
it also applies default values when the value has been explicitly
specified before.

Unit test timeout increased.

Switch to v6 provider in tests.
Migrate resource ec_deployment_traffic_filter to terraform-provider-framework
* Use ListNestedAttributes for nested schemas in datasource ec_stack
* Use ListNestedAttributes for nested schemas in datasource ec_deployment
* Use blocks and ListNestedAttributes for nested schemas in datasource ec_deployments
Update dependencies and remove external provider workaround from migration tests
#12)

* Migrate resource ec_deployment_extension to terraform-plugin-framework

* Remove useless use of ec.Bool() and ec.String()

Co-authored-by: Pascal Hofmann <[email protected]>
@dimuon dimuon requested review from alaudazzi, nrichers and a team as code owners December 7, 2022 09:52
@cla-checker-service
Copy link

cla-checker-service bot commented Dec 7, 2022

💚 CLA has been signed

@tobio
Copy link
Member

tobio commented Dec 7, 2022

The recommended way to port existing resources to the new provider version is state import.

It's not possible to import the elastic password, this feels like a pretty big foot gun that we're handing users.

@tobio
Copy link
Member

tobio commented Dec 7, 2022

image

To be honest, this is impossible to actually review. Can we instead break this up so we're only migrating a single resource/data source per PR?

@dimuon
Copy link
Contributor Author

dimuon commented Dec 7, 2022

image

To be honest, this is impossible to actually review. Can we instead break this up so we're only migrating a single resource/data source per PR?

Yes, it's quite difficult to review this. We did some reviews with @pascal-hofmann when we were working on the feature branch and basically we followed the way that you proposed. But, even in that case, it's not so easy - ec_deployment code base is quite big by its own, e.g. this was the PR for ec_deployment only. However, there are also a number of json files for acceptance and unit tests.

@dimuon
Copy link
Contributor Author

dimuon commented Dec 7, 2022

image

To be honest, this is impossible to actually review. Can we instead break this up so we're only migrating a single resource/data source per PR?

Also, it means additional code changes to keep the provider working. As I said, we did this during the work on the feature branch.

As an alternative, we can review the PRs on the migration repo - usually, it were a PR per resource/datasource.

@dimuon dimuon marked this pull request as draft December 7, 2022 11:44
Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

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

Tiny way through this change.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ec/provider.go Outdated Show resolved Hide resolved
ec/internal/util/parsers.go Outdated Show resolved Hide resolved
ec/internal/util/helpers.go Outdated Show resolved Hide resolved
ec/internal/planmodifier/default_value.go Show resolved Hide resolved
ec/internal/converters/extract_endpoint.go Outdated Show resolved Hide resolved
ec/internal/converters/convert_tags.go Outdated Show resolved Hide resolved
@pascal-hofmann
Copy link
Contributor

As far as I know the CLA has been signed. I guess my comment will re-trigger the CLA check?

@tobio
Copy link
Member

tobio commented Feb 15, 2023

@pascal-hofmann I can see you've signed the CLA, however it looks like these commits are using a different email address ([email protected]), not tied to your GH account.

2194ad3
8a79970
c197f28
b00e28a

@dimuon I guess you could reset the author on the above commits to use [email protected] in order to get past the check. FWIW manually triggering the CLA checker on this PR timed out, maybe there's a longer timeout on the automatic status check or we just force merge it 🤷.

@pascal-hofmann
Copy link
Contributor

pascal-hofmann commented Feb 15, 2023

I've added the address to my github account. I don't think rewriting the commits is the right thing to do.

(There is a company CLA signed with [email protected])

@dimuon
Copy link
Contributor Author

dimuon commented Feb 15, 2023

I've just rerun the checker. It looks good know 👍

@dimuon
Copy link
Contributor Author

dimuon commented Feb 15, 2023

I still would like to update the TF Framework to the latest version (v.1.1.1) before the merge. I've started working on this but it'll take some time - there are a number of breaking changes between 0.14.0 and 1.1.1.

@tobio
Copy link
Member

tobio commented Feb 15, 2023

https://www.youtube.com/watch?v=fR4HjTH_fTM

@dimuon
Copy link
Contributor Author

dimuon commented Feb 22, 2023

@tobio , I've updated the framework to v1.1.1. Would you mind to have a look at the commit?

Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

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

LGTM. Some minor nits. Some cases where we should be following 'accept interfaces, return structs'

ec/ecdatasource/deploymentsdatasource/schema.go Outdated Show resolved Hide resolved
ec/internal/planmodifiers/bool_default_value.go Outdated Show resolved Hide resolved
ec/internal/planmodifiers/string_default_value.go Outdated Show resolved Hide resolved
ec/internal/validators/knownvalidator.go Outdated Show resolved Hide resolved
ec/internal/validators/urlvalidator.go Outdated Show resolved Hide resolved
@dimuon
Copy link
Contributor Author

dimuon commented Feb 24, 2023

I’ve updated the TF framework version till the latest one (v1.1.1) and came across a defect in the Framework that prevents us from releasing based on v1.1.1 (see our acceptance test failures - all errors with elasticsearch.trust_account's unexpected new value are caused by the defect). The defect is already fixed in the Framework main branch and should be in v1.2.0.

I plan to revert the latest commits that updates the Framework version and release the provider based on Framework v0.14.0 that was used during the development and was tested the most.

We will update the TF Framework till v1.2.0 in the subsequent releases.

@joelsdc
Copy link

joelsdc commented Mar 1, 2023

This merge breaks datasources. Please undo or fix ASAP.

@dimuon
Copy link
Contributor Author

dimuon commented Mar 2, 2023

This merge breaks datasources. Please undo or fix ASAP.

@joelsdc , can you please provide more details? What is the error message? Also please share your configuration.

@dimuon
Copy link
Contributor Author

dimuon commented Mar 2, 2023

@joelsdc , can you please also share the version of the Terraform CLI.

@joelsdc
Copy link

joelsdc commented Mar 2, 2023

Hi @dimuon, I've opened issue #595

I'm using:

Terraform v1.3.9
on darwin_arm64

@tobio tobio deleted the feature/530/migrate-to-plugin-framework branch May 30, 2023 12:21
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.

5 participants