{"record":{"id":"0cc6d40e17f94f28","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-cluster-w","errorCode":null,"errorMessage":"failed to create cluster: %w","messagePattern":"failed to create cluster: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigtable/admin_wrappers.go","lineNumber":110,"sourceCode":"\t\tvar partialErr bigtable.ErrPartiallyUnavailable\n\t\tif errors.As(err, &partialErr) {\n\t\t\treturn clusters, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to list clusters: %w\", err)\n\t}\n\treturn clusters, nil\n}\n\nfunc (s *Source) CreateCluster(ctx context.Context, instanceId, clusterId, zone string, numNodes int32) (any, error) {\n\tconf := &bigtable.ClusterConfig{\n\t\tInstanceID: instanceId,\n\t\tClusterID:  clusterId,\n\t\tZone:       zone,\n\t\tNumNodes:   numNodes,\n\t}\n\terr := s.InstanceAdmin.CreateCluster(ctx, conf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create cluster: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"cluster created successfully\"}, nil\n}\n\nfunc (s *Source) UpdateCluster(ctx context.Context, instanceId, clusterId string, serveNodes int32) (any, error) {\n\terr := s.InstanceAdmin.UpdateCluster(ctx, instanceId, clusterId, serveNodes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to update cluster: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"cluster updated successfully\"}, nil\n}\n\nfunc (s *Source) DeleteCluster(ctx context.Context, instanceId, clusterId string) (any, error) {\n\terr := s.InstanceAdmin.DeleteCluster(ctx, instanceId, clusterId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to delete cluster: %w\", err)\n\t}\n\treturn map[string]string{\"status\": \"cluster deleted successfully\"}, nil","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/admin_wrappers.go#L92-L128","documentation":"Raised by CreateCluster when the InstanceAdmin.CreateCluster admin RPC fails. The error wraps the original cause (PermissionDenied, InvalidArgument, FailedPrecondition, resource exhaustion). It means the new cluster (with the given zone and node count) could not be provisioned in the target instance.","triggerScenarios":"Calling CreateCluster(ctx, instanceId, clusterId, zone, numNodes) with an invalid/unsupported zone, a duplicate clusterId in the same instance, numNodes=0 for a production instance, insufficient quota for nodes, missing IAM permission, or the instance being in a state that rejects cluster creation.","commonSituations":"Typos in zone names (e.g. 'us-east1' instead of 'us-east1-b'); reusing a cluster ID that already exists; hitting project quota for Bigtable nodes; running with credentials lacking roles/bigtable.admin; attempting to add clusters to an instance type that disallows it.","solutions":["Validate the zone against Bigtable-supported regions (`gcloud bigtable clusters create --help` or docs) and ensure the clusterId is unique in the instance.","Ensure numNodes >= 1 for PRODUCTION instances and check node quota in the Cloud Console.","Grant the caller roles/bigtable.admin so cluster creation is permitted.","Unwrap the error (errors.As / status.FromError) and map InvalidArgument/AlreadyExists/ResourceExhausted to input validation instead of retries."],"exampleFix":"// before\nconf := &bigtable.ClusterConfig{ClusterID: clusterId, Zone: zone, NumNodes: numNodes}\nerr := s.InstanceAdmin.CreateCluster(ctx, conf)\n// after\nif numNodes <= 0 {\n    return nil, fmt.Errorf(\"numNodes must be >= 1 for production clusters\")\n}\nconf := &bigtable.ClusterConfig{ClusterID: clusterId, Zone: \"us-east1-b\", NumNodes: numNodes}\nerr := s.InstanceAdmin.CreateCluster(ctx, conf)","handlingStrategy":"validation","validationCode":"var supportedZones = map[string]bool{\"us-east1-b\": true, \"us-central1-c\": true}\n\nfunc validateClusterInput(instanceId, clusterId, zone string, numNodes int32, existing []string) error {\n    if !supportedZones[zone] {\n        return fmt.Errorf(\"unsupported zone %q\", zone)\n    }\n    for _, id := range existing {\n        if id == clusterId {\n            return fmt.Errorf(\"cluster %q already exists\", clusterId)\n        }\n    }\n    if numNodes < 1 {\n        return fmt.Errorf(\"numNodes must be >= 1\")\n    }\n    return nil\n}","typeGuard":"func clusterCreateErrorCode(err error) codes.Code {\n    if st, ok := status.FromError(errors.Unwrap(err)); ok {\n        return st.Code()\n    }\n    return codes.Unknown\n}\n// AlreadyExists -> duplicate id; InvalidArgument -> bad zone/nodes; ResourceExhausted -> quota","tryCatchPattern":"err := createCluster(ctx, conf)\nif err != nil {\n    switch clusterCreateErrorCode(err) {\n    case codes.AlreadyExists:\n        return nil // treat create as idempotent\n    case codes.ResourceExhausted:\n        return fmt.Errorf(\"node quota exceeded; request quota increase\")\n    case codes.InvalidArgument:\n        return fmt.Errorf(\"invalid zone or node count: %w\", err)\n    default:\n        return fmt.Errorf(\"create cluster: %w\", err)\n    }\n}","preventionTips":["Validate zone names and node counts against Bigtable limits before calling CreateCluster.","Check for duplicate cluster IDs via ListClusters first to keep creation idempotent.","Monitor and request node quota increases for the project in advance.","Grant roles/bigtable.admin to the creating identity and test in a staging project first."],"tags":["gcp","bigtable","admin-api","create-cluster","error-wrapping"],"backgroundTag":"bigtable-admin-api-error","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}