Kubernetes Agent Registration - Agent name with special characters needs better validation
Summary
If you create a Kubernetes Agent configuration repository using special characters in the <agent_name>
subdirectory, the Kubernetes Registration dropdown does not list this agent.
We have only tested the following characters:
- hyphen - Ok
- underscore - Not Ok
- period - Not Ok
We documented that the agent name should follow RFC1123, but git allows other characters too, and the agent-name
git directory might be invalid as an agent name.
Today, we never warn the user about an invalid agent name, we just don't show the given agent in the registration dropdown.
Proposal
Implement a warning in the dropdown that shows how many or which agent configuration directories have an invalid name, without allowing to select them.
Option 1
Show invalid configurations in the agent selection dropdown as disabled, add an icon and explanation tooltip:
Option 2
Show invalid configurations in the agent selection dropdown and do the validation when user selects one:
Definition of done
-
Invalid configurations are shown in the dropdown -
The validation is shown on the frontend
Steps to reproduce
- Refer to documentation: https://docs.gitlab.com/ee/user/clusters/agent/install/index.html#define-a-configuration-repository.
- Ensure the
<agent_name>
subdirectory contains either an underscore_
or period.
character. - Click on Infrastructure > Kubernetes Clusters.
- Click on GitLab Agent managed clusters.
- Click the dropdown list. * Bug appears here
- Change the
<agent_name>
subdirectory to not include an underscore_
or period.
character. - Click on Infrastructure > Kubernetes Clusters.
- Click on GitLab Agent managed clusters.
- Click the dropdown list.
Example Project
What is the current bug behavior?
Step 5: Nothing appears in the dropdown list, although it appears to show an empty item.
Step 9: Gitlab agent appears in the dropdown list.
What is the expected correct behavior?
Step 5: Gitlab agent appears in the dropdown list.
Step 9: Gitlab agent appears in the dropdown list.
Relevant logs and/or screenshots
Screenshot 1: Shows empty dropdown list item. Also, response from graphql query shows nodes is empty.
Screenshot 2: Shows the agent appearing correctly in the dropdown list. Also, response from qraphql query shows node is returned.
Output of checks
@anton was reproducing the issue on his personal instance via the UI. He also reproduced the behaviour in the rails console.
Commands below taken from source: https://gitlab.com/gitlab-org/gitlab/-/blob/v14.4.2-ee/lib/gitlab/kas/client.rb#L30-40
project = Project.last
client = Gitlab::Kas::Client.new
client.list_agent_config_files(project: project)
If the <agent_name>
subdirectory contains only alphanumeric (including hyphens), the last command will return the agent.
If the <agent_name>
subdirectory contains characters such as underscore or period, the last command returns nothing.
Results of GitLab environment info
Reproducible in latest Gitlab version (14.4.2).
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)