Skip to content

Add GraphQL type for agent metadata

Tiger Watson requested to merge 322605-fix-agentk-metadata into master

What does this MR do and why?

Replaces a broken JSON field with a dedicated type for ConnectedAgent.metadata. Previously the metadata was not serialized properly, which always resulted in an empty value.

Screenshots or screen recordings

GraphQL request:

{
  project(fullPath: "path/to/agent/project") {    
    clusterAgents {
      edges {
        node {
          name
          connections {
            edges {
              node {
                connectedAt
                connectionId
                metadata {
                  version
                  commit
                  podName
                  podNamespace
                }
              }
            }
          }
        }
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "clusterAgents": {
        "edges": [
          {
            "node": {
              "name": "my-agent",
              "connections": {
                "edges": [
                  {
                    "node": {
                      "connectedAt": "2021-09-15T09:40:29+10:00",
                      "connectionId": "8100640246091127",
                      "metadata": {
                        "version": "v14.2.2",
                        "commit": "2b22fa6",
                        "podName": "gitlab-agent-698f74d7c8-tnfp4",
                        "podNamespace": "gitlab-kubernetes-agent"
                      }
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

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

Related to #322605 (closed)

Edited by Tiger Watson

Merge request reports