Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync users from Microsoft Entra ID skiptoken and deltatoken API call error #2535

Closed
RayCoSector opened this issue Mar 21, 2024 · 11 comments · Fixed by #2565, #2566 or #2567
Closed

Sync users from Microsoft Entra ID skiptoken and deltatoken API call error #2535

RayCoSector opened this issue Mar 21, 2024 · 11 comments · Fixed by #2565, #2566 or #2567
Assignees
Labels
Feature - user sync Issue type - bug Bugs in existing code that needs to be fixed. Plugin - local_o365 Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Milestone

Comments

@RayCoSector
Copy link

RayCoSector commented Mar 21, 2024

Hi all,

Has anyone come across this before (see below), I'm thinking that it might be caused due to multiple accounts using the same email address in the Active Directory.

What happens is that the next sync then is a forced to do a full sync, after the full sync completes in 5 or so hours the next sync is then like the below, completing in around 1 second and the next sync is a full sync and around it goes. All seems to work okay.. it is just a little unnerving as to why it is happening ??

Moodle 4.1.9
O365 plugins 4.1.5

Execute scheduled task: Sync users from Microsoft Entra ID (local_o365\task\usersync)
... started 10:01:01. Current memory use 21.5 MB.
...... Starting sync
...... Using deltatoken.
...... Using delta sync.
...... Contacting Microsoft Entra ID...
...... Error in delta usersync: Error in API call: Invalid request: Both skiptoken and deltatoken can't be in the same request.
...... Resetting delta tokens.
...... Got response from Microsoft Entra ID
...... Clearing deltatoken (none received)
...... No users received to sync.
...... Suspend/delete users feature skipped because it was run less than 1 day ago.
...... Sync process finished.
... used 3 dbqueries
... used 0.84352517127991 seconds
Scheduled task complete: Sync users from Microsoft Entra ID (local_o365\task\usersync)

Regards,
Ray.

@RayCoSector
Copy link
Author

RayCoSector commented Mar 22, 2024

I removed all the duplicate users and the issue is still in place.

Is one of the App Registration API's required to call Azure in this part as we built this site from scratch, not using the powershell script only allowing the API calls for SSO not all of them for OneDrive & Teams etc.

Debug mode on did not show me anymore information...

@weilai-irl weilai-irl self-assigned this Apr 8, 2024
@RayCoSector
Copy link
Author

RayCoSector commented Apr 17, 2024

Just to add, I've now seen the same on another site - using 4.1.5 plugins on Moodle 4.1.9

Each alternate run it runs a full sync
image

Recorded in the log from the delta run is, same as above
...... Error in delta usersync: Error in API call: Invalid request: Both skiptoken and deltatoken can't be in the same request.
...... Resetting delta tokens.

Regards,
Ray.

@smangancap
Copy link

smangancap commented Apr 25, 2024

I can confirm this same issue persists in moodle version 4.1.9 and local_o365 4.1.6

The error just started to occur after our upgrade from moodle version 4.1.7 to 4.1.9.

@RayCoSector
Copy link
Author

Any news or idea on what this might be @weilai-irl .. upgrading to local_o365 4.1.6 & auth_oidc 4.1.6 is still showing the same issues.

@RayCoSector
Copy link
Author

Morning @weilai-irl sorry to be a pain, looking for a solution for this. I've had some success on some sites by using Cleanup User Sync Delta Tokens in Maintenance Tools section. But this does not fix it for all sites.

I've now seen this on a Moodle 4.4 site using plugins local_o365 / auth_oidc version 4.3.3

Many thanks for any help or pointers to solve the issue.

Regards,
Ray.

@bbusschots-mu
Copy link

We're having this problem too, this is what our Moodle Partner has found when investigating our issues:

Upon reviewing the logs, I've identified a recurring error message indicating an issue with the API call during delta user synchronization. The error states: "Error in API call: Invalid request: Both skiptoken and deltatoken can't be in the same request."

This error seems to disrupt the synchronization process, leading to the inability to retrieve the delta token for subsequent runs. After which the sync task ends up processing all users, resulting in a significant increase in server memory usage and, eventually, halting the cron job without providing an explicit error message.

For now we are limping along, with user update happening slowly, and we're often relying on users to log in to get their accounts to update.

We are running:

  • Moodle 4.1.10 (Build: 20240422)
  • local_o365 4.1.6 (2022112830)
  • auth_oidc 4.1.6 (2022112830)

@weilai-irl
Copy link
Collaborator

Hi all,

Please find the fix to the issue in the linked PR. Please test the solution and provide feedback, as there are not enough users in our test tenant to perform the test.

If passed, the solution will be included in the next release.

Regards,
Lai

@bbusschots-mu
Copy link

Thanks @weilai-irl — I've put in the request to have the PR for the 4_0_1 branch applied to our test Moodle instance. I'll report back when I have news.

@RayCoSector
Copy link
Author

RayCoSector commented Jun 3, 2024

Morning @weilai-irl

I can confirm that adding the changes mentioned here to local/o365/classes/rest/unified.php fixes the issue.

Each Entra sync run now correctly returns a Delta sync as expected

Execute scheduled task: Sync users from Microsoft Entra ID (local_o365\task\usersync)
... started 11:37:14. Current memory use 19.2 MB.
...... Starting sync
...... Using deltatoken.
...... Using delta sync.
...... Contacting Microsoft Entra ID...
...... Got response from Microsoft Entra ID
...... Storing deltatoken
...... 3 users received. Syncing...
Details removed
...... Sync process finished.
... used 14 dbqueries
... used 11.851914167404 seconds
Scheduled task complete: Sync users from Microsoft Entra ID (local_o365\task\usersync)

image

Many thanks,
Ray.

@weilai-irl
Copy link
Collaborator

Hi @RayCoSector

Thank you for your confirmation. This will certainly be included in the next release then.

Regards,
Lai

@weilai-irl
Copy link
Collaborator

Hi all,

The fix to this issue has been included in release 4.1.7, 4.2.6 and 4.3.4 on 2nd of July 2024. I'm going to mark this issue as closed.

Regards,
Lai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment