1. 17 Oct, 2017 1 commit
    • Bob Van Landuyt's avatar
      Fix errors when deleting a forked project · 192615692153
      Bob Van Landuyt authored
      The problem would occur when the `ForkedProjectLink` was deleted, but
      the `ForkNetworkMember` was not. The delete would be rolled back and
      But the error would not be saved because `Project#forked?`
      would still be true, because the `ForkNetworkMember` exists. But the
      `Project#forked_project_link` would be `nil`. So the validation for
      the visibility level would fail.
  2. 07 Oct, 2017 1 commit
  3. 14 Aug, 2017 1 commit
  4. 27 Jul, 2017 2 commits
  5. 26 Jul, 2017 1 commit
  6. 20 Jul, 2017 1 commit
    • Timothy Andrew's avatar
      Handle errors while a project is being deleted asynchronously. · f136c01d1d1e
      Timothy Andrew authored
      1. Rescue all errors that `Projects::DestroyService` might throw, to prevent the
         worker from leaving things in an inconsistent state
      2. Unmark the project as `pending_delete`
      3. Add a `delete_error` text column to `projects`, and save the error message in
         there, to be shown to the project masters/owners.
  7. 11 Jul, 2017 1 commit
  8. 24 Jun, 2017 1 commit
  9. 17 May, 2017 1 commit
    • Yorick Peterse's avatar
      Use CTEs for nested groups and authorizations · f63dad32f25f
      Yorick Peterse authored
      This commit introduces the usage of Common Table Expressions (CTEs) to
      efficiently retrieve nested group hierarchies, without having to rely on
      the "routes" table (which is an _incredibly_ inefficient way of getting
      the data). This requires a patch to ActiveRecord (found in the added
      initializer) to work properly as ActiveRecord doesn't support WITH
      statements properly out of the box.
      Unfortunately MySQL provides no efficient way of getting nested groups.
      For example, the old routes setup could easily take 5-10 seconds
      depending on the amount of "routes" in a database. Providing vastly
      different logic for both MySQL and PostgreSQL will negatively impact the
      development process. Because of this the various nested groups related
      methods return empty relations when used in combination with MySQL.
      For project authorizations the logic is split up into two classes:
      * Gitlab::ProjectAuthorizations::WithNestedGroups
      * Gitlab::ProjectAuthorizations::WithoutNestedGroups
      Both classes get the fresh project authorizations (= as they should be
      in the "project_authorizations" table), including nested groups if
      PostgreSQL is used. The logic of these two classes is quite different
      apart from their public interface. This complicates development a bit,
      but unfortunately there is no way around this.
      This commit also introduces Gitlab::GroupHierarchy. This class can be
      used to get the ancestors and descendants of a base relation, or both by
      using a UNION. This in turn is used by methods such as:
      * Namespace#ancestors
      * Namespace#descendants
      * User#all_expanded_groups
      Again this class relies on CTEs and thus only works on PostgreSQL. The
      Namespace methods will return an empty relation when MySQL is used,
      while User#all_expanded_groups will return only the groups a user is a
      direct member of.
      Performance wise the impact is quite large. For example, on GitLab.com
      Namespace#descendants used to take around 580 ms to retrieve data for a
      particular user. Using CTEs we are able to reduce this down to roughly 1
      millisecond, returning the exact same data.
      == On The Fly Refreshing
      Refreshing of authorizations on the fly (= when
      users.authorized_projects_populated was not set) is removed with this
      commit. This simplifies the code, and ensures any queries used for
      authorizations are not mutated because they are executed in a Rails
      scope (e.g. Project.visible_to_user).
      This commit includes a migration to schedule refreshing authorizations
      for all users, ensuring all of them have their authorizations in place.
      Said migration schedules users in batches of 5000, with 5 minutes
      between every batch to smear the load around a bit.
      == Spec Changes
      This commit also introduces some changes to various specs. For example,
      some specs for ProjectTeam assumed that creating a personal project
      would _not_ lead to the owner having access, which is incorrect. Because
      we also no longer refresh authorizations on the fly for new users some
      code had to be added to the "empty_project" factory. This chunk of code
      ensures that the owner's permissions are refreshed after creating the
      project, something that is normally done in Projects::CreateService.
  10. 04 Apr, 2017 1 commit
  11. 03 Apr, 2017 1 commit
  12. 31 Mar, 2017 1 commit
  13. 28 Mar, 2017 1 commit
  14. 24 Mar, 2017 1 commit
  15. 23 Mar, 2017 2 commits
  16. 22 Feb, 2017 1 commit
  17. 19 Feb, 2017 1 commit
    • Stan Hu's avatar
      Prevent project team from being truncated too early during project destruction · ef8defda6ff9
      Stan Hu authored
      There are two issues with truncating the project team early:
      1. `Projects::UnlinkForkService` may not close merge requests properly since
         permissions may be revoked early.
      2. If an error is encountered during flushing of caches, then the user will
         lose all privileges, possibly causing an issue on deletion on retry.
  18. 03 Feb, 2017 2 commits
  19. 01 Dec, 2016 1 commit
    • Lin Jen-Shin's avatar
      Make deleting with optimistic locking respect NULL · 1009ba32b08d
      Lin Jen-Shin authored
      For now deleting with optimistic locking is broken when
      lock_version is still NULL, because Rails would try to
      delete with `lock_version = 0` while in the database
      the column is still `NULL`.
      The monkey patches would force Rails just pass whatever
      in the column, and stop Rails from casting `NULL` into `0`
      when the value is read from database.
      Closes #24766
  20. 05 Oct, 2016 1 commit
    • Stan Hu's avatar
      Fix project deletion when feature visibility is set to private · 0a4f2b010c68
      Stan Hu authored
      Projects that are destroyed are put in the pending_delete state.
      The ProjectDestroyWorker checks whether the current user has
      access, but since the ProjectFeature class uses the default scope
      of the Project, it will not be able to find the right project.
      This was a regression in 8.12 that caused the following stack trace:
      NoMethodError: undefined method `team' for nil:NilClass
        from app/models/project_feature.rb:62:in `get_permission'
        from app/models/project_feature.rb:34:in `feature_available?'
        from app/models/project.rb:21:in `feature_available?'
        from app/policies/project_policy.rb:170:in `disabled_features!'
        from app/policies/project_policy.rb:29:in `rules'
        from app/policies/base_policy.rb:82:in `block in abilities'
        from app/policies/base_policy.rb:113:in `collect_rules'
        from app/policies/base_policy.rb:82:in `abilities'
        from app/policies/base_policy.rb:50:in `abilities'
        from app/models/ability.rb:64:in `uncached_allowed'
        from app/models/ability.rb:58:in `allowed'
        from app/models/ability.rb:49:in `allowed?'
        from app/services/base_service.rb:11:in `can?'
        from lib/gitlab/metrics/instrumentation.rb:155:in `block in can?'
        from lib/gitlab/metrics/method_call.rb:23:in `measure'
        from lib/gitlab/metrics/instrumentation.rb:155:in `can?'
        from app/services/projects/destroy_service.rb:18:in `execute'
      Closes #22948
  21. 03 Jun, 2016 2 commits
  22. 16 May, 2016 2 commits
  23. 08 May, 2016 1 commit
    • Connor Shea's avatar
      Enable the Rubocop DeprecatedClassMethods cop · 90737768f2b7
      Connor Shea authored
      This reports uses of `File.exists?` and `Dir.exists?`, which were both
      deprecated in Ruby and will eventually be removed in favor of
      `.exist?`. Also fixes all existing uses of the deprecated methods.
  24. 09 Dec, 2015 1 commit
  25. 13 Jun, 2015 2 commits
  26. 03 Jun, 2015 1 commit