lithnet / googleapps-managementagent

Google Workspace Management Agent for MIM 2016
MIT License
12 stars 4 forks source link

Error exporting students to classroom/course #58

Closed magnus1111111 closed 3 years ago

magnus1111111 commented 4 years ago

Getting the following error when exporting multiple students to a classroom "Number of tokens required is greated than the capacity of the bucket Parameter name: tokensRequired"

It works when exporting 3 students but when I try with 9 students I get the error. Don't know the exact number of students when the error occurs.

The details of the error are at Lithnet.GoogleApps.TokenBucket.TryConsume(Int64 tokensRequired) at Lithnet.GoogleApps.TokenBucket.Consume(Int64 numTokens) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff(BatchRequest request, String serviceName, Int32 retryAttempts, Int32 consumeTokens) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff(BatchRequest request, String serviceName, Int32 retryAttempts) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff(BatchRequest request, String serviceName) at Lithnet.GoogleApps.CourseStudentRequestFactory.ProcessBatches[T](String id, Boolean ignoreExistingStudent, Boolean ignoreMissingStudent, IList1 requests, PoolItem1 poolService, Func2 onResponse) at Lithnet.GoogleApps.CourseStudentRequestFactory.AddStudents(String courseId, IList1 students, Boolean throwOnExistingStudent) at Lithnet.GoogleApps.MA.ApiInterfaceCourseStudents.ApplyChanges(CSEntryChange csentry, SchemaType type, Object& target, Boolean patch) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ApiInterfaces\ApiInterfaceCourseStudents.cs:line 78 at Lithnet.GoogleApps.MA.ApiInterfaceCourse.ApplyChanges(CSEntryChange csentry, SchemaType type, Object& target, Boolean patch) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ApiInterfaces\ApiInterfaceCourse.cs:line 169 at Lithnet.GoogleApps.MA.ExportProcessor.PutCSEntryChangeUpdate(CSEntryChange csentry, CSEntryChange deltaCSEntry, MASchemaType maType, SchemaType type, IManagementAgentParameters config) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ExportProcessor.cs:line 143 at Lithnet.GoogleApps.MA.ExportProcessor.PutCSEntryChangeObject(CSEntryChange csentry, SchemaType type, IManagementAgentParameters config) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ExportProcessor.cs:line 64 at Lithnet.GoogleApps.MA.ExportProcessor.PutCSEntryChange(CSEntryChange csentry, SchemaType type, IManagementAgentParameters config) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ExportProcessor.cs:line 16 at Lithnet.GoogleApps.MA.ManagementAgent.<>c__DisplayClass32_0.b__0(CSEntryChange csentry) in D:\github\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ManagementAgent.cs:line 134

ryannewington commented 4 years ago

@leoerlandsson Looks like the batch size is set to 100 for the class room service, but the rate limiter config for the classroom service only allows 5 requests per second. So any batch requests greater than 5 are failing.

https://developers.google.com/classroom/limits

It looks like we might be able to push 25/sec according to the above limits, but this would still fall sort of the batch size. Thoughts?

leoerlandsson commented 4 years ago

Hi @ryannewington @magnus1111111,

There's definitely a problem here.

I'll have a look at it and get back to you asap. I think it should be a fairly simple fix to just adjust the limits and batch sizes.

Br Leo

leoerlandsson commented 4 years ago

This seems related to https://github.com/lithnet/googleapps-client/issues/2

But that one should be fixed. Investigating further.

Also: https://github.com/leoerlandsson/googleapps-managementagent/commit/153be5ef9ce03d11517d4c573b4a9347c42b7033 but it seems I haven't created a Pull request for that one.

magnus1111111 commented 4 years ago

Any news on this issue?

Br Magnus

leoerlandsson commented 4 years ago

@magnus1111111 I think there's a solution in the above mentioned commits, but I need to test it and then we need to do a new Release. Will keep you updated.

ryannewington commented 3 years ago

@leoerlandsson to get @magnus1111111 up and running, should I try a build that just drops the page size down to <5 as a workaround? Until we have more time to look into this further?

Sorry to have to rely on you for this, but I dont have a classroom enabled tenant to accurately test this stuff out

leoerlandsson commented 3 years ago

@ryannewington No worries. Sorry I haven't responded, it's been really busy here.

I have two older commits in my forks that should fix this. I'll try to create Pull requests for them.

There are some other stuff in the commits, but we'll exclude those as they haven't been tested properly.

leoerlandsson commented 3 years ago

I've created two pull requests, please see above @ryannewington @magnus1111111

I'm in Training today and Wednesday, but please don't hestitate to comment should there be any questions. I'll try responding asap.

ryannewington commented 3 years ago

Lithnet.GoogleApps.MA.Setup.zip @magnus1111111 give this build a go and let us know how you go

magnus1111111 commented 3 years ago

I'll give it a go and let you know

magnus1111111 commented 3 years ago

I've done a quick test with one classroom that should have 18 students and MIM exported all students in one export without errors. So it seems to work. Thanks.

leoerlandsson commented 3 years ago

I guess this needs to be incorporated in master and released officially aswell.

ryannewington commented 3 years ago

Thanks for the reminder! published!

leoerlandsson commented 3 years ago

Thanks Ryan