Add the Workday integration settings for top-level groups
What does this MR do and why?
Adds the settings for a new Workday integration, for https://gitlab.com/gitlab-org/gitlab/-/work_items/629838. Administrators use it to enter the Workday connection details that the workforce hierarchy import will read. This MR adds the settings only. The source adapter, the Workday client and the connection test follow in a later merge request.
The integration describes one tenant, so it differs from other integrations in two ways:
- It exists only on a top-level group. It is hidden from subgroups, projects, and the instance and organization levels.
- It is never copied to subgroups or projects.
It uses the framework changes from !271255 (merged), which has merged: group-level-only integrations, available_for_group?, propagatable?, and audit events for integrations.
The Workday integration
- Fields: people report URL, workforce units report URL, token URL, client ID, client secret, refresh token. All are stored in the encrypted integration properties. The client secret and refresh token are
passwordfields, so the form and the API never return them. - URLs: must be public HTTPS URLs. They are marked
exposes_secrets, so changing one clears the saved secrets. - Availability:
Integrations::Workday.available_for_group?requires a top-level group, theworkday_integrationfeature flag for that group, and the Ultimateworkforce_hierarchieslicensed feature. The name is registered only when theworkday_group_integrationSaaS feature is available, because on GitLab Self-Managed and Dedicated the tenant is the organization (https://gitlab.com/gitlab-org/gitlab/-/work_items/638894). - Model validation: the group must be present and top-level, as a second barrier behind the availability check.
- Audit events: recorded by the framework's
integration_created,integration_updatedandintegration_deletedevents, which cover integrations saved from the settings page or the REST API. This MR adds no audit code of its own for those paths. - Reset: deletes the group's workforce hierarchy with
Integrations::Workday#delete_workforce_hierarchybefore the integration row is destroyed. Without this, the foreign key would delete the whole hierarchy in one cascade. The hierarchy is deleted only when the integration was saved and the reset is allowed. - Group transfer: transferring a top-level group under another group deletes its Workday integration and workforce hierarchy, and records an
integration_deletedaudit event. The hierarchy is deleted in batches before the transfer's transaction, so its row locks are not held until the transfer commits and a lock retry does not repeat the deletes. The integration row is deleted inside the transaction. A failed transfer therefore keeps the integration and its secrets but not the hierarchy, which a sync restores. Otherwise the row and its secrets would stay on what is now a subgroup, where the integration is hidden and can no longer be opened, reset or deleted. Raised in !271255 (comment 4270863759). - REST API: registered with the group integrations API, with the same availability checks.
Decisions for reviewers
- Clearing secrets on a URL change is kept. Otherwise someone who can edit the settings could point the token URL at a server they control and receive the saved secrets. The cost is entering the secrets again after fixing a URL.
- Registered in the REST API, not UI-only. A guard spec requires every non-instance integration to be registered, so the alternative is a spec exception.
- No usage metrics. The integration guide asks for five metrics per integration. The project, instance and inheriting ones can never be non-zero here. I can add
groups_workday_activeif reviewers want it. workforce_hierarchies.integration_idbecomes NOT NULL in a separate merge request, together with the factory and development seed changes it needs.- Milestone 19.7. The definition files use 19.7 because this will merge after the 19.6 cut.
- A group transfer deletes the Workday data instead of being blocked. An earlier version blocked the transfer until the integration was reset. That is a dead end when the integration is hidden (feature flag off or license lapsed), because reset returns
404then. A group on a paid plan cannot be transferred anyway, so the block would mostly have hit that case. Letting reset and the APIDELETEwork on a hidden integration was also considered: the reset button is on a page that returns404when hidden, and the APIDELETEonly blanks the fields, so the row and the hierarchy would still be left on the subgroup.
Known gaps
- The form does not link to a help page. User documentation is covered in https://gitlab.com/gitlab-org/gitlab/-/work_items/638006.
- The integration shows the default icon. A Workday logo is tracked in https://gitlab.com/gitlab-org/gitlab-services/design.gitlab.com/-/work_items/3767.
Database
There is no migration. db/docs/integrations.yml only adds Integrations::Workday to the classes of the integrations table. The MR runs three kinds of queries:
1. Group transfer lookup (Integrations::Workday.find_for_group), once per transfer of a group under another group. It is not behind the feature flag, so a hidden row is found too:
SELECT "integrations".* FROM "integrations"
WHERE "integrations"."type_new" = 'Integrations::Workday' AND "integrations"."group_id" = 22
LIMIT 1Plan from a local database
Limit (cost=0.15..2.17 rows=1 width=271)
-> Index Scan using index_integrations_on_unique_group_id_and_type_new on integrations (cost=0.15..2.17 rows=1 width=271)
Index Cond: ((group_id = 22) AND (type_new = 'Integrations::Workday'::text))2. Deleting the workforce hierarchy (Workforce::Hierarchy.delete_for_tenant). The method is already on master. This MR calls it through Integrations::Workday#delete_workforce_hierarchy from the reset action, and from the group transfer when a Workday integration is found. Both calls run outside a transaction. It deletes the people in batches of 1,000 until none are left, then the hierarchy row:
DELETE FROM "workforce_people" WHERE ("workforce_people"."id") IN (
SELECT "workforce_people"."id" FROM "workforce_people"
WHERE "workforce_people"."workforce_hierarchy_id" = 6 LIMIT 1000
)
DELETE FROM "workforce_hierarchies" WHERE "workforce_hierarchies"."id" = 6Production has no workforce data yet, so there is no production plan. Locally, deleting a seeded hierarchy of 50,000 people took 0.24 seconds. Moving data removal to a background job is covered in https://gitlab.com/gitlab-org/gitlab/-/work_items/629842.
3. Deleting the integration row (destroy! in the group transfer's transaction). One row by primary key, after its workforce hierarchy is gone. The reset action already runs the same statement for every integration:
DELETE FROM "integrations" WHERE "integrations"."id" = 10Generated files
locale/gitlab.pot, doc/api/openapi/openapi_v3.yaml, config/routing/gitlab_routes.json, doc/auth/tokens/fine_grained_access_tokens_rest.md, doc/api/graphql/reference/enums.md and public/-/graphql/introspection_result.json are regenerated. The GraphQL files change only because the new licensed feature adds a WORKFORCE_HIERARCHIES enum value.
The new API routes needed a paired HTTP Router change for the cells-routes:router-in-sync job, which has merged: gitlab-org/cells/http-router!1542 (merged)
References
- Issue: https://gitlab.com/gitlab-org/gitlab/-/work_items/629838
- Framework changes: !271255 (merged)
- HTTP Router routes: gitlab-org/cells/http-router!1542 (merged)
- Phase 1 epic: https://gitlab.com/groups/gitlab-org/-/work_items/23625
- Workforce unit store: !270006 (merged)
Screenshots or screen recordings
How to set up and validate locally
-
Run GDK in SaaS mode (
GITLAB_SIMULATE_SAAS=1) with an Ultimate license. -
In the Rails console, enable the feature flag for a top-level group:
group = Group.find_by_full_path('toolbox') Feature.enable(:workday_integration, group) -
As an Owner, go to the group's Settings > Integrations. Workday is listed.
-
Open it, select Active, and save with empty fields. The six fields are required. An
http://or local URL is rejected. -
Fill in the fields and save. Reopen the form: the two secret fields are empty.
-
Change only the token URL and save. The save is rejected until the secrets are entered again.
-
Check the stored row in the Rails console:
Integrations::Workday.pluck(:id, :group_id, :project_id) # one row, no copies Integrations::Workday.last.encrypted_properties # encrypted -
Create a subgroup and a project. Neither lists Workday, and
/-/settings/integrations/workday/editreturns 404 on the subgroup. -
Go to the group's Secure > Audit events. The "Workday integration was created" and "Workday integration was updated" events are listed. Select Reset on the form to see the deleted event.
-
Disable the feature flag. Workday is no longer listed and its edit page returns 404.
-
To check the transfer, use a top-level group without a paid plan that has a saved Workday integration, and transfer it under another group (Settings > General > Advanced > Transfer group). Afterwards
Integrations::Workday.find_for_group(group)isnil, and the group's audit events list "Workday integration was deleted".
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

