Error loading more than 20 environments

Description of issue:
When a project has more than 20 environments (available + stopped), clicking on the Pod to display logs displays an error. This error is only displayed for environments that are created after those 20 environments. Any environment that was created before the 20, display logs. If you go to the Logs page the dropdown only shows the first 20 environments and not any new ones (this is presumably why the error displays when trying to access the other environments).

This screenshot shows that there are 20 available environments and 1 Stopped environment

This shows the error that I get when trying to view branch21 logs (since there are more than 20 environments, this environment does not show in the dropdown from the logs page)

This shows any environment before that 21st environment still displays logs properly

This shows that if I delete the stopped environment to bring the total environments back to 20 it will properly display logs for branch21 environment

Can now view logs

Expected result:
I would expect to be able to have more than 20 environments and to view their logs without any errors.

Version Info:
GitLab: 14.3.3-ee
GitLab Shell: 13.21.1
GitLab Workhorse: v14.3.3
GitLab API: v4
Ruby: 2.7.4p191
PostgreSQL: 12.7
Redis: 6.0.14

Troubleshooting steps taken:

  • I created a new project, connected a kubernetes cluster to it with environment scopes
  • In the gitlab-ci.yml, I deploy a node server to the kubernetes cluster using the environment scope on every branch that’s created
  • I added a branch and then checked the logs page to see when it breaks (found that it breaks when there’s > 20 environments including available and stopped)
  • Then I dug into the source a bit:
    • When I go to the environments page it makes an http request to https://[gitlab-server].com/[project_name]/-/environments/folders/qa.json which properly returns branch21 in the results
    • However, when I go to the logs page it makes an http request to https://[gitlab-server].com/api/v4/projects/212/environments which does not return branch21 in the results

Additional comments:
I assume there’s some internal limit for the v4 api endpoint, this needs to be updated to allow all environments and not just return the first 20.