Skip to content

Kubernetes cluster creation fails - cluster worker missing TenantID in context #466

@poyrazK

Description

@poyrazK

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?

  1. Fix the cluster repository to include tenant_id in INSERT and SELECT statements
  2. Have the cluster worker look up the VPC's tenant_id and set it in the context before calling downstream services

Category

  • Small
  • Medium
  • Large
  • Critical

Severity

  • Low
  • Medium
  • High
  • Critical

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions