diff --git a/alicloud/common.go b/alicloud/common.go index 0b22a1ba7b4b..75a6b17e01fa 100644 --- a/alicloud/common.go +++ b/alicloud/common.go @@ -232,6 +232,8 @@ const DefaultTimeoutMedium = 500 // timeout for long time progerss product, rds e.g. const DefaultLongTimeout = 1000 +const LongTimeOut = 1200 + const DefaultIntervalMini = 2 const DefaultIntervalShort = 5 diff --git a/alicloud/resource_alicloud_polardb_cluster.go b/alicloud/resource_alicloud_polardb_cluster.go index 9b85bee39e37..236de456b8f0 100644 --- a/alicloud/resource_alicloud_polardb_cluster.go +++ b/alicloud/resource_alicloud_polardb_cluster.go @@ -405,9 +405,10 @@ func resourceAlicloudPolarDBCluster() *schema.Resource { DiffSuppressFunc: polardbDiffSuppressFunc, }, "db_node_num": { - Type: schema.TypeInt, - Optional: true, - ValidateFunc: IntInSlice([]int{1, 2}), + Type: schema.TypeInt, + Optional: true, + ValidateFunc: IntInSlice([]int{1, 2}), + DiffSuppressFunc: polardbProxyTypeDiffSuppressFunc, }, "parameter_group_id": { Type: schema.TypeString, @@ -512,16 +513,33 @@ func resourceAlicloudPolarDBClusterCreate(d *schema.ResourceData, meta interface d.SetId(fmt.Sprint(response["DBClusterId"])) // wait cluster status change from Creating to running - stateConf := BuildStateConf([]string{"Creating"}, []string{"Running"}, d.Timeout(schema.TimeoutCreate), 5*time.Minute, polarDBService.PolarDBClusterStateRefreshFunc(d.Id(), []string{"Deleting"})) + stateConf := BuildStateConf([]string{"Creating", "WarmCreating"}, []string{"Running"}, 10*time.Minute, 10*time.Second, polarDBService.PolarDBClusterStateRefreshFunc(d.Id(), []string{"Deleting"})) if _, err := stateConf.WaitForState(); err != nil { return WrapErrorf(err, IdMsg, d.Id()) } if v, ok := d.GetOk("db_type"); ok && v.(string) == "MySQL" { - categoryConf := BuildStateConf([]string{}, []string{"Normal", "Basic", "ArchiveNormal", "NormalMultimaster", "SENormal"}, d.Timeout(schema.TimeoutUpdate), 3*time.Minute, polarDBService.PolarDBClusterCategoryRefreshFunc(d.Id(), []string{})) + categoryConf := BuildStateConf([]string{}, []string{"Normal", "Basic", "ArchiveNormal", "NormalMultimaster", "SENormal"}, 10*time.Minute, 10*time.Second, polarDBService.PolarDBClusterCategoryRefreshFunc(d.Id(), []string{})) if _, err := categoryConf.WaitForState(); err != nil { return WrapErrorf(err, IdMsg, d.Id()) } } + allConfig := make(map[string]string) + if v, ok := d.GetOk("loose_polar_log_bin"); ok { + allConfig["loose_polar_log_bin"] = fmt.Sprint(v) + } + if v, ok := d.GetOk("default_time_zone"); ok { + allConfig["default_time_zone"] = fmt.Sprint(v) + } + if v, ok := d.GetOk("lower_case_table_names"); ok { + allConfig["lower_case_table_names"] = fmt.Sprint(v) + } + // wait instance parameter expect after modifying + if len(allConfig) > 0 { + if err := polarDBService.WaitForPolarDBParameter(d.Id(), DefaultLongTimeout, allConfig); err != nil { + return WrapError(err) + } + } + return resourceAlicloudPolarDBClusterUpdate(d, meta) } @@ -530,7 +548,7 @@ func resourceAlicloudPolarDBClusterUpdate(d *schema.ResourceData, meta interface polarDBService := PolarDBService{client} d.Partial(true) - if d.HasChange("default_time_zone") || d.HasChange("lower_case_table_names") || d.HasChange("loose_polar_log_bin") { + if !d.IsNewResource() && (d.HasChange("default_time_zone") || d.HasChange("lower_case_table_names") || d.HasChange("loose_polar_log_bin")) { if err := polarDBService.CreateClusterParamsModifyParameters(d); err != nil { return WrapError(err) } @@ -1764,6 +1782,12 @@ func buildPolarDBCreateRequest(d *schema.ResourceData, meta interface{}) (map[st request["DefaultTimeZone"] = v.(string) } + if v, ok := d.GetOk("security_ips"); ok { + ipList := expandStringList(v.(*schema.Set).List()) + ipstr := strings.Join(ipList[:], COMMA_SEPARATED) + request["SecurityIPList"] = ipstr + } + return request, nil } diff --git a/alicloud/resource_alicloud_polardb_cluster_test.go b/alicloud/resource_alicloud_polardb_cluster_test.go index de7280edb3d0..945f3456f5aa 100644 --- a/alicloud/resource_alicloud_polardb_cluster_test.go +++ b/alicloud/resource_alicloud_polardb_cluster_test.go @@ -215,7 +215,6 @@ func TestAccAliCloudPolarDBCluster_Update(t *testing.T) { { Config: testAccConfig(map[string]interface{}{ "db_node_count": "3", - "imci_switch": "ON", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ diff --git a/alicloud/service_alicloud_polardb.go b/alicloud/service_alicloud_polardb.go index 2ea4da70bcd5..8d5fa490c796 100644 --- a/alicloud/service_alicloud_polardb.go +++ b/alicloud/service_alicloud_polardb.go @@ -965,7 +965,7 @@ func (s *PolarDBService) ModifyParameters(d *schema.ResourceData) error { value := i.(map[string]interface{})["value"].(string) allConfig[key] = value } - if err := s.WaitForPolarDBParameter(d.Id(), DefaultTimeoutMedium, allConfig); err != nil { + if err := s.WaitForPolarDBParameter(d.Id(), DefaultLongTimeout, allConfig); err != nil { return WrapError(err) } } @@ -1002,7 +1002,7 @@ func (s *PolarDBService) CreateClusterParamsModifyParameters(d *schema.ResourceD addDebug(request.GetActionName(), raw, request.RpcRequest, request) // wait instance parameter expect after modifying - if err := s.WaitForPolarDBParameter(d.Id(), DefaultLongTimeout, allConfig); err != nil { + if err := s.WaitForPolarDBParameter(d.Id(), LongTimeOut, allConfig); err != nil { return WrapError(err) } for _, i := range changeParams {