Skip to content

GraphQL: Expose token_expires_at property and sorting

What does this MR do and why?

This is the sixth MR of !71607 (closed), as per !71607 (comment 791611312). It adds GraphQL functionality related to runner token expiration.

Testing

sort:TOKEN_EXPIRES_AT_DESC
query getRunners {
  runners(sort:TOKEN_EXPIRES_AT_DESC) {
    nodes {
      id
      runnerType
      tokenExpiresAt
    }
  }
}
{
  "data": {
    "runners": {
      "nodes": [
        {
          "id": "gid://gitlab/Ci::Runner/137",
          "runnerType": "INSTANCE_TYPE",
          "tokenExpiresAt": null
        },
        {
          "id": "gid://gitlab/Ci::Runner/97",
          "runnerType": "GROUP_TYPE",
          "tokenExpiresAt": null
        },
        {
          "id": "gid://gitlab/Ci::Runner/138",
          "runnerType": "INSTANCE_TYPE",
          "tokenExpiresAt": "2022-02-15T18:41:18Z"
        }
      ]
    }
  }
}
sort:TOKEN_EXPIRES_AT_ASC
query getRunners {
  runners(sort:TOKEN_EXPIRES_AT_ASC) {
    nodes {
      id
      runnerType
      tokenExpiresAt
    }
  }
}
{
  "data": {
    "runners": {
      "nodes": [
        {
          "id": "gid://gitlab/Ci::Runner/138",
          "runnerType": "INSTANCE_TYPE",
          "tokenExpiresAt": "2022-02-15T18:41:18Z"
        },
        {
          "id": "gid://gitlab/Ci::Runner/137",
          "runnerType": "INSTANCE_TYPE",
          "tokenExpiresAt": null
        },
        {
          "id": "gid://gitlab/Ci::Runner/97",
          "runnerType": "GROUP_TYPE",
          "tokenExpiresAt": null
        }
      ]
    }
  }
}

Database query plans

The queries generated by the GraphQL API are as follows:

SELECT
    "ci_runners".*
FROM
    "ci_runners"
ORDER BY
    "ci_runners"."token_expires_at" DESC,
    "ci_runners"."id" DESC
LIMIT 100

These queries were already approved in a previous MR.

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 Pedro Pombeiro

Merge request reports