Repository navigation
Add cron script to sync PDC users and orgs - #318
bickelj-agent wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical active issue remains because retrying non-idempotent sync-start POSTs after lost responses or transient failures can create duplicate synchronization tasks.
1 open issue
What changed in this PR
Adds a standalone, cron-ready utility that authenticates with Keycloak and synchronizes PDC users and organizations through sequential asynchronous API tasks.
Changes:
- Adds OAuth2 client-credentials authentication using environment-provided credentials.
- Starts and polls user synchronization, followed by organization synchronization.
- Adds token handling, retries, configurable polling and deadlines, logging, URL validation, and distinct exit codes.
| File | Description |
|---|---|
| standalone/pdc-sync-users-and-orgs | Adds an executable cron script for scheduled sequential synchronization of PDC users and organizations. |
Review effort: Lite
9c4b8ae to
b808d0a
Compare
b808d0a to
0a09c56
Compare
0a09c56 to
47559a6
Compare
|
Reviewed the one new script; happy path, exit codes, 401 refresh and deadline behaviour verified against a fake API/Keycloak, and Minor items
— DeepSeek-V4.1-Flash-1017 |
47559a6 to
bdb490f
Compare
|
All four review threads are addressed and resolved (cron env-file sourcing with — GLM-5.3-Flash |
PDC caches Keycloak users, organizations, and memberships, but the cache only refreshes when someone calls the sync endpoints. Add a standalone script for a cron job: it starts the user sync, polls the task to completion, then does the same for organizations, exiting zero only when both syncs complete. GLM-5.3-Flash, an LLM supervised and prompted by @bickelj Issue PhilanthropyDataCommons/service#2600 Regularly call user/org sync endpoints
bdb490f to
b1d0c6c
Compare
chriszs
left a comment
There was a problem hiding this comment.
Not reviewing this unless asked. Assume I was suggested as a codeowner because I've written scripts before.
|
@chriszs Fair enough. If you are willing to give it a glance, that would be nice, but it is admittedly a big ask. |

The Keycloak-to-PDC replica of users, organizations, and memberships only refreshes when someone calls the sync endpoints by hand, so it drifts between runs. Add a standalone cron-ready script that starts the user sync, polls its task to completion, then does the same for the organization sync, exiting zero only when both complete.
Refs PhilanthropyDataCommons/service#2600
GLM-5.3-Flash, an LLM supervised and prompted by @bickelj