Cluster kubernetes API throws 500 error if user tries to submit another cluster
Summary
Cluster kubernetes API throws 500 if a user tries to submit multiple clusters on CE
Steps to reproduce
- Add a cluster through an API or through UI
- Add another cluster through API
❯ curl --header 'Private-Token: '$MAINTANER_PAT'' http://localhost:3000/api/v4/projects/131/clusters/user \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-X POST --data '{"name":"cluster-1", "platform_kubernetes_attributes":{"api_url":"https://35.111.51.20","token":"12345","namespace":"cluster-1-namespace"}}'
{"message":"500 Internal Server Error"}
This only happens on CE, as we only allow on cluster per project. On EE its not present.
What is the current bug behavior?
API throws 500 internal error server
What is the expected correct behavior?
API should return an appropriate error message
Relevant logs and/or screenshots
Output of checks
This happens on gitlab.com
Possible fixes
Add a policy check on "POST" endpoint to check if the user can add another cluster.