Skip to content

Add cron script to sync PDC users and orgs - #318

Open
bickelj-agent wants to merge 1 commit into
mainfrom
2600-sync-users-and-orgs
Open

bickelj-agent wants to merge 1 commit into
mainfrom
2600-sync-users-and-orgs

Conversation

@bickelj-agent

Copy link
Copy Markdown
Collaborator

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread standalone/pdc-sync-users-and-orgs Resolved
@bickelj-agent
bickelj-agent force-pushed the 2600-sync-users-and-orgs branch from 9c4b8ae to b808d0a Compare November 10, 2026 19:44
Comment thread standalone/pdc-sync-users-and-orgs Resolved
Comment thread standalone/pdc-sync-users-and-orgs Resolved
Comment thread standalone/pdc-sync-users-and-orgs Resolved
Comment thread standalone/pdc-sync-users-and-orgs Resolved
Comment thread standalone/pdc-sync-users-and-orgs Resolved
@bickelj-agent
bickelj-agent force-pushed the 2600-sync-users-and-orgs branch from b808d0a to 0a09c56 Compare November 10, 2026 20:04
@bickelj-agent
bickelj-agent marked this pull request as ready for review November 10, 2026 20:07
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants