EE MR for https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18108
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/42090.