Skip to content

Backend changes for workspaces admin

Chad Woolley requested to merge caw-workspace-admin-backend into master

Issue: GraphQL and Policy changes to support Workspace... (#426507 - closed)

What does this MR do and why?

See detailed description in GraphQL and Policy changes to support Workspace... (#426507 - closed)

See overview of Category:Remote Development Workspaces Admin UI issues and MRs in MVP of Admin UI for Workspaces (&11992 - closed)

How to set up and validate locally

Create an agent and workspace in local development environment to use with the following query, using instructions in https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/-/blob/main/doc/local-development-environment-setup.md

But this is very involved, I'm happy to pair to demonstrate if you want to exploratory test it in an already-configured environment.

Sample graphiql query for development:

query getAgentWorkspaces($clusterAgentName: String!, $agentProjectFullPath: ID!) {
  project(fullPath: $agentProjectFullPath) {
    clusterAgent(name: $clusterAgentName) {
      workspaces {
        nodes {
          id
          clusterAgent {
            createdAt
            id
            name
            updatedAt
            webPath
          }
          projectId
          user {
            id
            bot
            username
            name
            state
            email
            publicEmail
            commitEmail
            avatarUrl
            webUrl
            webPath
            groupCount
            location
            gitpodEnabled
            preferencesGitpodPath
            profileEnableGitpodPath
            bio
            linkedin
            twitter
            discord
            organization
            jobTitle
            createdAt
            pronouns
          }
          name
          namespace
          desiredState
          desiredStateUpdatedAt
          actualState
          respondedToAgentAt
          url
          editor
          maxHoursBeforeTermination
          devfileRef
          devfilePath
          devfile
          processedDevfile
          deploymentResourceVersion
          createdAt
          updatedAt
        }
      }
    }
  }
}

Variables for above query (depends on your env and primary keys):

{
  "agentProjectFullPath": "gitlab-org/gitlab-org-subgroup/gitlab-org-sub-subgroup/gitlab-agent-configurations",
  "clusterAgentName": "remotedev"
}

Sample json response from above query:

{
  "data": {
    "project": {
      "clusterAgent": {
        "workspaces": {
          "nodes": [
            {
              "id": "gid://gitlab/RemoteDevelopment::Workspace/72",
              "clusterAgent": {
                "createdAt": "2023-05-17T03:30:28Z",
                "id": "gid://gitlab/Clusters::Agent/4",
                "name": "remotedev",
                "updatedAt": "2023-05-17T03:30:28Z",
                "webPath": "/gitlab-org/gitlab-org-subgroup/gitlab-org-sub-subgroup/gitlab-agent-configurations/-/cluster_agents/remotedev"
              },
              "projectId": "gid://gitlab/Project/2",
              "user": {
                "id": "gid://gitlab/User/1",
                "bot": false,
                "username": "root",
                "name": "Administrator",
                "state": "active",
                "email": null,
                "publicEmail": null,
                "commitEmail": null,
                "avatarUrl": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
                "webUrl": "http://gdk.test:3000/root",
                "webPath": "/root",
                "groupCount": 24,
                "location": "",
                "gitpodEnabled": false,
                "preferencesGitpodPath": null,
                "profileEnableGitpodPath": null,
                "bio": "",
                "linkedin": "",
                "twitter": "",
                "discord": "",
                "organization": "",
                "jobTitle": "",
                "createdAt": "2022-04-26T17:43:46Z",
                "pronouns": null
              },
              "name": "workspace-4-1-phpat9",
              "namespace": "gl-rd-ns-4-1-phpat9",
              "desiredState": "Terminated",
              "desiredStateUpdatedAt": "2023-11-18T13:54:51Z",
              "actualState": "Terminated",
              "respondedToAgentAt": "2023-11-18T13:55:07Z",
              "url": "https://60001-workspace-4-1-phpat9.workspaces.localdev.me?folder=%2Fprojects%2Fgitlab-shell",
              "editor": "webide",
              "maxHoursBeforeTermination": 24,
              "devfileRef": "main",
              "devfilePath": ".devfile.yaml",
              "devfile": "#invalid: invalid field forcing a validation error in devfile gem\nschemaVersion: 2.2.0\ncomponents:\n- name: tooling-container\n  attributes:\n    gl/inject-editor: true\n  container:\n    image: quay.io/mloriedo/universal-developer-image:ubi8-dw-demo\n",
              "processedDevfile": "---\ncomponents:\n- attributes:\n    gl/inject-editor: true\n  container:\n    dedicatedPod: false\n    image: quay.io/mloriedo/universal-developer-image:ubi8-dw-demo\n    mountSources: true\n    command:\n    - \"/projects/.gl-editor/start_server.sh\"\n    volumeMounts:\n    - name: gl-workspace-data\n      path: \"/projects\"\n    env:\n    - name: EDITOR_VOLUME_DIR\n      value: \"/projects/.gl-editor\"\n    - name: EDITOR_PORT\n      value: '60001'\n    - name: SSH_PORT\n      value: '60022'\n    endpoints:\n    - name: editor-server\n      targetPort: 60001\n      exposure: public\n      secure: true\n      protocol: https\n    - name: ssh-server\n      targetPort: 60022\n      exposure: internal\n      secure: true\n  name: tooling-container\n- name: gl-workspace-data\n  volume:\n    size: 15Gi\n- name: gl-editor-injector\n  container:\n    image: registry.gitlab.com/gitlab-org/gitlab-web-ide-vscode-fork/web-ide-injector:2\n    volumeMounts:\n    - name: gl-workspace-data\n      path: \"/projects\"\n    env:\n    - name: EDITOR_VOLUME_DIR\n      value: \"/projects/.gl-editor\"\n    - name: EDITOR_PORT\n      value: '60001'\n    - name: SSH_PORT\n      value: '60022'\n    memoryLimit: 256Mi\n    memoryRequest: 128Mi\n    cpuLimit: 500m\n    cpuRequest: 100m\n- name: gl-cloner-injector\n  container:\n    image: alpine/git:2.36.3\n    volumeMounts:\n    - name: gl-workspace-data\n      path: \"/projects\"\n    args:\n    - |-\n      if [ ! -d '/projects/gitlab-shell' ];\n      then\n        git clone --branch main http://gdk.test:3000/gitlab-org/gitlab-shell.git /projects/gitlab-shell;\n      fi\n    command:\n    - \"/bin/sh\"\n    - \"-c\"\n    memoryLimit: 256Mi\n    memoryRequest: 128Mi\n    cpuLimit: 500m\n    cpuRequest: 100m\nmetadata: {}\nschemaVersion: 2.2.0\ncommands:\n- id: gl-editor-injector-command\n  apply:\n    component: gl-editor-injector\n- id: gl-cloner-injector-command\n  apply:\n    component: gl-cloner-injector\nevents:\n  preStart:\n  - gl-editor-injector-command\n  - gl-cloner-injector-command\n",
              "deploymentResourceVersion": 8341187,
              "createdAt": "2023-11-17T13:54:34Z",
              "updatedAt": "2023-11-18T13:55:07Z"
            }
          ]
        }
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Chad Woolley

Merge request reports

Loading