Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested subgroups no longer appear to work #221

Closed
masonbivens opened this issue May 25, 2021 · 5 comments
Closed

Nested subgroups no longer appear to work #221

masonbivens opened this issue May 25, 2021 · 5 comments
Labels

Comments

@masonbivens
Copy link

masonbivens commented May 25, 2021

Describe the bug
When using a hierarchical group structure it appears that targeting sub-groups no longer works.

Output:

[💣  ] ❯ gitlabform -c config.yml 'foobar/technology/infra/ter'  
🏗 GitLabForm version: 2.0.0.post1 = the latest stable😊
:: # of groups to process: 1
:: # of projects to process: 0
@ (1/1) Processing group: ter
Warning: Error occurred while processing group ter, exception:

Resource path='https://gitlab.com/api/v4/groups/ter' not found!

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlabform/core.py", line 470, in process_all
    self.group_processors.process_group(
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlabform/processors/group/__init__.py", line 32, in process_group
    processor.process(group, configuration, dry_run, output_file)
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlabform/processors/util/decorators.py", line 42, in method_wrapper
    return method(self, project_and_group, SafeDict(configuration), *args)
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlabform/processors/abstract_processor.py", line 47, in process
    self._process_configuration(project_or_project_and_group, configuration)
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlabform/processors/group/group_settings_processor.py", line 22, in _process_configuration
    self.gitlab.put_group_settings(group, group_settings)
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlab/groups.py", line 103, in put_group_settings
    self._make_requests_to_api(
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlab/core.py", line 110, in _make_requests_to_api
    response = self._make_request_to_api(
  File "/usr/local/lib/python3.9/site-packages/gitlabform/gitlab/core.py", line 193, in _make_request_to_api
    raise NotFoundException("Resource path='%s' not found!" % url)
gitlabform.gitlab.core.NotFoundException: Resource path='https://gitlab.com/api/v4/groups/ter' not found!

:: # of groups processed successfully: 0
:: # of projects processed successfully: 0
:: # of groups failed: 1 
:: Failed group 1: ter 

Config:

config_version: 2
gitlab:
  url: https://gitlab.com
projects_and_groups:
  '*':
    project_settings:
      builds_access_level: private
      public_jobs: false
      visibility: private
      default_branch: master
      issues_access_level: private
      snippets_access_level: disabled
      wiki_access_level: private
      shared_runners_enabled: false
      auto_cancel_pending_pipelines: enabled
      only_allow_merge_if_pipeline_succeeds: false
      only_allow_merge_if_all_discussions_are_resolved: false
      remove_source_branch_after_merge: true
      resolve_outdated_diff_discussions: true

    merge_requests:
      approvals:
        approvals_before_merge: 2
        reset_approvals_on_push: true
        disable_overriding_approvers_per_merge_request: true
  
  'foobar/technology/infra/*':
    members:
      groups:
        foobar/user-groups/cloudops:
          group_access: 40

    merge_requests:
      approver_groups:
        - foobar/user-groups/cloudops

    files:
      'CODEOWNERS':
        overwrite: false
        branches:
          - master
        skip_ci: true
        content: |
          * @foobar/user-groups/cloudops

  'foobar/technology/infra/ter/*':
    branches:
      master:
        protected: true
        developers_can_push: false
        developers_can_merge: true
      0.12:
        protected: true
        developers_can_push: false
        developers_can_merge: true
      0.13:
        protected: true
        developers_can_push: false
        developers_can_merge: true
      0.14:
        protected: true
        developers_can_push: false
        developers_can_merge: true

    project_push_rules:
      branch_name_regex: '^(0.12|0.13|0.14|[A-Z][A-Z_0-9]+-\d+)'
@seboudry
Copy link

Hi!

projects_and_groups:
  "my-group/sub-group/*":
🏗 GitLabForm version: 2.0.0.post1 = the latest stable😊

>>> Processing ALL groups and projects defined in config
:: # of groups to process: 1
:: # of projects to process: 0
@ (1/1) Skipping group sub-group as it has empty effective config. 
:: # of groups processed successfully: 0
:: # of projects processed successfully: 0

It appears that only last part of group path is kept.

@skycaptain
Copy link

Can confirm:

config.yml:

config_version: 2

projects_and_groups:
  "path/to/incredible/myproject/*":
    project_settings:
      wiki_enabled: false
$  gitlabform --skip-version-check --debug ALL_DEFINED
[...]
https://gitlab.example.com:443 "GET /api/v4/groups/path%2Fto%2Fincredible HTTP/1.1" 200 None
response code=200
[...]
https://gitlab.example.com:443 "GET /api/v4/groups/incredible/projects?include_subgroups=true&archived=false&per_page=100 HTTP/1.1" 404 33
response code=404
[...]

@gdubicki
Copy link
Member

gdubicki commented Jun 7, 2021

Thanks for reporting this @masonbivens and @skycaptain !

This should be fixed in v2.0.4 released a moment ago. Please reopen this issue if you are still seeing the issue after GitLabForm upgrade.

@skycaptain
Copy link

@gdubicki unfortunately still exists with 2.0.4. The truncated group path is still used resulting in an 404 error.

$  gitlabform --skip-version-check --debug ALL_DEFINED
🏗 GitLabForm version: 2.0.4 
[...]
https://gitlab.example.com:443 "GET /api/v4/groups/path%2Fto%2Fincredible HTTP/1.1" 200 None
response code=200
[...]
https://gitlab.example.com:443 "GET /api/v4/groups/incredible/projects?include_subgroups=true&archived=false&per_page=100 HTTP/1.1" 404 33
response code=404
[...]

@gdubicki gdubicki reopened this Jun 9, 2021
gdubicki added a commit that referenced this issue Jun 18, 2021
to complete the fix for getting all defined subgroups (#221).

Also prevent finding project or group that have their name matching
but the full path not (f.e. requesting to process "foo/bar" will
now not process "baz/bar", even if GitLab projects search API will
return the latter as a search result).
@gdubicki
Copy link
Member

Thanks again @skycaptain !

I think I got it fixed completely this time (in v2.0.5 I fixed only requesting processing a single subgroup, like gitlabform foo/bar/baz).

Please check out v2.0.6 with the fix and reopen if you still observe any issues related to subgroups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants