googleapis/mcp-toolbox · error
failed to delete cluster: %w
Error message
failed to delete cluster: %w
What it means
This error wraps any failure from the Bigtable InstanceAdmin DeleteCluster call inside Source.DeleteCluster. The library wraps the underlying API error with fmt.Errorf("failed to delete cluster: %w", err) so the root cause (not found, permissions, last remaining cluster) stays intact. Check the wrapped gRPC error for the actual status.
Source
Thrown at internal/sources/bigtable/admin_wrappers.go:126
err := s.InstanceAdmin.CreateCluster(ctx, conf)
if err != nil {
return nil, fmt.Errorf("failed to create cluster: %w", err)
}
return map[string]string{"status": "cluster created successfully"}, nil
}
func (s *Source) UpdateCluster(ctx context.Context, instanceId, clusterId string, serveNodes int32) (any, error) {
err := s.InstanceAdmin.UpdateCluster(ctx, instanceId, clusterId, serveNodes)
if err != nil {
return nil, fmt.Errorf("failed to update cluster: %w", err)
}
return map[string]string{"status": "cluster updated successfully"}, nil
}
func (s *Source) DeleteCluster(ctx context.Context, instanceId, clusterId string) (any, error) {
err := s.InstanceAdmin.DeleteCluster(ctx, instanceId, clusterId)
if err != nil {
return nil, fmt.Errorf("failed to delete cluster: %w", err)
}
return map[string]string{"status": "cluster deleted successfully"}, nil
}
func (s *Source) GetTable(ctx context.Context, tableId string) (any, error) {
table, err := s.Admin.TableInfo(ctx, tableId)
if err != nil {
return nil, fmt.Errorf("failed to get table: %w", err)
}
return table, nil
}
func (s *Source) CreateTable(ctx context.Context, tableId, columnFamily string) (any, error) {
err := s.Admin.CreateTable(ctx, tableId)
if err != nil {
return nil, fmt.Errorf("failed to create table: %w", err)
}
if columnFamily != "" {View on GitHub (pinned to 8cc6e09de2)
Solutions
- Confirm the cluster still exists and the ID is correct before deleting (it is an idempotency question — NotFound often means it is already gone).
- If it is the last cluster in the instance, add another cluster first or delete the whole instance instead.
- Grant the caller roles/bigtable.admin or bigtable.clusters.delete permission.
- Check for backups/views blocking deletion; treat gRPC Unavailable/DeadlineExceeded as retryable with backoff.
Example fix
// before: undifferentiated handling
return nil, fmt.Errorf("failed to delete cluster: %w", err)
// after: treat NotFound as already-deleted
if code := status.Code(err); code == codes.NotFound {
return map[string]string{"status": "cluster already deleted"}, nil
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: confirm cluster exists before delete
clusters, err := listClusters(ctx, instanceId)
if err == nil && !slices.Contains(clusters, clusterId) {
return nil // nothing to delete
} Type guard
func isAlreadyGone(err error) bool {
return status.Code(err) == codes.NotFound
} Try / catch
if err := src.DeleteCluster(ctx, inst, cluster); err != nil {
if status.Code(err) == codes.NotFound {
return nil // idempotent success
}
if status.Code(err) == codes.FailedPrecondition {
return fmt.Errorf("cannot delete last cluster; %v", err)
}
return fmt.Errorf("delete cluster: %w", err)
} Prevention
- Treat NotFound as success in cleanup/idempotent scripts.
- Never delete the last cluster of an instance; delete the instance instead.
- Check for dependent backups or logical views before deleting.
- Use a service account with bigtable.clusters.delete granted.
When it happens
Trigger: Calling the bigtable delete_cluster tool where s.InstanceAdmin.DeleteCluster(ctx, instanceId, clusterId) errors: cluster ID does not exist, attempting to delete the last cluster of an instance (not allowed), insufficient IAM permissions (bigtable.clusters.delete), or a transient gRPC/network failure.
Common situations: Deleting an already-deleted or mistyped cluster; trying to remove the final cluster in an instance (Bigtable requires at least one); service account lacking Bigtable Admin; dependency-locked clusters referenced by logical views or backups.
Related errors
- failed to update cluster: %w
- failed to get table: %w
- failed to create table: %w
- failed to delete table: %w
- failed to create column family: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/9712b05296273426.
Report an issue: GitHub.