GraphQL: Support membership params for project filter in RunnersFinder

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussion from !103994 (merged) should be addressed:

  • @shinya.maeda started a discussion: (+3 comments)

    Question: If we filter runners by project-id, I expect it's a project-level runners that belong to a specific project. Why do we include all available runners in the project, including instance-level runners and group-level runners?

    Related to the point, would this method should take @params[:membership] into account, so that it'll be consistent with group_runners? It seems owned_or_instance_wide is corresponding to all_available. If you fetch project-level runners belong to a specific project, it would be direct. Etc

Implementation plan

  1. We need to implement a CiRunnerProjectMembershipFilter type similar to CiRunnerMembershipFilter consisting of the following values:

    enum value query example
    PARENT_GROUPS ::Ci::Runner.belonging_to_parent_group_of_project(@project.id) https://gitlab.com/gitlab-org/gitlab/blob/b408bc81cb8862071b99ac6dd1327939bb52d276/app/controllers/projects/settings/ci_cd_controller.rb#L132-134
    OWNED_OR_INSTANCE_WIDE ::Ci::Runner.owned_or_instance_wide(@project.id) https://gitlab.com/gitlab-org/gitlab/blob/b408bc81cb8862071b99ac6dd1327939bb52d276/app/finders/ci/runners_finder.rb#L79-79
    DIRECT @project.runners https://gitlab.com/gitlab-org/gitlab/blob/9d2d05be54a378581883c00337894288d1ef2efd/app/controllers/projects/settings/ci_cd_controller.rb#L120-120

    Normally, the DIRECT value should be the default. However, the OWNED_OR_INSTANCE_WIDE behavior is the current one.

  2. We need to create a Resolvers::Ci::ProjectRunnersResolver (similar to Resolvers::Ci::GroupRunnersResolver) to support a :membership field and a project parent object.

Edited by 🤖 GitLab Bot 🤖