Better way of attaching users to Group using Rest API

We are currently Using TeamCity Enterprise 7.1.4 (build 24331)

We use Custom logging system that adds users from Single Sign on.

We use Rest API to manage groups.

Attaching of Users to groups is done using REST API.

We have in house role based system that synchronizes with Teamcity Groups


Adding of user is done http://youtrack.jetbrains.com/issue/TW-28991 by this method a sample code


this is sample code



http://teamcity:8111/app/rest/users/username:abcd


put XML


<user id='1234'><groups>'<group key='12' name = 'proj1'/><group key='13' name = 'proj2'/></groups></user>


content_type = 'application/xml'

This process became very lengthy and started taking hours as the users and groups increased. In debugging we found that user was first removed from all the groups and then re-added which are put on xml. The teamcity-activities.log file has the details.

Here is a snippet

[2014-02-25 04:31:26,061]   INFO - tbrains.buildServer.ACTIVITIES - User "abcd" was removed from "proj1" by "xxxx" 
[2014-02-25 04:31:26,115]   INFO - tbrains.buildServer.ACTIVITIES - User "abcd" was removed from "proj2" by "xxxx" 
[2014-02-25 04:31:26,132]   INFO - tbrains.buildServer.ACTIVITIES - User "abcd" was added to "proj1" by "xxxx"
[2014-02-25 04:31:26,196]   INFO - tbrains.buildServer.ACTIVITIES - User "abcd" was added to "proj2" by "xxxx" 
2 comments
Comment actions Permalink

Hello,

You are right. I have created an issue to make REST API logic more effective and perform only necesasry operations.

In TeamCity 8.1 there is a new request supported: POST a single group definition to /app/user/username:abcd/groups URL.

As to:

> This process became very lengthy and started taking hours as the users and groups increased.

How many gropus and users do you have?
Would it be possible to take a set of the server thread dumps over the operation execution and create a separate issue in the tracker with the dumps attached?

0
Comment actions Permalink

> This process became very lengthy and started taking hours as the users and groups increased.

How many gropus and users do you have?

Ans. We have currentlty about 178 Groups and about 1461 registered users. each user atleast belongs to 4 groups and every group has a minimum of 20 users.

We are optimizing the script only if the new user is added we are no longer removing the users from groups.

0

Please sign in to leave a comment.