Why is this an issue?
When creating a Kubernetes cluster, provisioning fails with "vpc not found" because the cluster worker sets UserID in the context but not TenantID. The VPC repository queries require tenant_id in the WHERE clause, so the lookup fails.
What is causing it?
The cluster worker at internal/workers/cluster_worker.go line 140 sets:
ctx := appcontext.WithUserID(workerCtx, job.UserID)
But the VPC repository's GetByID method queries with WHERE id = $1 AND tenant_id = $2. Since TenantID is not set in the context, appcontext.TenantIDFromContext(ctx) returns uuid.Nil, causing the query to fail.
Additionally, the cluster repository's INSERT statement doesn't include tenant_id column, so clusters are created with tenant_id = NULL.
How can it be solved?
- Fix the cluster repository to include
tenant_id in INSERT and SELECT statements
- Have the cluster worker look up the VPC's tenant_id and set it in the context before calling downstream services
Category
Severity
Steps to reproduce
cloud kubernetes create -n test-cluster -v <vpc-id> -w 1
# Cluster status: failed
# API log: "failed to get VPC" with "NOT_FOUND: vpc not found"
# The VPC exists but the tenant_id lookup fails
Why is this an issue?
When creating a Kubernetes cluster, provisioning fails with "vpc not found" because the cluster worker sets
UserIDin the context but notTenantID. The VPC repository queries requiretenant_idin the WHERE clause, so the lookup fails.What is causing it?
The cluster worker at
internal/workers/cluster_worker.goline 140 sets:But the VPC repository's
GetByIDmethod queries withWHERE id = $1 AND tenant_id = $2. SinceTenantIDis not set in the context,appcontext.TenantIDFromContext(ctx)returnsuuid.Nil, causing the query to fail.Additionally, the cluster repository's INSERT statement doesn't include
tenant_idcolumn, so clusters are created withtenant_id = NULL.How can it be solved?
tenant_idin INSERT and SELECT statementsCategory
Severity
Steps to reproduce