continued from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/32934
closes https://gitlab.com/gitlab-org/gitlab-ee/issues/31359