#2330 Write script to fix missing subroles in production

v1.0.0
closed
sf-2 (994)
General
nobody
2015-08-20
2011-06-16
No

After [#2264] is finished, need a script to repair any damage done in prod.

"""
For projects:
    * Admin role.roles should contain Developer, and Developer only
    * Developer role.roles should contain Member, and Member only

For project.users:
    * user.project_role().roles, if it contains Admin, should not contain
      Developer or Member
    * user.project_role().roles, if it contains Developer, should not contain
      Member
"""

Related

Tickets: #2264

Discussion

  • forge:tv/2330

    To test, log in to allura as an admin and go to /p/test/admin/groups. Delete admin1 from the Developer group. Add test-user to the Developer group and Member group.

    A few things just happened:
    1. Subroles for the test project just got obliterated, due to a bug fixed in [#2264]. This means that the Admin role no longer contains Developer and Member, and the Developer role no longer contains Member, as they should.
    2. admin1 has separate Admin and Member roles, but should actually only have Admin, since Admin should contain Member.
    3. test-user has separate Developer and Member roles, but should actually only have Developer, since Developer should contain Member.

    Run the script in test-only mode and view the log:

    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ paster script production.ini ../scripts/fix-subroles.py test
    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ cat /var/log/allura/allura.log
    

    You should see output describing repairs that need to be made to project and user roles. In this case, it should include something about resetting the Admin and Developer roles for the "test" project, and something about removing the Member role from admin1 and removing the Member role from test-user.

    Run the script without the test flag:

    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ paster script production.ini ../scripts/fix-subroles.py
    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ cat /var/log/allura/allura.log
    

    You should see output describing repairs that were made. Now run the script one more time to make sure everything actually got fixed:

    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ paster script production.ini ../scripts/fix-subroles.py
    (env-allura)root@h6v6059:/var/local/allura/Allura(tv/2330)$ cat /var/log/allura/allura.log
    

    The only output should be something similar to the following:

    13:04:06,230 INFO  [__main__] Examining subroles in all non-user projects.
    13:04:06,474 INFO  [__main__] 6 projects examined.
    
    • status: in-progress --> code-review
    • assigned_to: Tim Van Steenburgh --> Kyle Adams
     

    Related

    Tickets: #2264

  • Kyle Adams - 2011-06-17

    Looks good.

     
  • Kyle Adams - 2011-06-17
    • status: code-review --> closed
     

Log in to post a comment.