Skip to content

[ws-manager-bridge] the number of workspace instances remaining seems to be wrong #11399

Closed as not planned
@jenting

Description

@jenting

Bug description

We wanted to delete the us53 cluster, the number of workspace pod is empty, so we triggered the werft job to delete the us53 cluster. But somehow, the ws-manager-bridge reported the number of running instances is 2.

Updated property [core/project].
downloading sha256:c479b2288f1e17ae558d565dcd1d686765cf4b9c310a5c85d2bbcdc644074b91  100% || (21/21 MB, 51.481 MB/s)
Switched to context "us53".
🚀 Retrieving governing meta cluster prod-meta-us02 kubeconfig
Fetching cluster endpoint and auth data.
kubeconfig entry generated for prod-meta-us02.
🚀 Changing kubectx to prod-meta-us02
Switched to context "gke_gitpod-191109_us-west1_prod-meta-us02".
Context "gke_gitpod-191109_us-west1_prod-meta-us02" modified.
Active namespace is "default".
🚀 Deregistering cluster us53
time="2022-07-14T20:35:29Z" level=fatal msg="rpc error: code = Unknown desc = cluster is not empty (2 instances remaining)"

After that, we check the DB according to the code logic

  • const instances = await this.workspaceDB.findRegularRunningInstances();
  • public async findRegularRunningInstances(userId?: string): Promise<WorkspaceInstance[]> {
    const infos = await this.findRunningInstancesWithWorkspaces(undefined, userId);
    return infos.filter((info) => info.workspace.type === "regular").map((wsinfo) => wsinfo.latestInstance);
    }
    public async findRunningInstancesWithWorkspaces(
    installation?: string,
    userId?: string,
    includeStopping: boolean = false,
    ): Promise<RunningWorkspaceInfo[]> {
    const params: any = {};
    const conditions = ["wsi.phasePersisted != 'stopped'", "wsi.deleted != TRUE"];
    if (!includeStopping) {
    // This excludes instances in a 'stopping' phase
    conditions.push("wsi.phasePersisted != 'stopping'");
    }
    if (installation) {
    params.region = installation;
    conditions.push("wsi.region = :region");
    }
    const joinParams: any = {};
    const joinConditions = [];
    if (userId) {
    joinParams.userId = userId;
    joinConditions.push("ws.ownerId = :userId");
    }
    return this.doJoinInstanceWithWorkspace<RunningWorkspaceInfo>(
    conditions,
    params,
    joinConditions,
    joinParams,
    (wsi, ws) => {
    return { workspace: ws, latestInstance: wsi };
    },
    );
    }

The number of workspace according to the criteria using SQL query is 10, rather than 2.

We are not sure is it the bug of ws-manager-bridge or we input the wrong query parameters.

Steps to reproduce

Internal slack thread.

Workspace affected

No response

Expected behavior

No response

Example repository

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    team: webappIssue belongs to the WebApp teamtype: bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions