Skip to content

Commit d8cd553

Browse files
committed
fix: uncomment after fixing upstream
1 parent f8d6629 commit d8cd553

11 files changed

+207
-208
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ require (
103103
gopkg.in/yaml.v3 v3.0.1 // indirect
104104
)
105105

106-
replace github.com/datastax/astra-client-go/v2 => github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251014131947-9665c4fa0857
106+
replace github.com/datastax/astra-client-go/v2 => github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251020202040-d7a36e274d4e

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
8181
github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
8282
github.com/aws/aws-sdk-go v1.38.67 h1:OCeXMKiiM8X7HAKPCE5yD+t+sEsRaj8EwDs2tlgvX2c=
8383
github.com/aws/aws-sdk-go v1.38.67/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
84-
github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251014131947-9665c4fa0857 h1:isVQFmmNsi+zo0FPGiKugP7QPXfe8JIi64XYEYUH0CQ=
85-
github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251014131947-9665c4fa0857/go.mod h1:piBMy3fnDcLN8+MDQfvjZr8ejcP2oh+CXkQYwNy8blA=
84+
github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251020202040-d7a36e274d4e h1:xKcciSSwUwy3zsM1mT7y6kUJjaYM0wnEQLqIDD1LkkQ=
85+
github.com/bdunn313/astra-client-go/v2 v2.2.64-0.20251020202040-d7a36e274d4e/go.mod h1:piBMy3fnDcLN8+MDQfvjZr8ejcP2oh+CXkQYwNy8blA=
8686
github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
8787
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
8888
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=

internal/provider/data_source_access_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ func listAccessList(ctx context.Context, client *astra.ClientWithResponses, data
9595
}
9696

9797
// If the database is terminated then the access list has been deleted.
98-
//if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED { TODO uncomment
99-
// return nil, nil
100-
//}
98+
if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED {
99+
return nil, nil
100+
}
101101

102102
resp, err := client.GetAccessListForDatabase(ctx, astra.DatabaseIdParam(databaseID))
103103
if err != nil {

internal/provider/data_source_keyspaces.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ func listKeyspaces(ctx context.Context, client *astra.ClientWithResponses, datab
7575
}
7676

7777
// If the database is terminated then the keyspaces have been deleted.
78-
//if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED { TODO uncomment
79-
// return nil, nil
80-
//}
78+
if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED {
79+
return nil, nil
80+
}
8181

8282
allKeyspaces := astra.StringSlice(db.Info.AdditionalKeyspaces)
8383
if k := astra.StringValue(db.Info.Keyspace); k != "" {

internal/provider/data_source_private_link_endpoints.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ func listPrivateLinkEndpoints(ctx context.Context, client *astra.ClientWithRespo
108108
}
109109

110110
// If the database is terminated then the private links have been deleted.
111-
//if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED { TODO uncomment
112-
// return nil, nil
113-
//}
111+
if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED {
112+
return nil, nil
113+
}
114114

115115
plResponse, err := client.GetPrivateLinkEndpointWithResponse(ctx, databaseID, datacenterID, endpointID)
116116
if err != nil {

internal/provider/data_source_private_links.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ func listPrivateLinks(ctx context.Context, client *astra.ClientWithResponses, da
109109
}
110110

111111
// If the database is terminated then the private links have been deleted.
112-
//if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED { TODO uncomment
113-
// return nil, nil
114-
//}
112+
if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED {
113+
return nil, nil
114+
}
115115

116116
plResponse, err := client.GetPrivateLinksForDatacenterWithResponse(ctx, databaseID, datacenterID)
117117

internal/provider/resource_cdc_v3.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ func waitForDatabaseActive(ctx context.Context, client *astra.ClientWithResponse
444444
// Success fetching database
445445
dbStatus := res.JSON200.Status
446446
switch dbStatus {
447-
//case astra.ERROR, astra.TERMINATED, astra.TERMINATING: TODO uncomment
448-
// // If the database reached a terminal state it will never become active
449-
// return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status='%s'", dbStatus))
450-
//case astra.ACTIVE:
451-
// return nil
447+
case astra.ERROR, astra.TERMINATED, astra.TERMINATING:
448+
// If the database reached a terminal state it will never become active
449+
return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status='%s'", dbStatus))
450+
case astra.ACTIVE:
451+
return nil
452452
default:
453453
return retry.RetryableError(fmt.Errorf("waiting database to be active but is '%s'", dbStatus))
454454
}

internal/provider/resource_database.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ func resourceDatabaseRead(ctx context.Context, resourceData *schema.ResourceData
265265
}
266266

267267
// If the database is TERMINATING or TERMINATED then remove it from the state
268-
//if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED { TODO uncomment
269-
// resourceData.SetId("")
270-
// return nil
271-
//}
268+
if db.Status == astra.TERMINATING || db.Status == astra.TERMINATED {
269+
resourceData.SetId("")
270+
return nil
271+
}
272272

273273
// Add the database to state
274274
if err := setDatabaseResourceData(resourceData, db); err != nil {
@@ -369,9 +369,9 @@ func resourceDatabaseDelete(ctx context.Context, resourceData *schema.ResourceDa
369369

370370
// Return when the database is in a TERMINATED state
371371
db := res.JSON200
372-
//if db.Status == astra.TERMINATED { TODO uncomment
373-
// return nil
374-
//}
372+
if db.Status == astra.TERMINATED {
373+
return nil
374+
}
375375

376376
// Continue until one of the expected conditions above are met
377377
return retry.RetryableError(fmt.Errorf("expected database to be terminated but is %s", db.Status))
@@ -524,14 +524,14 @@ func waitForDatabaseAndUpdateResource(ctx context.Context, resourceData *schema.
524524
// Success fetching database
525525
db := res.JSON200
526526
switch db.Status {
527-
//case astra.ERROR, astra.TERMINATED, astra.TERMINATING: TODO uncomment
528-
// If the database reached a terminal state it will never become active
529-
//return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
530-
//case astra.ACTIVE:
531-
// if err := setDatabaseResourceData(resourceData, db); err != nil {
532-
// return retry.NonRetryableError(err)
533-
// }
534-
// return nil
527+
case astra.ERROR, astra.TERMINATED, astra.TERMINATING:
528+
// If the database reached a terminal state it will never become active
529+
return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
530+
case astra.ACTIVE:
531+
if err := setDatabaseResourceData(resourceData, db); err != nil {
532+
return retry.NonRetryableError(err)
533+
}
534+
return nil
535535
default:
536536
return retry.RetryableError(fmt.Errorf("expected database to be active but is %s", db.Status))
537537
}

internal/provider/resource_keyspace.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func resourceKeyspaceCreate(ctx context.Context, d *schema.ResourceData, meta in
5252
client := meta.(astraClients).astraClient.(*astra.ClientWithResponses)
5353

5454
databaseID := d.Get("database_id").(string)
55-
//keyspaceName := d.Get("name").(string) TODO uncomment
55+
keyspaceName := d.Get("name").(string)
5656

5757
//Wait for DB to be in Active status
5858
if err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *retry.RetryError {
@@ -77,30 +77,30 @@ func resourceKeyspaceCreate(ctx context.Context, d *schema.ResourceData, meta in
7777
// Success fetching database
7878
db := res.JSON200
7979
switch db.Status {
80-
//case astra.ERROR, astra.TERMINATED, astra.TERMINATING: TODO uncomment
81-
// // If the database reached a terminal state it will never become active
82-
// return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
83-
//case astra.ACTIVE:
84-
// keyspaceMutex.Lock()
85-
// resp, err := client.AddKeyspaceWithResponse(ctx, astra.DatabaseIdParam(databaseID), astra.KeyspaceNameParam(keyspaceName))
86-
// keyspaceMutex.Unlock()
87-
// if err != nil {
88-
// return retry.NonRetryableError(fmt.Errorf("error calling add keyspace (not retrying) %s", err))
89-
// } else if resp.StatusCode() == 409 {
90-
// // DevOps API returns 409 for concurrent modifications, these need to be retried.
91-
// return retry.RetryableError(fmt.Errorf("error adding keyspace to database (retrying): %s", string(resp.Body)))
92-
// } else if resp.StatusCode() == 401 {
93-
// // DevOps API returns 401 Unauthorized for requests without the keyspace create permission
94-
// return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (insufficient permissions, role missing 'db-keyspace-create')"))
95-
// } else if resp.StatusCode() >= 400 {
96-
// return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (not retrying): %s", string(resp.Body)))
97-
// }
98-
//
99-
// if err := setKeyspaceResourceData(d, databaseID, keyspaceName); err != nil {
100-
// return retry.NonRetryableError(fmt.Errorf("error setting keyspace data (not retrying) %s", err))
101-
// }
102-
//
103-
// return nil
80+
case astra.ERROR, astra.TERMINATED, astra.TERMINATING:
81+
// If the database reached a terminal state it will never become active
82+
return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
83+
case astra.ACTIVE:
84+
keyspaceMutex.Lock()
85+
resp, err := client.AddKeyspaceWithResponse(ctx, astra.DatabaseIdParam(databaseID), astra.KeyspaceNameParam(keyspaceName))
86+
keyspaceMutex.Unlock()
87+
if err != nil {
88+
return retry.NonRetryableError(fmt.Errorf("error calling add keyspace (not retrying) %s", err))
89+
} else if resp.StatusCode() == 409 {
90+
// DevOps API returns 409 for concurrent modifications, these need to be retried.
91+
return retry.RetryableError(fmt.Errorf("error adding keyspace to database (retrying): %s", string(resp.Body)))
92+
} else if resp.StatusCode() == 401 {
93+
// DevOps API returns 401 Unauthorized for requests without the keyspace create permission
94+
return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (insufficient permissions, role missing 'db-keyspace-create')"))
95+
} else if resp.StatusCode() >= 400 {
96+
return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (not retrying): %s", string(resp.Body)))
97+
}
98+
99+
if err := setKeyspaceResourceData(d, databaseID, keyspaceName); err != nil {
100+
return retry.NonRetryableError(fmt.Errorf("error setting keyspace data (not retrying) %s", err))
101+
}
102+
103+
return nil
104104
default:
105105
return retry.RetryableError(fmt.Errorf("expected database to be active but is %s", db.Status))
106106
}
@@ -144,7 +144,7 @@ func resourceKeyspaceDelete(ctx context.Context, d *schema.ResourceData, meta in
144144
client := meta.(astraClients).astraClient.(*astra.ClientWithResponses)
145145

146146
databaseID := d.Get("database_id").(string)
147-
//keyspaceName := d.Get("name").(string) TODO uncomment
147+
keyspaceName := d.Get("name").(string)
148148

149149
//Wait for DB to be in Active status
150150
if err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *retry.RetryError {
@@ -169,27 +169,27 @@ func resourceKeyspaceDelete(ctx context.Context, d *schema.ResourceData, meta in
169169
// Success fetching database
170170
db := res.JSON200
171171
switch db.Status {
172-
//case astra.ERROR, astra.TERMINATED, astra.TERMINATING: TODO uncomment
173-
// // If the database reached a terminal state it will never become active
174-
// return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
175-
//case astra.ACTIVE:
176-
// keyspaceMutex.Lock()
177-
// resp, err := client.DropKeyspaceWithResponse(ctx, astra.DatabaseIdParam(databaseID), astra.KeyspaceNameParam(keyspaceName))
178-
// keyspaceMutex.Unlock()
179-
// if err != nil {
180-
// return retry.NonRetryableError(fmt.Errorf("error calling drop keyspace (not retrying) %s", err))
181-
// } else if resp.StatusCode() == 409 {
182-
// // DevOps API returns 409 for concurrent modifications, these need to be retried.
183-
// return retry.RetryableError(fmt.Errorf("error dropping keyspace from database (retrying): %s", string(resp.Body)))
184-
// } else if resp.StatusCode() == 401 {
185-
// // DevOps API returns 401 Unauthorized for requests without the keyspace drop permission
186-
// return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (insufficient permissions, role missing 'db-keyspace-drop')"))
187-
// } else if resp.StatusCode() >= 400 {
188-
// return retry.NonRetryableError(fmt.Errorf("error dropping keyspace from database (not retrying): %s", string(resp.Body)))
189-
// }
190-
//
191-
// d.SetId("")
192-
// return nil
172+
case astra.ERROR, astra.TERMINATED, astra.TERMINATING:
173+
// If the database reached a terminal state it will never become active
174+
return retry.NonRetryableError(fmt.Errorf("database failed to reach active status: status=%s", db.Status))
175+
case astra.ACTIVE:
176+
keyspaceMutex.Lock()
177+
resp, err := client.DropKeyspaceWithResponse(ctx, astra.DatabaseIdParam(databaseID), astra.KeyspaceNameParam(keyspaceName))
178+
keyspaceMutex.Unlock()
179+
if err != nil {
180+
return retry.NonRetryableError(fmt.Errorf("error calling drop keyspace (not retrying) %s", err))
181+
} else if resp.StatusCode() == 409 {
182+
// DevOps API returns 409 for concurrent modifications, these need to be retried.
183+
return retry.RetryableError(fmt.Errorf("error dropping keyspace from database (retrying): %s", string(resp.Body)))
184+
} else if resp.StatusCode() == 401 {
185+
// DevOps API returns 401 Unauthorized for requests without the keyspace drop permission
186+
return retry.NonRetryableError(fmt.Errorf("error adding keyspace to database (insufficient permissions, role missing 'db-keyspace-drop')"))
187+
} else if resp.StatusCode() >= 400 {
188+
return retry.NonRetryableError(fmt.Errorf("error dropping keyspace from database (not retrying): %s", string(resp.Body)))
189+
}
190+
191+
d.SetId("")
192+
return nil
193193
default:
194194
return retry.RetryableError(fmt.Errorf("expected database to be active but is %s", db.Status))
195195
}

internal/provider/resource_streaming_tenant.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ func setStreamingTenantData(data *StreamingTenantResourceModel, tenantResponse *
398398
}
399399

400400
// requiresReplaceIfClusterChange only require replace if the cluster name, cloud provider, or region has changed.
401-
402401
func requiresReplaceIfClusterChange() planmodifier.String {
403402
return stringplanmodifier.RequiresReplaceIf(
404403
func(ctx context.Context, req planmodifier.StringRequest, resp *stringplanmodifier.RequiresReplaceIfFuncResponse) {

0 commit comments

Comments
 (0)