Port to EE for https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16302
https://gitlab.com/gitlab-org/gitlab-ce/issues/31885