Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-7265

Allow sysadmins to view orphaned repositories in Stash

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • 7.13.0
    • None
    • None
    • 98
    • We collect Bitbucket feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      Atlassian status as of May 2021

      Hi everyone! It's been a long wait, but I have good news for you. In Bitbucket Server 7.13 we have released Advanced repository management. This feature helps to get a holistic view on all repositories in Bitbucket. It can help you find all orphaned repositories in just a few clicks. Select Personal (deleted users) option in Repositories type filter.

      Note: We will add Repository size filter soon, so that figuring out which orphaned repositories occupy the most disk space will be easy.

      To learn more about new features of Bitbucket Data Center 7.13 read the release notes.

      Cheers,
      Anton Genkin - Product Manager
      Bitbucket Data Center

      Original message

      Summary

      From this post in Answers we found a use case in which users that are removed from Stash or deactivated in an external User Directory might leave orphan personal repositories behind that are not accessible from the UI.

      We should offer sysadmins a way to view these orphaned personal repositories so they can be managed.

      Steps to Reproduce

      Here is the scenario. I, the administrator, create a user. The user logs in and creates some repositories and only gives himself/herself access to said repositories.
      The user is now fired and the administrator (actually the LDAP synchronization task) removes the user from Stash. How does the administrator find all of the repositories that the user created?
      When I run this test, the repositories just seem to disappear. I have to know the names of the repositories to search for them and then I can add a new owner or delete them.
      I work for a large organization and this scenario could lead to many orphaned repositories, because the administrator is not privy to every employee departure and certainly would not know what repositories were created by the user.

      Scenario 1: Internal Database

      1. Create a user in the Stash Internal Database
      2. Add at least Global permissions to it
      3. Log in as the newly created user
      4. Go to its profile and create a personal repo
      5. As an admin user, delete the user
      6. You will have created an orphan repo

      Scenario 2: External Directory

      1. Create a user in the External Directory you've got (i.e. LDAP, Crowd or JIRA)
      2. Add at least Global permissions to it
      3. Log in as the newly created user
      4. Go to its profile and create a personal repo
      5. As an admin of the User Directory, de-activate the user
      6. You will have created an orphan repo

      Expected Results

      The repo will still be there, but the Stash administrator will have a way to easily find repos on that situation.

      Actual Results

      The repo will still be there, but the Stash administrator will have a way to easily find repos on that situation.

      This ties back to STASH-3564 as there should be a better way to visualize/browse personal repositories

      Workaround

      You will be able to find the orphan users/repos if you run the query below against your database:

      select snu.name, r.slug from sta_personal_project spr, repository r, sta_normal_user snu
      where spr.project_id=r.project_id and spr.owner_id=snu.user_id 
      and snu.name not in 
      (select u.lower_user_name 
      from cwd_user u join cwd_directory d on u.directory_id = d.id 
      where d.is_active='T' and u.is_active='T');
      

      Important: do not change anything on your database. With the information above, as a Stash administrator, you will be able to hit the orphan profile page of that user and remove its repo. You will have to browse straight into their profile page by hitting the following URL:

      http://<Stash_URL>/users/<username_from_query_above>
      

      On this page you will be able to see all the user's orphan repos. From there, you can browse into the repo "Settings" and delete the repo on the top right button of the next screen.

      If you need the deletion to be done in bulk, you can programmatically do it using the DELETE method using curl, for example, calling this REST API in Stash.

              Unassigned Unassigned
              tbomfim ThiagoBomfim (Inactive)
              Votes:
              92 Vote for this issue
              Watchers:
              70 Start watching this issue

                Created:
                Updated:
                Resolved: