@@ -25,6 +25,7 @@ import (
25
25
"github.com/hashicorp/terraform-plugin-framework/types"
26
26
"github.com/hashicorp/terraform-plugin-log/tflog"
27
27
retry "github.com/sethvargo/go-retry"
28
+ "github.com/yugabyte/terraform-provider-ybm/managed/fflags"
28
29
"github.com/yugabyte/terraform-provider-ybm/managed/util"
29
30
openapiclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
30
31
)
@@ -1271,7 +1272,7 @@ func (r resourceCluster) Create(ctx context.Context, req tfsdk.CreateResourceReq
1271
1272
cluster .DesiredState .Value = plan .DesiredState .Value
1272
1273
}
1273
1274
1274
- if strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Disabled" ) {
1275
+ if fflags . IsFeatureFlagEnabled ( fflags . CONNECTION_POOLING ) && ( strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Disabled" ) ) {
1275
1276
cluster .DesiredConnectionPoolingState .Value = plan .DesiredConnectionPoolingState .Value
1276
1277
}
1277
1278
@@ -1709,11 +1710,14 @@ func resourceClusterRead(ctx context.Context, accountId string, projectId string
1709
1710
cluster .ClusterID .Value = clusterId
1710
1711
cluster .ClusterName .Value = clusterResp .Data .Spec .Name
1711
1712
cluster .DesiredState .Value = string (clusterResp .Data .Info .GetState ())
1712
- if clusterResp .Data .Info .GetIsConnectionPoolingEnabled () {
1713
- cluster .DesiredConnectionPoolingState .Value = "Enabled"
1714
- } else {
1715
- cluster .DesiredConnectionPoolingState .Value = "Disabled"
1713
+ if fflags .IsFeatureFlagEnabled (fflags .CONNECTION_POOLING ) {
1714
+ if clusterResp .Data .Info .GetIsConnectionPoolingEnabled () {
1715
+ cluster .DesiredConnectionPoolingState .Value = "Enabled"
1716
+ } else {
1717
+ cluster .DesiredConnectionPoolingState .Value = "Disabled"
1718
+ }
1716
1719
}
1720
+
1717
1721
cluster .ClusterType .Value = string (* clusterResp .Data .Spec .ClusterInfo .ClusterType )
1718
1722
cluster .ClusterTier .Value = string (clusterResp .Data .Spec .ClusterInfo .ClusterTier )
1719
1723
cluster .ClusterVersion .Value = strconv .Itoa (int (clusterResp .Data .Spec .ClusterInfo .GetVersion ()))
@@ -1953,9 +1957,12 @@ func (r resourceCluster) Update(ctx context.Context, req tfsdk.UpdateResourceReq
1953
1957
}
1954
1958
}
1955
1959
1956
- // Disable Connection Pooling if the desired state is set to 'Disabled and it is enabeld currently
1957
- if plan .DesiredConnectionPoolingState .Unknown || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Disabled" ) {
1960
+ tflog .Info (ctx , fmt .Sprintf ("Existing Desired Connection Pooling State in State is %v" , state .DesiredConnectionPoolingState .Value ))
1961
+
1962
+ // Disable Connection Pooling if the desired state is set to 'Disabled' and it is enabled currently
1963
+ if fflags .IsFeatureFlagEnabled (fflags .CONNECTION_POOLING ) && ! state .DesiredConnectionPoolingState .Unknown && strings .EqualFold (state .DesiredConnectionPoolingState .Value , "Enabled" ) && (plan .DesiredConnectionPoolingState .Unknown || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Disabled" )) {
1958
1964
// Disable Connection Pooling
1965
+ tflog .Info (ctx , fmt .Sprintf ("Existing Desired Connection Pooling State in State is %v" , state .DesiredConnectionPoolingState .Value ))
1959
1966
err := disableConnectionPooling (ctx , apiClient , accountId , projectId , clusterId )
1960
1967
if err != nil {
1961
1968
resp .Diagnostics .AddError ("Disable connection pooling failed: " , err .Error ())
@@ -2199,7 +2206,7 @@ func (r resourceCluster) Update(ctx context.Context, req tfsdk.UpdateResourceReq
2199
2206
}
2200
2207
2201
2208
// Enable connection pooling if the desired state is set to 'Enabled'
2202
- if ! plan .DesiredConnectionPoolingState .Unknown && strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) {
2209
+ if fflags . IsFeatureFlagEnabled ( fflags . CONNECTION_POOLING ) && ! plan .DesiredConnectionPoolingState .Unknown && strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) {
2203
2210
err := enableConnectionPooling (ctx , apiClient , accountId , projectId , clusterId )
2204
2211
if err != nil {
2205
2212
resp .Diagnostics .AddError ("Enabling connection pooling Failed: " , err .Error ())
@@ -2248,7 +2255,7 @@ func (r resourceCluster) Update(ctx context.Context, req tfsdk.UpdateResourceReq
2248
2255
cluster .DesiredState .Value = plan .DesiredState .Value
2249
2256
}
2250
2257
2251
- if strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) {
2258
+ if fflags . IsFeatureFlagEnabled ( fflags . CONNECTION_POOLING ) && ( strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) || strings .EqualFold (plan .DesiredConnectionPoolingState .Value , "Enabled" ) ) {
2252
2259
cluster .DesiredConnectionPoolingState .Value = plan .DesiredConnectionPoolingState .Value
2253
2260
}
2254
2261
0 commit comments