Skip to content

Show agent version warnings from KAS

What does this MR do and why?

As we had an issue with incorrectly identifying the suggested agent version and the state of the version incompatibility, we decided to switch to showing the version warning from KAS. This is the most accurate information.

This MR updates the frontend to use newly added Graphql fields (from Add resolver for new KAS fields (!174384 - merged)).

There could be such states of the agent regarding its version:

  • everything is good -> we show the agent version with no warnings;
  • agent has nodes with different versions -> we show the oldest of the agent versions and render a popover explaining the version mismatch;
  • agent has version warnings from KAS -> we show the agent version with a popover containing the warning message;
  • agent has both nodes with different versions and warnings from KAS -> we show the oldest version and render a popover explaining the version mismatch and containing the warning message.

When the version warnings are present, we also show a link to the documentation on how to update an agent.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Condition Screenshot
All agents in the list Screenshot_2024-12-11_at_16.25.58
Agent with warnings Screenshot_2024-12-11_at_16.26.10
Agent with version mismatch Screenshot_2024-12-11_at_16.26.16
Agent with warnings and version mismatch Screenshot_2024-12-11_at_16.26.25

How to set up and validate locally

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

Validate locally without full set up (using patch)

  1. Visit Project -> Operate -> Kubernetes clusters
  2. Apply patch
Click to expand
diff --git a/app/assets/javascripts/clusters_list/components/agents.vue b/app/assets/javascripts/clusters_list/components/agents.vue
index af0bb557fc57..5011f350bac3 100644
--- a/app/assets/javascripts/clusters_list/components/agents.vue
+++ b/app/assets/javascripts/clusters_list/components/agents.vue
@@ -33,7 +33,207 @@ export default {
         };
       },
       update(data) {
-        return data;
+        // return data;
+        return {
+          project: {
+            id: 'gid://gitlab/Project/48132041',
+            clusterAgents: {
+              nodes: [
+                {
+                  id: 'gid://gitlab/Clusters::Agent/68025',
+                  name: 'my-agent',
+                  webPath: '/anna_vovchenko/flux-for-gitops/-/cluster_agents/flux-agent',
+                  createdAt: '2023-07-31T12:59:43Z',
+                  project: {
+                    id: 'gid://gitlab/Project/48132041',
+                    fullPath: 'anna_vovchenko/flux-for-gitops',
+                  },
+                  userAccessAuthorizations: {
+                    config: {
+                      access_as: {
+                        agent: {},
+                      },
+                    },
+                  },
+                  connections: {
+                    nodes: [
+                      {
+                        metadata: {
+                          version: 'v17.11.0',
+                        },
+                        warnings: [],
+                      },
+                    ],
+                  },
+                  tokens: {
+                    nodes: [
+                      {
+                        id: 'gid://gitlab/Clusters::AgentToken/69166',
+                        lastUsedAt: '2024-12-10T10:27:28Z',
+                      },
+                    ],
+                  },
+                  isReceptive: false,
+                },
+                {
+                  id: 'gid://gitlab/Clusters::Agent/68029',
+                  name: 'agent-warnings',
+                  webPath: '/anna_vovchenko/flux-for-gitops/-/cluster_agents/flux-agent',
+                  createdAt: '2023-07-31T12:59:43Z',
+                  project: {
+                    id: 'gid://gitlab/Project/48132041',
+                    fullPath: 'anna_vovchenko/flux-for-gitops',
+                    __typename: 'Project',
+                  },
+                  userAccessAuthorizations: {
+                    config: {
+                      access_as: {
+                        agent: {},
+                      },
+                    },
+                    __typename: 'ClusterAgentAuthorizationUserAccess',
+                  },
+                  connections: {
+                    nodes: [
+                      {
+                        metadata: {
+                          version: 'v17.0.0',
+                        },
+                        warnings: [
+                          {
+                            version: {
+                              message:
+                                'The agent for Kubernetes (agentk) is outdated by more than four minor releases and might not be compatible with the agent server for Kubernetes (KAS). You should upgrade agentk.',
+                              type: 'OUTDATED',
+                            },
+                          },
+                        ],
+                      },
+                    ],
+                  },
+                  tokens: {
+                    nodes: [
+                      {
+                        id: 'gid://gitlab/Clusters::AgentToken/69166',
+                        lastUsedAt: '2024-12-10T10:27:28Z',
+                        __typename: 'ClusterAgentToken',
+                      },
+                    ],
+                    __typename: 'ClusterAgentTokenConnection',
+                  },
+                  __typename: 'ClusterAgent',
+                  isReceptive: false,
+                },
+                {
+                  id: 'gid://gitlab/Clusters::Agent/68026',
+                  name: 'agent-versions-mismatch',
+                  webPath: '/anna_vovchenko/flux-for-gitops/-/cluster_agents/flux-agent',
+                  createdAt: '2023-07-31T12:59:43Z',
+                  project: {
+                    id: 'gid://gitlab/Project/48132041',
+                    fullPath: 'anna_vovchenko/flux-for-gitops',
+                  },
+                  userAccessAuthorizations: {
+                    config: {
+                      access_as: {
+                        agent: {},
+                      },
+                    },
+                  },
+                  connections: {
+                    nodes: [
+                      {
+                        metadata: {
+                          version: 'v17.11.0',
+                        },
+                        warnings: [],
+                      },
+                      {
+                        metadata: {
+                          version: 'v17.12.0',
+                        },
+                        warnings: [],
+                      },
+                    ],
+                  },
+                  tokens: {
+                    nodes: [
+                      {
+                        id: 'gid://gitlab/Clusters::AgentToken/69166',
+                        lastUsedAt: '2024-12-10T10:27:28Z',
+                      },
+                    ],
+                  },
+                  isReceptive: false,
+                },
+                {
+                  id: 'gid://gitlab/Clusters::Agent/68030',
+                  name: 'mismatch-with-warnings',
+                  webPath: '/anna_vovchenko/flux-for-gitops/-/cluster_agents/flux-agent',
+                  createdAt: '2023-07-31T12:59:43Z',
+                  project: {
+                    id: 'gid://gitlab/Project/48132041',
+                    fullPath: 'anna_vovchenko/flux-for-gitops',
+                  },
+                  userAccessAuthorizations: {
+                    config: {
+                      access_as: {
+                        agent: {},
+                      },
+                    },
+                  },
+                  connections: {
+                    nodes: [
+                      {
+                        metadata: {
+                          version: 'v17.0.0',
+                        },
+                        warnings: [
+                          {
+                            version: {
+                              message:
+                                'The agent for Kubernetes (agentk) is outdated by more than four minor releases and might not be compatible with the agent server for Kubernetes (KAS). You should upgrade agentk.',
+                              type: 'OUTDATED',
+                            },
+                          },
+                        ],
+                      },
+                      {
+                        metadata: {
+                          version: 'v17.1.0',
+                        },
+                        warnings: [
+                          {
+                            version: {
+                              message:
+                                'The agent for Kubernetes (agentk) is outdated by more than four minor releases and might not be compatible with the agent server for Kubernetes (KAS). You should upgrade agentk.',
+                              type: 'OUTDATED',
+                            },
+                          },
+                        ],
+                      },
+                    ],
+                  },
+                  tokens: {
+                    nodes: [
+                      {
+                        id: 'gid://gitlab/Clusters::AgentToken/69166',
+                        lastUsedAt: '2024-12-10T10:27:28Z',
+                      },
+                    ],
+                  },
+                  isReceptive: false,
+                },
+              ],
+            },
+            ciAccessAuthorizedAgents: {
+              nodes: [],
+            },
+            userAccessAuthorizedAgents: {
+              nodes: [],
+            },
+          },
+        };
       },
       result() {
         this.emitAgentsLoaded();
  1. Verify the agent list with different states

Validate locally with the full set up and real data

  1. Enable KAS on your GDK (steps 1-2 from the guide).
  2. Visit the Project -> Infrastructure -> Kubernetes clusters page and create an agent following the instruction from the modal.
    • Select the "Connect a cluster" button
    • The modal should pop up
    • In the modal select "Select an agent or enter a name to create new"
    • You probably won't have any configured agents to show up in the list, create a new one by typing the name of your choice
    • The button should appear at the bottom of the list saying "Create agent: <your-agent-name>"
    • Select the button and click "Register" in the next view.
    • Save the token to use it in the next point.
  3. Follow points 3-8 from the guide and then the Deploy the GitLab Agent (agentk) with k3d section to create a local cluster and connect your agent with the cluster.
  4. Use different agent versions when installing to your cluster.
  5. Verify the agent list containing warnings.

Related to #506049

Edited by Anna Vovchenko

Merge request reports

Loading