From dde2a0b81cee44a86ed5eab3b54b4c821c49818d Mon Sep 17 00:00:00 2001 From: "Muneeb H. Jan" Date: Mon, 2 Dec 2024 13:21:06 +0100 Subject: [PATCH] [Fix] Modify CCE cluster resources to match changes in gopher (#2751) [Fix] Modify CCE cluster resources to match changes in gopher Summary of the Pull Request CCE V3 Cluster functions changed in Gophercloud (PR #761) require modifications in TF provider. PR Checklist Tests added/passed. Release notes added. Acceptance Steps Performed === RUN TestAccCCEClusterV3DataSource_basic === PAUSE TestAccCCEClusterV3DataSource_basic === RUN TestAccCCEClusterV3_basic === PAUSE TestAccCCEClusterV3_basic === RUN TestAccCCEClusterV3_turbo_basic === PAUSE TestAccCCEClusterV3_turbo_basic === RUN TestAccCCEClusterV3_importBasic === PAUSE TestAccCCEClusterV3_importBasic === RUN TestAccCCEClusterV3_invalidNetwork === PAUSE TestAccCCEClusterV3_invalidNetwork === RUN TestAccCCEClusterV3_proxyAuth === PAUSE TestAccCCEClusterV3_proxyAuth === RUN TestAccCCEClusterV3_timeout === PAUSE TestAccCCEClusterV3_timeout === RUN TestAccCCEClusterV3NoAddons === PAUSE TestAccCCEClusterV3NoAddons === RUN TestAccCCEClusterV3NoUserClusterDataSet === PAUSE TestAccCCEClusterV3NoUserClusterDataSet === RUN TestAccCCEClusterV3_withVersionDiff === PAUSE TestAccCCEClusterV3_withVersionDiff === CONT TestAccCCEClusterV3DataSource_basic === CONT TestAccCCEClusterV3_proxyAuth === CONT TestAccCCEClusterV3_importBasic === CONT TestAccCCEClusterV3_invalidNetwork === CONT TestAccCCEClusterV3NoUserClusterDataSet === CONT TestAccCCEClusterV3NoAddons === CONT TestAccCCEClusterV3_withVersionDiff === CONT TestAccCCEClusterV3_timeout === CONT TestAccCCEClusterV3_turbo_basic === CONT TestAccCCEClusterV3_basic --- PASS: TestAccCCEClusterV3_invalidNetwork (23.25s) --- PASS: TestAccCCEClusterV3_proxyAuth (465.83s) --- PASS: TestAccCCEClusterV3_importBasic (480.17s) --- PASS: TestAccCCEClusterV3NoUserClusterDataSet (500.49s) --- PASS: TestAccCCEClusterV3DataSource_basic (506.72s) --- PASS: TestAccCCEClusterV3NoAddons (567.46s) --- PASS: TestAccCCEClusterV3_withVersionDiff (886.22s) --- PASS: TestAccCCEClusterV3_turbo_basic (915.85s) --- PASS: TestAccCCEClusterV3_timeout (953.18s) --- PASS: TestAccCCEClusterV3_basic (971.63s) === RUN TestAccCCEKubeConfigV3DataSource_basic === PAUSE TestAccCCEKubeConfigV3DataSource_basic === CONT TestAccCCEKubeConfigV3DataSource_basic --- PASS: TestAccCCEKubeConfigV3DataSource_basic (562.53s) PASS Reviewed-by: Anton Sidelnikov --- go.mod | 2 +- go.sum | 6 +- ...komcloud_cce_cluster_kubeconfig_v3_test.go | 13 +- ...ce_opentelekomcloud_cce_cluster_v3_test.go | 146 +++++++++--------- .../acceptance/cce/shared/cluster.go | 4 +- ...ntelekomcloud_cce_cluster_kubeconfig_v3.go | 2 +- ..._source_opentelekomcloud_cce_cluster_v3.go | 2 +- ...esource_opentelekomcloud_cce_cluster_v3.go | 20 +-- .../resource_opentelekomcloud_cce_node_v3.go | 2 +- ...ce-refactor-clusters-9ee4f8b6503f4126.yaml | 4 + 10 files changed, 109 insertions(+), 92 deletions(-) create mode 100644 releasenotes/notes/cce-refactor-clusters-9ee4f8b6503f4126.yaml diff --git a/go.mod b/go.mod index 93c2f7869..53b2ad9b6 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4 github.com/mitchellh/go-homedir v1.1.0 - github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128102934-12bde9d9ad22 + github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241129140521-38656d067f56 github.com/unknwon/com v1.0.1 golang.org/x/crypto v0.23.0 golang.org/x/sync v0.1.0 diff --git a/go.sum b/go.sum index 80058d22a..931c637a7 100644 --- a/go.sum +++ b/go.sum @@ -156,10 +156,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241125090636-639d0490ef08 h1:wG3Uy3CD7vTtjJmqTl4zgqzwK5RzkgIrFcNBj4W3bRg= -github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241125090636-639d0490ef08/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg= -github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128102934-12bde9d9ad22 h1:9TjDvrDqLTS9V5VUuFwi6qx/hp5IaYl+IK9sZuwIf74= -github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241128102934-12bde9d9ad22/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg= +github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241129140521-38656d067f56 h1:8IBF5eU0C41SlhfzdyjTajMpuhMX5QEpEPN7f4a7zts= +github.com/opentelekomcloud/gophertelekomcloud v0.9.4-0.20241129140521-38656d067f56/go.mod h1:M1F6OfSRZRzAmAFKQqSLClX952at5hx5rHe4UTEykgg= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/opentelekomcloud/acceptance/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3_test.go b/opentelekomcloud/acceptance/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3_test.go index 2448586fd..04eccd619 100644 --- a/opentelekomcloud/acceptance/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3_test.go +++ b/opentelekomcloud/acceptance/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3_test.go @@ -3,6 +3,7 @@ package acceptance import ( "fmt" "testing" + "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -108,7 +109,15 @@ resource "opentelekomcloud_cce_cluster_v3" "cluster_1" { data "opentelekomcloud_cce_cluster_kubeconfig_v3" "this" { cluster_id = opentelekomcloud_cce_cluster_v3.cluster_1.id - expiry_date = "2024-02-01" + expiry_date = "%s" } -`, common.DataSourceSubnet, cceName) +`, common.DataSourceSubnet, cceName, GetDatePlusTwo()) +} + +// GetDatePlusTwo returns the date for today + 2 days in the YYYY-MM-DD format. +func GetDatePlusTwo() string { + today := time.Now() + futureDate := today.AddDate(0, 0, 2) + formattedDate := futureDate.Format("2006-01-02") + return formattedDate } diff --git a/opentelekomcloud/acceptance/cce/resource_opentelekomcloud_cce_cluster_v3_test.go b/opentelekomcloud/acceptance/cce/resource_opentelekomcloud_cce_cluster_v3_test.go index 981dc180a..49c5512b8 100644 --- a/opentelekomcloud/acceptance/cce/resource_opentelekomcloud_cce_cluster_v3_test.go +++ b/opentelekomcloud/acceptance/cce/resource_opentelekomcloud_cce_cluster_v3_test.go @@ -18,21 +18,35 @@ import ( const resourceClusterName = "opentelekomcloud_cce_cluster_v3.cluster_1" +func getCceClusterResourceFunc(cfg *cfg.Config, state *terraform.ResourceState) (interface{}, error) { + client, err := cfg.CceV3Client(env.OS_REGION_NAME) + if err != nil { + return nil, fmt.Errorf("error creating CCE v3 Client: %s", err) + } + return clusters.Get(client, state.Primary.ID) +} + func TestAccCCEClusterV3_basic(t *testing.T) { var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() + quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3Basic(clusterName), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "name", clusterName), resource.TestCheckResourceAttr(resourceClusterName, "status", "Available"), resource.TestCheckResourceAttr(resourceClusterName, "cluster_type", "VirtualMachine"), @@ -64,19 +78,25 @@ func TestAccCCEClusterV3_basic(t *testing.T) { func TestAccCCEClusterV3_turbo_basic(t *testing.T) { var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() + quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterTurboV3Basic(clusterName), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "name", clusterName), resource.TestCheckResourceAttr(resourceClusterName, "status", "Available"), resource.TestCheckResourceAttr(resourceClusterName, "cluster_type", "VirtualMachine"), @@ -94,6 +114,12 @@ func TestAccCCEClusterV3_turbo_basic(t *testing.T) { } func TestAccCCEClusterV3_importBasic(t *testing.T) { + var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() quotas.BookOne(t, quotas.CCEClusterQuota) @@ -101,7 +127,7 @@ func TestAccCCEClusterV3_importBasic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3BasicSG(clusterName), @@ -121,13 +147,20 @@ func TestAccCCEClusterV3_importBasic(t *testing.T) { } func TestAccCCEClusterV3_invalidNetwork(t *testing.T) { + var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() + quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3InvalidSubnet(clusterName), @@ -149,13 +182,20 @@ func TestAccCCEClusterV3_invalidNetwork(t *testing.T) { } func TestAccCCEClusterV3_proxyAuth(t *testing.T) { + var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() + quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3AuthProxy(clusterName), @@ -167,6 +207,11 @@ func TestAccCCEClusterV3_proxyAuth(t *testing.T) { func TestAccCCEClusterV3_timeout(t *testing.T) { var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() quotas.BookOne(t, quotas.CCEClusterQuota) @@ -174,12 +219,12 @@ func TestAccCCEClusterV3_timeout(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3Timeout(clusterName), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "authentication_mode", "rbac"), ), }, @@ -189,19 +234,23 @@ func TestAccCCEClusterV3_timeout(t *testing.T) { func TestAccCCEClusterV3NoAddons(t *testing.T) { var cluster clusters.Clusters - + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) t.Parallel() quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3NoAddons(randClusterName()), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "installed_addons.#", "0"), ), }, @@ -211,19 +260,24 @@ func TestAccCCEClusterV3NoAddons(t *testing.T) { func TestAccCCEClusterV3NoUserClusterDataSet(t *testing.T) { var cluster clusters.Clusters - + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) t.Parallel() + quotas.BookOne(t, quotas.CCEClusterQuota) resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3NoUserClusterData(randClusterName()), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "certificate_clusters.#", "0"), resource.TestCheckResourceAttr(resourceClusterName, "certificate_users.#", "0"), ), @@ -232,61 +286,13 @@ func TestAccCCEClusterV3NoUserClusterDataSet(t *testing.T) { }) } -func testAccCheckCCEClusterV3Destroy(s *terraform.State) error { - config := common.TestAccProvider.Meta().(*cfg.Config) - client, err := config.CceV3Client(env.OS_REGION_NAME) - if err != nil { - return fmt.Errorf("error creating opentelekomcloud CCE client: %s", err) - } - - for _, rs := range s.RootModule().Resources { - if rs.Type != "opentelekomcloud_cce_cluster_v3" { - continue - } - - _, err := clusters.Get(client, rs.Primary.ID).Extract() - if err == nil { - return fmt.Errorf("cluster still exists") - } - } - - return nil -} - -func testAccCheckCCEClusterV3Exists(n string, cluster *clusters.Clusters) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("no ID is set") - } - - config := common.TestAccProvider.Meta().(*cfg.Config) - client, err := config.CceV3Client(env.OS_REGION_NAME) - if err != nil { - return fmt.Errorf("error creating OpenTelekomCloud CCE client: %s", err) - } - - found, err := clusters.Get(client, rs.Primary.ID).Extract() - if err != nil { - return err - } - - if found.Metadata.Id != rs.Primary.ID { - return fmt.Errorf("cluster not found") - } - - *cluster = *found - - return nil - } -} - func TestAccCCEClusterV3_withVersionDiff(t *testing.T) { var cluster clusters.Clusters + rc := common.InitResourceCheck( + resourceClusterName, + &cluster, + getCceClusterResourceFunc, + ) clusterName := randClusterName() t.Parallel() quotas.BookOne(t, quotas.CCEClusterQuota) @@ -294,12 +300,12 @@ func TestAccCCEClusterV3_withVersionDiff(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { common.TestAccPreCheck(t) }, ProviderFactories: common.TestAccProviderFactories, - CheckDestroy: testAccCheckCCEClusterV3Destroy, + CheckDestroy: rc.CheckResourceDestroy(), Steps: []resource.TestStep{ { Config: testAccCCEClusterV3WithInvalidVersion(clusterName), Check: resource.ComposeTestCheckFunc( - testAccCheckCCEClusterV3Exists(resourceClusterName, &cluster), + rc.CheckResourceExists(), resource.TestCheckResourceAttr(resourceClusterName, "name", clusterName), ), }, diff --git a/opentelekomcloud/acceptance/cce/shared/cluster.go b/opentelekomcloud/acceptance/cce/shared/cluster.go index 7389ce3ae..bc05de426 100644 --- a/opentelekomcloud/acceptance/cce/shared/cluster.go +++ b/opentelekomcloud/acceptance/cce/shared/cluster.go @@ -83,7 +83,7 @@ func deleteSharedCluster(t *testing.T) { client, err := config.CceV3Client(env.OS_REGION_NAME) th.AssertNoErr(t, err) - th.AssertNoErr(t, clusters.Delete(client, sharedClusterID).ExtractErr()) + th.AssertNoErr(t, clusters.Delete(client, sharedClusterID, clusters.DeleteQueryParams{})) stateConf := &resource.StateChangeConf{ Pending: []string{"Deleting", "Available", "Unavailable"}, @@ -137,7 +137,7 @@ func CreateSharedCluster(t *testing.T, client *golangsdk.ServiceClient, subnet * SubnetId: subnet.ID, }, }, - }).Extract() + }) th.AssertNoErr(t, err) sharedClusterID = job.Metadata.Id diff --git a/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3.go b/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3.go index 360609755..fc0509fd3 100644 --- a/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3.go +++ b/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_kubeconfig_v3.go @@ -69,7 +69,7 @@ func dataSourceCCEClusterKubeConfigV3Read(_ context.Context, d *schema.ResourceD Duration: duration, } - kubeconfig, err := clusters.GetCertWithExpiration(client, clusterID, expiryOpts).ExtractMap() + kubeconfig, err := clusters.GetCertWithExpiration(client, clusterID, expiryOpts) if err != nil { return fmterr.Errorf("unable to retrieve cluster kubeconfig: %w", err) } diff --git a/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_v3.go b/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_v3.go index 6846d2b44..42cd0dee8 100644 --- a/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_v3.go +++ b/opentelekomcloud/services/cce/data_source_opentelekomcloud_cce_cluster_v3.go @@ -203,7 +203,7 @@ func dataSourceCCEClusterV3Read(_ context.Context, d *schema.ResourceData, meta return diag.FromErr(err) } - cert, err := clusters.GetCert(cceClient, d.Id()).Extract() + cert, err := clusters.GetCert(cceClient, d.Id()) if err != nil { return fmterr.Errorf("error retrieving opentelekomcloud CCE cluster cert: %s", err) } diff --git a/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_cluster_v3.go b/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_cluster_v3.go index 9139723b4..59dc1d2a5 100644 --- a/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_cluster_v3.go +++ b/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_cluster_v3.go @@ -448,7 +448,7 @@ func resourceCCEClusterV3Create(ctx context.Context, d *schema.ResourceData, met createOpts.Spec.EniNetwork = &eniNetwork } - create, err := clusters.Create(client, createOpts).Extract() + create, err := clusters.Create(client, createOpts) if err != nil { if isAuthRequired(err) { @@ -498,7 +498,7 @@ func resourceCCEClusterV3Read(ctx context.Context, d *schema.ResourceData, meta return fmterr.Errorf(cceClientError, err) } - cluster, err := clusters.Get(client, d.Id()).Extract() + cluster, err := clusters.Get(client, d.Id()) if err != nil { if _, ok := err.(golangsdk.ErrDefault404); ok { d.SetId("") @@ -546,7 +546,7 @@ func resourceCCEClusterV3Read(ctx context.Context, d *schema.ResourceData, meta return fmterr.Errorf("error setting cce cluster fields: %w", err) } - cert, err := clusters.GetCert(client, d.Id()).Extract() + cert, err := clusters.GetCert(client, d.Id()) if err != nil { return fmterr.Errorf("error retrieving opentelekomcloud CCE cluster cert: %w", err) } @@ -652,7 +652,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met if d.HasChange("description") { updateOpts.Spec.Description = d.Get("description").(string) - _, err = clusters.Update(client, d.Id(), updateOpts).Extract() + _, err = clusters.Update(client, d.Id(), updateOpts) if err != nil { return fmterr.Errorf("error updating opentelekomcloud CCE: %w", err) } @@ -676,7 +676,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met updateIpOpts := clusters.UpdateIpOpts{ Action: "unbind", } - err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts).ExtractErr() + err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts) if err != nil { return fmterr.Errorf("error unbinding EIP to opentelekomcloud CCE: %w", err) } @@ -687,7 +687,7 @@ func resourceCCEClusterV3Update(ctx context.Context, d *schema.ResourceData, met ElasticIp: newEipStr, } updateIpOpts.Spec.ID = fipId - err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts).ExtractErr() + err = clusters.UpdateMasterIp(client, d.Id(), updateIpOpts) if err != nil { return fmterr.Errorf("error binding EIP to opentelekomcloud CCE: %w", err) } @@ -707,7 +707,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met return fmterr.Errorf(cceClientError, err) } - deleteOpts := clusters.DeleteOpts{} + deleteOpts := clusters.DeleteQueryParams{} var deleteAll bool if v, ok := d.GetOk("delete_all_storage"); ok && v.(string) != "false" { deleteOpt := d.Get("delete_all_storage").(string) @@ -733,7 +733,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met deleteOpts.DeleteSfs = d.Get("delete_sfs").(string) } - err = clusters.DeleteWithOpts(client, d.Id(), deleteOpts) + err = clusters.Delete(client, d.Id(), deleteOpts) if err != nil { return fmterr.Errorf("error deleting opentelekomcloud CCE Cluster: %w", err) } @@ -758,7 +758,7 @@ func resourceCCEClusterV3Delete(ctx context.Context, d *schema.ResourceData, met func WaitForCCEClusterActive(cceClient *golangsdk.ServiceClient, clusterId string) resource.StateRefreshFunc { return func() (interface{}, string, error) { - n, err := clusters.Get(cceClient, clusterId).Extract() + n, err := clusters.Get(cceClient, clusterId) if err != nil { return nil, "", fmt.Errorf("error waiting for CCE cluster to become active: %w", err) } @@ -771,7 +771,7 @@ func WaitForCCEClusterDelete(client *golangsdk.ServiceClient, clusterId string) return func() (interface{}, string, error) { log.Printf("[DEBUG] Attempting to delete CCE cluster %s.\n", clusterId) - r, err := clusters.Get(client, clusterId).Extract() + r, err := clusters.Get(client, clusterId) if err != nil { if _, ok := err.(golangsdk.ErrDefault404); ok { diff --git a/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_node_v3.go b/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_node_v3.go index 7f75043fd..ef0125ed8 100644 --- a/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_node_v3.go +++ b/opentelekomcloud/services/cce/resource_opentelekomcloud_cce_node_v3.go @@ -1146,7 +1146,7 @@ func waitForCceNodeDelete(cceClient *golangsdk.ServiceClient, clusterId, nodeId func waitForClusterAvailable(cceClient *golangsdk.ServiceClient, clusterId string) resource.StateRefreshFunc { return func() (interface{}, string, error) { log.Printf("[INFO] Waiting for OpenTelekomCloud Cluster to be available %s.\n", clusterId) - n, err := clusters.Get(cceClient, clusterId).Extract() + n, err := clusters.Get(cceClient, clusterId) if err != nil { return nil, "", err diff --git a/releasenotes/notes/cce-refactor-clusters-9ee4f8b6503f4126.yaml b/releasenotes/notes/cce-refactor-clusters-9ee4f8b6503f4126.yaml new file mode 100644 index 000000000..6d2cfd027 --- /dev/null +++ b/releasenotes/notes/cce-refactor-clusters-9ee4f8b6503f4126.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + **[CCE]** Refactor v3 cluster tests and fixed to match changes in gopher (`#2751 `_)