-
Notifications
You must be signed in to change notification settings - Fork 226
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
[DNM until after 2.8 release] Migrate from sdk-v1 to sdk2-v2 #1224
base: master
Are you sure you want to change the base?
Conversation
@felipe-colussi In general, nice job! Had some comments following up our discussion on the source code and schema updates last week. Please do the following
|
@felipe-colussi Can you also please squash the top 8-10 commits https://github.com/rancher/terraform-provider-rancher2/pull/1224/commits? They are all pretty small updates. |
c1f810f
to
86630d5
Compare
8e72589
to
ea3ec1f
Compare
Looks like the build is failing due to go fmt. Run gofmt -w on these files
|
4859bdf
to
f6e126a
Compare
- Add missing fields that are required in the new schema - Update agentDeploymentCustomization types - Update error to diag - Fix build errors and tests, rebase with master
f6e126a
to
59f6565
Compare
The changes got massively confusing on this PR so we did the following
@felipe-colussi If there are additional review comments, please include them in only 1-2 additional commits that are for addressed comments. Issues with the auto-generated |
Smoke tests after migration: RKE2 - DO = Create Auth -> Create Cluster -> Upgrade K8S version -> Delete. Ok. RKE - DO = "Data" Auth -> Create Cluster with cluster_agent_deployment_customization -> Remove override_affinity+override_resource_requirements+fleet_agent_deployment_customization -> Increase node count -> Delete. Ok RKE - AWS -> Create Auth -> Create Cluster (k8s version and network plugin only) -> increase node count -> dete. Ok. |
@@ -53,15 +53,14 @@ resource "rancher2_namespace" "testacc" { | |||
testAccCheckRancher2UpgradeCatalogV24 = testAccRancher2CatalogGlobal + testAccRancher2CatalogCluster + testAccRancher2CatalogProject | |||
testAccCheckRancher2UpgradeCertificateV24 = testAccRancher2Certificate + testAccRancher2CertificateNs | |||
testAccCheckRancher2BootstrapV23 = ` | |||
provider "rancher2" { |
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.
For my own understanding can you explain why this was necessary
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.
This is the fix for the flaky test that was happening.
I didn't found anything related to it on the migration guides, but once I started reading the code docs the new test framework explicitly says that we can't use alias on providers and recommend to use multiple providers instead.
DNM: waiting for release of 4.0.0
Issue: #1080
Observation: I Had a lot of conflicts on the PR #1207 IMO it was safer to close that one and create a new one cherry-picking my changes than it was to resolve the conflicts on that pr.
Problem
Migrate SDK1 to SDK2
Solution
Migrate SDK1 to SDK2:
Main changes:
Change Create, Read, Update, Delete fields to CreateContext, ReadContext . . .
Change function signatures from
dataSourceRancher2....( d *schema.ResourceData, meta interface{})
error todataSourceRancher2...(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics
Change some error handling to behave with
diag.Diagnostics
.Remove
MaxItems
from TF arguments withCompiled: true
. Required by migrating sdk1 to 2.Add some argument that were being set without being on the schema. Required by migrating sdk1 to 2.
Changed some types and added some so they correspond to the schemas. Required by migrating sdk1 to 2.
Observation:
I had a loot of errors on the Tests, mainly 401 during the delete of TestAccRancher2Upgrade. I Did 2 commits to add some debug logic to that test and on that moment It just worked. I'm letting the debug (prints) on this PR so if I go back having that error I can confirm if the envs were being overwritten without need (I do believe that this was causing the error).
Testing
Engineering Testing
Manual Testing
I Tested on TF trying to create, destroy scale and change objects.
DO-RKE2-Basic.txt
AWS-RKE2-CUSTOM.txt
aws-rke1-custom.txt
Automated Testing
I ran all automated tests, also had to change some to match the SDK upgrade.
QA Testing Considerations
This is a huge change, I wasn't able to get a bug that happened due to the migration, that said please test this intensively.
Regressions Considerations