Entitlement Sequencing, Event Gating and Entitlement-Time Routing
- 1 1. Purpose and scope
- 2 2. Background
- 3 3. Sequences
- 4 4. The "wait" step
- 4.1 4.1 Requirements
- 4.2 4.2 Options
- 4.3 4.3 Implementation
- 5 5. Revoke leaves system data in place (separate workstream)
- 6 6. Module calls made during entitlement
- 7 7. Implementation plan
- 7.1 Workstream A: sequencing, gating and routing (critical path)
- 7.2 Workstream B: Category 2 (optional dependencies)
- 7.3 Workstream C: revoke behavior (deferred, not on the critical path)
- 7.4 Workstream D: FQM adjustments (follow-on work - to be discussed and coordinated with team Athena)
- 7.5 Delivery order
1. Purpose and scope
This page describes ideas for mitigating race conditions during tenant entitlement operations. The solutions described here include adjustments to sequencing operations performed during entitlement and routing of module-to-module calls made during entitlement.
It complements Race Conditions When Processing MTE Events in a Mixed-Version Environment, which covers a Kafka consumer-side filtering problem related to multi-version support, and proposes header-based fixes (Solutions 1-3). This page covers the publisher-side orchestration/sequencing, the gating ("wait") mechanism, and entitlement-time API routing.
2. Background
2.1 Problems/Scope
The document addresses four problems, all of which come up when MTE switches a tenant’s entitlement from one application version to another.
Events published before the system is ready for them:
MTE publishes system-user, scheduled-job and capability events to set up system users, timers and capabilities.
The consuming modules (mod-users-keycloak, mod-scheduler, mod-roles-keycloak) need their tenant APIs to have run first. The tenant-aware Kafka filter also discards events if the tenant isn’t yet entitled to the receiving module version.
If events go out too early, or in parallel with the entitlement switch, they can be lost. In a mixed-version cluster, both the old and new consumer versions can discard the same event. The result is a missing system user, timer or capability, with no error.
2. No way to know a step has finished before starting the next
The sequences depend on “wait until that’s done”, but nothing in MTE provides it.
The wait has to confirm that events were processed, not just consumed, because a discarded event still counts as consumed.
Tenant APIs are a mix of synchronous (Spring) and asynchronous (RMB) calls.
3. Modules calling other modules during entitlement hit the wrong version
Some modules call other modules while handling their own tenant API call.
The sidecar’s entitlement cache updates asynchronously, so a call can still be routed straight to the old provider version, even though MTE has already upgraded the provider and updated Kong.
Two categories:
Provider is in requires (e.g. many modules call mod-settings from their tenant API)
Optional dependency (e.g. like the FQM case, where there are many optional dependencies called from the tenant API)
4. Revoke leaves system users and capabilities behind
System users and capabilities stay in place after revoke. This is a side discovery rather than part of the race conditions.
2.2 Events published by MTE
Event | Consumer | Creates / updates |
|---|---|---|
|
| System users |
|
| System timers |
|
| Capabilities |
| Sidecars, | Sidecar entitlement info, disable timers upon revoke, Kafka filtering. Eventually disable system users upon revoke. See section 5. |
2.3 Why ordering matters
Tenant APIs of FOLIO modules create the tenant schema and other prerequisites. They must run before those modules can consume events or other API calls.
Tenant APIs of some modules may need to call other modules (m2m), which sometimes require system users to already exist.
The tenant-aware Kafka filter discards events if the tenant is not entitled to the receiving module version when the event is consumed (see the race conditions page).
2.4 Routing model
External traffic entering FOLIO always goes through Kong.
Inter-module requests are almost always routed directly between sidecars.
Exception: if a sidecar doesn't know how to route a request (e.g. due to a missing interface dependency), it can route the request to kong instead.
Exception (New): calls made during entitlement (see section 6), which are routed through Kong.
2.5 Maintenance windows
Hosting providers / system operators often notify customers of an appropriately sized maintenance window, during which use the system will be updated. Use of the system is discouraged/disallowed throughout the maintenance window.
These maintenance windows will help mitigate some race conditions, but will never fully solve the problem (e.g. timers fire automatically on predefined schedules, regardless of human activity).
Enforcement of these windows is up to the hosting provider / system operators. Steps may be taken to block or disallow use of the system, or it may just be a request to the library, with a disclaimer.
3. Sequences
app-platform-minimal contains the modules that are responsible for creation/mgmt of system users, capabilities and timers (mod-users-keycloak, mod-roles-keycloak, mod-scheduler, etc.). app-foo stands for any other application.
"Wait" means the gate described in section 4. Event confirmation waits are no-ops when MTE’s EVENT_PUBLISHER_AWAIT_COMPLETION=false. The tenant-API completion waits always apply.
Operation | Step | Action |
|---|---|---|
Enable | 1 | Call tenant APIs (creates tenant schema etc. for |
| 2 | As each module's tenant API completes, publish that module's entitlement event. Do not wait for the remaining modules in the application (see 3.3) |
| 3 | Wait for all tenant API calls to complete |
| 4 | Publish user / timer / capability events (creates system users, capabilities and timers defined by platform-minimal modules) |
Enable | 1 | Publish user / capability events (so system users exist before tenant API calls) |
| 2 | Wait |
| 3 | For each module: call its tenant API (tenant APIs may safely make m2m calls). For async (v2) tenant APIs, poll the operation status until it completes |
| 4 | As each module's tenant API completes, publish that module's entitlement event. Do not wait for the remaining modules in the application (see 3.3) |
| 5 | Wait for all tenant API calls to complete |
| 6 | Publish timer events |
Upgrade | 1 | Call tenant APIs |
| 2 | As each module's tenant API completes, publish that module's entitlement event. Do not wait for the remaining modules in the application (see 3.3) |
| 3 | Wait for all tenant API calls to complete |
| 4 | Publish user / timer / capability events (updates the entities defined by platform-minimal modules) |
Upgrade | 1 | Publish user / capability events (system users up to date before tenant APIs run) |
| 2 | Wait |
| 3 | For each module: call its tenant API (updates entities; m2m calls are safe). For async (v2) tenant APIs, poll the operation status until it completes |
| 4 | As each module's tenant API completes, publish that module's entitlement event (see 3.3) |
| 5 | Wait for all tenant API calls to complete |
| 6 | Publish timer events |
Revoke | 1 | Call tenant APIs (system users, if needed, are still present) |
| 2 | Wait |
| 3 | Publish entitlement events (updates sidecar entitlement info, disables system timers, updates entitlement Kafka filtering; |
Revoke | 1 | Call tenant APIs (system users, if needed, are still present) |
| 2 | Wait |
| 3 | Publish the entitlement event (updates entitlement kafka filtering and sidecar entitlement info) |
Enable / upgrade | 1 | Run the |
| 2 | Wait |
| 3 | Run the |
Revoke | 1 | Run the |
| 2 | Wait |
| 3 | Run the |
Enable/Upgrade/Revoke | 1 | Rely on MTE’s ordering of entitlement/upgrade operations based on required and optional application-level dependencies. If a tenant API call fails because a m2m call error, the entitlement/upgrade operation can safely be retried since the tenant APIs should be idempotent. |
Enable/Upgrade/Revoke | 1 | Here the MTE’s ordering of entitlement/upgrade operations based on application-level dependencies will not help since the modules are part of the same application. However, the MTE also orders the tenant API calls based on interface dependencies. When such dependencies exist, we’ll should execute the calls for those module’s tenant APIs sequentially instead of in parallel. |
3.1 Patterns
app-platform-minimal: always call tenant APIs first, wait, then publish events.app-foo: publish user / capability events first, wait, then call the tenant APIs, publishing each module's entitlement event as its tenant API completes. Wait for all the tenant APIs to complete, then publish timer events.Applications that include
mod-users-keycloak,mod-roles-keycloakormod-schedulerdeclare a new app-descriptor property,coreEntitlement: <true|false>, which tells MTE to use the "tenant APIs first" sequence. Presently this is only required in app-platform-minimal. This property allows us to avoid special casing specific application or module names. Default tofalse, which uses theapp-foosequence. Note that this also differs from today's flow (capability events move before tenant APIs, timers move after all tenant APIs, and each phase waits when MTE’sEVENT_PUBLISHER_AWAIT_COMPLETION=true).
3.2 Interaction with the mixed-version race
Publishing events only after every platform-minimal module is entitled to its new version can avoid the lost-event race: only the new consumer version accepts the event. The key is to wait for all of the platform-minimal module tenant APIs to fully complete before publishing the events. Platform-minimal modules use a mix of synchronous and asynchronous tenant APIs, so the gate must handle both (see 4.3).
3.3 Module-level entitlement tracking
Entitlement events are now emitted per module, as each module's tenant API completes, rather than once for the whole application after every tenant API has finished. This means MTE must track entitlements down to the module level, not only at the application level, and persist the result as each individual module entitlement completes.
Introducing an application entitlement status such as "in progress" / "partially complete" is likely needed to represent an application whose modules are not all entitled yet.
The details (data model, persistence, failure and retry handling, what a partially entitled application means for consumers) are to be worked out, possibly via a spike pulled by the Eureka developers.
4. The "wait" step
Several sequences require MTE to wait for Kafka message processing before proceeding.
4.1 Requirements
MTE must know what it published (count and identity of events).
The gate must confirm that events were processed, not merely consumed. In the mixed-version race, an event can be consumed by every version and discarded by all of them, so a consumption-only gate will not suffice.
4.2 Options
Option | Reliability | Trade-offs |
|---|---|---|
Confirmation Kafka message | Reliable | Adds more asynchronous messaging - Already implemented! |
Callbacks | Most reliable | No additional async messaging; requires module changes |
Broker receipt status | Is there a reliable way? | Reports delivery, not processing |
Subscribe to own topic (wait until MTE consumes everything it sent) | Lowest | No module changes. Confirms consumption only, so it can't detect discarded events |
[DECISION] Despite callbacks being slightly more reliable, We chose the kafka confirmation mechanism since it's already implemented for the Async Entitlement Processing Feedback Loop feature.
4.3 Implementation
Add a "wait" stage to the flow engine.
The confirmation wait applies only when
EVENT_PUBLISHER_AWAIT_COMPLETION=trueand needsEVENT_CONFIRMATION_ENABLED=truein the three core modules.
Poll storage, waiting for all events to be confirmed as processed.
Configurable: polling frequency (Default: 2 seconds)
Configurable: max time to wait (Default: 5 minutes)
Tenant API completion is a separate gate from event confirmation which is not controlled via a feature flag, and the two kinds of tenant API behave differently (Okapi guide: enabling for a tenant):
Spring-based modules, including all Spring modules in
app-platform-minimal(mod-*-keycloak,mod-scheduler), implement the synchronous tenant API (v1). ThePOST _/tenantresponse means the work is done, so no additional wait is needed.RMB/RAML-based modules (e.g.
mod-configuration,mod-permissions,mod-settings,mod-users,mod-users-bl) implement the asynchronous tenant API (v2).POST _/tenantreturns immediately, and MTE must poll the operation status until it completes before moving to the next step.Configurable: max wait for async entitlement to complete (Default: 30 minutes)
5. Revoke leaves system data in place (separate workstream)
On revoke, MTE publishes no events other than the entitlement event.
Item | Current behavior |
|---|---|
System users | Remain in place |
Timers | Cleaned up by |
Capabilities | Remain in place |
This was discovered while analyzing the sequences above. It is not on the critical path for the sequencing and routing changes, so it is tracked as its own workstream.
System users: a spike will investigate.
Previously discussed (serves as a starting point for the spike):
Disable the tenant's system users upon revoke.
Upon entitle / upgrade, the logic must ensure the system user exists and is enabled/active.
mod-users-keycloaksubscribes to the entitlement events to trigger this, rather than extending thesystem-userevent mechanism. There is precedent:mod-scheduleralready does this. It is also simpler, since the events are already emitted and no MTE changes are required.
Capabilities: a spike will investigate, as several aspects need to be researched and fleshed out.
Dependency: the app-foo pattern (section 3.1) works because system users survive revoke. Once users are disabled on revoke, the sequences must be re-checked so that tenant API calls made during revoke still find an enabled system user where needed.
6. Module calls made during entitlement
Some modules call other modules during their tenant upgrade (the POST _/tenant call).
6.1 Problem
Sidecars cache entitlement information, and that cache updates asynchronously. Kong routes are updated synchronously by MTE. During an upgrade, a sidecar may still believe the tenant uses the old version and send the call directly to the old module version.
6.2 Category 1: provider declared in requires
Example: Many modules call mod-settings APIs while upgrading. MTE orders module entitlements so providers are enabled/upgraded first, but the sidecar cache may lag.
Proposed solution (header-based routing):
MTE sends
x-okapi-egress-use-gateway: trueonPOST _/tenantto the module. Thex-okapi-prefix is deliberate: existing code already propagatesx-okapi-*headers on outgoing calls, so no module changes are needed in most cases.The module propagates the header on all outgoing calls it makes while handling the request.
The sidecar, on receiving an egress call with the header set to
true, forwards the request to Kong instead of directly to the target sidecar.The sidecar removes the header before proxying to Kong.
NOTE: this will limit the scope of
x-okapi-egress-use-gatewayto only the modules in the original entitlement call, and the modules they call during tenant API handling. It will not propagate to downstream modules beyond that, e.g. During a tenant API call to A, A calls B, and B calls C: The B->C request will happen via sidecar routing, not Kong, regardless ofx-okapi-egress-use-gateway. This is generally considered safe because it mirrors the scope of the application being entitled.
Since Kong is updated before any tenant API calls are made, Kong already knows to route the request to the correct module version.
Notes:
Authorization is enforced by the destination sidecar. The header affects only how the request gets there, so it is not a security concern.
Direct sidecar-to-sidecar routing remains the default, so the behavior is an opt-in exception.
The header must not leak into asynchronous work that outlives the request or into published Kafka messages.
Propagation coverage:
Spring-based modules transpose all
x-okapi-*headers to outgoing requests automatically.RMB does the same, but some RMB modules implement custom HTTP clients.
Some modules use neither Spring nor RMB (e.g. the ERM modules, which are Groovy/Grails-based, and others that use no framework at all).
These are potential gaps. A module is at risk if it meets all of the following:
It is not Spring-based.
It implements a custom HTTP client.
It performs m2m calls during tenant API handling.
[OPEN] We expect the resulting list to be short. A spike will audit tenant handlers to identify the affected modules (see section 7).
Alternative considered: request-ID capture. The sidecar remembers the request ID of incoming tenant API calls and routes any egress call with that ID to Kong. It needs no new header but requires sidecar state (tracking, expiry, etc.) and ID propagation by modules. It is less explicit and is possibly harder to debug.
6.3 Category 2: provider not declared in requires (optional dependency)
Example: mod-fqm-manager calls locations and location-units while migrating custom entity types during upgrade.
MTE does not consider optional dependencies when ordering upgrades, so FQM may be upgraded before the providers.
Routing through Kong does not help: Kong routes by the tenant's current entitlement, so it still sends the call to the old version.
[DECISION] All of the following options will be implemented. They address different parts of the problem and reinforce each other.
Option | Notes |
|---|---|
Treat optional dependencies as ordering hints in MTE | Affects all modules. Hard |
Run the migration after the entitlement switch | FQM listens for entitlement updates ( |
Make the migration idempotent and retry with backoff | Tolerates the provider being on the old version for a while |
Tolerate old and new provider API versions | FQM can fail if it expects a particular response shape (e.g. v2's) but receives another (e.g. v1's). Even if it does not handle this gracefully today, it should: as applications move toward independent release and deployment, tolerating and gracefully handling version skew becomes increasingly important. Tracked as a story for the FQM team |
7. Implementation plan
Workstream A: sequencing, gating and routing (critical path)
A1. Wait stage in the flow engine
A1a. Confirm confirmation coverage. The existing mechanism (UXPROD-5714) covers the capability, system-user and scheduled-job publishers; the consumer side comes from the folio-kafka-consumer library, which also provides the marker-table filter. Verify that mod-roles-keycloak, mod-users-keycloak and mod-scheduler each send a resource-result event with the stage UUID. File a story for any consumer that does not.
Confirmed in code.
EVENT_CONFIRMATION_ENABLED=truecontrols this behavior, No story required.
A1b. Wait stage. Poll storage until every event the stage published is confirmed as processed. Configurable: polling frequency and maximum wait. Defaults: 2 seconds and 5 minutes.
The wait must work with the existing settings. This wait depends on MTE’s
EVENT_PUBLISHER_AWAIT_COMPLETIONflag. Whentrue, MTE waits for confirmation events. When absent orfalse, the wait is effectively a no-op. A wait timeout (5 minutes) fires before the sweeper timeout (ASYNC_CONFIRMATION_TIMEOUT, 90 minutes).When a timeout occurs, the waiting publisher stages are marked
FAILEDalong with the flow, so a late resource-result is dropped by the existing rule for stages that are no longer in progress. See https://github.com/folio-org/mgr-tenant-entitlements/blob/master/docs/features/async-stage-result-tracking.md#business-rules-and-constraintsA
FAILUREresult fails the wait immediately instead of running to the timeout.On timeout, fail the stage and the flow with a message naming the unconfirmed events. Recovery is a re-run of the entitlement, relying on idempotent tenant APIs and event handlers.
A1c. Entitlement events are not confirmed and not waited for. For enable and upgrade they affect only the sidecars.
mod-scheduleralso switches that module's existing timers on at ENTITLE and UPGRADE, which does nothing the first time a module is enabled. The sidecar relies on the header (A6) plus its reload onTenantNotEnabled(see A3f). The platform-minimal Kafka consumers use a marker-table filter tied to their own tenant API, so the wait for tenant API completion is what gates them. For revoke the entitlement events are the last step, so nothing waits for them. Publish them per module as each tenant API completes on enable and upgrade, and after all tenant APIs on revoke.
A2. Asynchronous tenant API support (net-new work)
Today
FolioTenantApiClientreturns after any response of 300 or below, so the module stage ends before an asynchronous operation finishes. Add polling of the operation status until the operation completes before the module stage ends and before its entitlement event is published.Define "asynchronous" by the response (operation accepted, status resource), not by the interface version number. The sections 3 and 4.3 shorthand "v1/v2" does not match MTE's own use of "legacy" for tenant interface 1.x.
Configurable operation timeout. Default: 30 minutes. A timeout or a failed operation fails the module stage.
Design constraint. Do not poll inside the
@TransactionalFolioModuleService.enable: it would hold a database transaction for up to the timeout, across parallel module flows. Also decide what happens to the saved module entitlement when the operation fails, so a re-run does not skip the module as "already installed". Resolve this together with A5.Integrate with the existing stage retry (
@FolioModuleCallsRetryable): state whether a failed operation is retried by a new POST or fails the stage.Release A2 first, on its own. Asynchronous tenant failures are invisible today, so some entitlements that "succeed" now will start failing. Let that surface in lower environments before the phased flow lands.
A3. Restructure the application flow into phases (split into stories; needs A1, A2 and A4)
A3a. Phase model. Move the system-user, scheduled-job (timer) and capability publishers out of the per-module flow into application-level stages. UI modules currently publish only capability events in their flow, so include them. State clearly in the story that this changes the default path (capability events before tenant APIs, timers after all of them).
A3b. Default (
app-foo) enable and upgrade. Publish system-user and capability events, wait, run each module (tenant API, then that module's entitlement event), wait for all tenant APIs, then publish timer events last. Enable no longer publishes timer events in step 1.A3c.
coreEntitlementapplications. Tenant APIs, wait, then publish system-user, timer and capability events. Entitlement events are published per module as each tenant API completes, as today.A3d. Revoke. Tenant APIs, wait, then entitlement events. For non-legacy tenant interfaces there is no tenant call unless
purge=true, so the "system users still present" condition only matters then. Today the event is published per module right after its uninstall; the table moves it to after all tenant APIs, so this is a code change. Kong and Keycloak cleanup currently runs per module after the event (verified). Keep it after the event and after the tenant APIs, which keeps header routing working during revoke tenant calls.A3e. Combined applications. Platform-minimal first on enable or upgrade, reversed on revoke, with a wait between the two applications.
A3f. Modules calling each other. Confirm the interface-dependency levels already run dependent modules sequentially (levels are sequential and modules within a level are parallel today). A failed m2m call (for example
TenantNotEnabled) first meets the existing stage retry. Check whether that window is long enough for the sidecar cache lag, then rely on re-running the entitlement for anything beyond it. The header (A6) fixes routing from the caller's sidecar only. The destination sidecar still rejects the call until it has applied the module's entitlement event or reloaded entitlements from MTE. The reload is triggered by the failed check and throttled by a flag that a cron resets; the source marks it as temporary (MODSIDECAR-126, "should be removed after design long term solution"). Decided: rely on the reload plus the stage retry and, beyond that, a re-run of the entitlement; no sidecar story. If MODSIDECAR-126 is removed or replaced, revisit this.A3g. Integration test. Assert event order for every row of the section 3 table, including entitlement events and UI-module capability events. Tests should exercise both
EVENT_PUBLISHER_AWAIT_COMPLETIONpaths (trueandfalse).A3h. Rollout and Configuration.
Two valid configurations will exist:
Current behavior wrt waiting - confirmation events are not sent, and MTE doesn’t wait for confirmation events. Race conditions still exist.
MTE has
EVENT_PUBLISHER_AWAIT_COMPLETION=falseor not set at all (default is false)core modules have
EVENT_CONFIRMATION_ENABLED=false, or not set at all.
New behavior - confirmation events are sent by core modules, MTE waits for confirmation events. Race conditions are mitigated.
MTE has
EVENT_PUBLISHER_AWAIT_COMPLETION=truecore modules have
EVENT_CONFIRMATION_ENABLED=true
Release an
app-platform-minimalversion withcoreEntitlement: truebefore, or together with, the MTE release. Once MTE is upgraded,app-platform-minimalmust only be entitled or upgraded to a version that has the property set. Otherwise the wrong order of operations will be used when entitling the core modules.Ensure the release notes clearly describe the valid configurations, and migration path/sequence.
A4. Application descriptor property for core entitlement
Boolean, default
false. Property name:coreEntitlement(decided; matches the camelCase of existing descriptor properties).Repositories:
mgr-applicationsowns the schema (applicationDescriptor.json, which allows additional properties, so declaring it is documentation and validation rather than a requirement),folio-application-generatorhas its own descriptor and template models that must pass the property through, MTE reads it, and theapp-platform-minimaltemplate sets it totrue.The property applies to the whole application. MTE honors it as written and never infers it from module names. Before releasing the property ahead of the flow, check that older MTE versions and
mgr-applicationsaccept an unknown descriptor property (the schema allows additional properties; not verified for MTE).Proposed: the generator warns if an application contains any of
mod-users-keycloak,mod-roles-keycloakormod-schedulerand the flag is nottrue.
A5. Spike: application-level entitlement status (possibly pulled by the Eureka developers)
Module-level tracking exists already, so the spike focuses on application-level status.
Output: a design page covering status values (for example in-progress and partially complete), persistence, retry semantics, what consumers see, and the A2 constraint on saving the module entitlement. This also answers how a half-upgraded application is handled.
Output: stories for the implementation.
A6. x-okapi-egress-use-gateway handling
MTE always sends the header on every tenant API call (
POST /_/tenant,DELETE /_/tenant,POST /_/tenant/disable) and on operation polling, with no feature flag.The sidecar routes an egress call with the header set to
trueto Kong and removes the header before proxying.Rollout order does not matter: an old sidecar ignores the header (so m2m calls route as today), and a new sidecar without the header behaves as today. Document this.
Mixed sidecar versions: an old sidecar does not strip the header, so it can travel one hop further than intended. Because Kong is updated before the module's own tenant API call, this only routes extra calls through Kong, so it is acceptable. Document this behavior.
Document the scope limit from 6.2: in A calls B calls C, the B to C call goes by sidecar routing, and the sidecar's re-fetch of entitlement information on a failed tenant check is the safety net (see A3f for its limits).
Acceptance: an end-to-end test where a module calls a provider during
POST /_/tenantand the call reaches the new provider version; a second test for a revoke tenant call.
A7. External requests carrying the header
Strip the header in API gateway for external traffic. Authorization is still enforced by the destination sidecar, so this limits routing load rather than closing a security hole.
The sidecar cannot simply ignore the header on ingress, because MTE's tenant call arrives as an ingress request and the module propagates the header from it.
MTE's tenant calls go straight to the module's discovery location, not through Kong (verified in
FolioTenantApiClient), so stripping in the API Gateway does not affect them.This can be achieved via Kong’s built-in request-transformer plugin. We’re already using a very similar response-transformer plugin. See https://github.com/folio-org/folio-kong/blob/master/config/global.yaml , https://developer.konghq.com/plugins/request-transformer/reference/#schema--config-remove
Similarly, for APISIX, we can use the proxy-rewrite plugin. See https://apisix.apache.org/docs/apisix/plugins/proxy-rewrite/
Since this is not on the critical path, and rather more of a safeguard against misuse, the recommendation is to only implement this in folio-apisix. That said, it’s not a lot of effort to implement it in both places. Most of the effort is probably on the testing side.
A8. Spike: audit tenant handlers
Find modules that are not Spring-based, implement a custom HTTP client and perform m2m calls during tenant API handling.
Also check whether
x-okapi-*headers leak into published Kafka messages or background work that outlives the request.Output: a table (module, repository, framework, HTTP client, m2m calls during tenant API, propagates header) and one remediation story per affected module, filed in the owning team's Jira project.
Workstream B: Category 2 (optional dependencies)
B1. MTE: treat optional dependencies as ordering hints
Module-level optional interfaces order modules within an application. When the provider is in another application, they add an application-level ordering edge.
Ships behind a feature flag, off by default. Name the flag and define the rollout stages in the story.
Before enabling, run a dry-run comparison of module orderings across a full platform release. Pass criteria: every changed ordering is listed and reviewed, and no new cycle appears.
Hard
requiresmust win. A cycle drops the optional edge and logs a warning. A missing or failing optional provider must not block the consumer.The section 3
app-foo+app-barrow must say it relies on this item when the flag is on, and on retries when it is off.
Workstream C: revoke behavior (deferred, not on the critical path)
C1. Spike: system users on revoke (mod-users-keycloak / Eureka team)
Output: a design page, discussion with the Eureka Architecture group, and follow-up stories. It answers:
Trigger. What distinguishes a real revoke from the old half of an upgrade? The upgrade flow publishes
REVOKEfor the old module id and thenUPGRADEfor the new one (verified). A module dropped from a new application version (a deprecated-module stage) and a rolled-backENTITLEalso produce a bareREVOKE. Candidates: an optional event field, a module-name check against current entitlement (racy), or an application-level signal. If the answer needs an MTE change, the "no MTE changes required" statement in section 5 must be corrected.Granularity. Revoking
app-foomust disable only the users its modules defined, whileapp-platform-minimalstays. Check howmod-users-keycloakrecords which module owns a system user.Re-enable. Section 5 puts enable and upgrade logic on the entitlement event, but an
app-footenant API runs before that module's entitlement event. Decide whether thesystem-userevent handler must also re-enable users.Revoke sequences. Recheck the section 3 revoke rows once users can be disabled, so tenant APIs run during a revoke (purge or legacy disable) still find an enabled system user. With
purge=true,mod-users-keycloakhas already cleared its own marker by the time the revoke event arrives, so a listener there that uses the marker filter never sees it.purge=true. Whether users should be deleted rather than disabled.mod-users-keycloakalready handlesCREATE,UPDATEandDELETEsystem-user events (verified), so a delete path exists.Event payload. What the entitlement event must carry, staying compatible with the sidecar,
mod-schedulerand the Kafka filter, which each parse the current four fields with their own model class. Confirm each ignores unknown properties.
C2. Spike: capabilities on revoke
Output: documented findings, discussion with the Eureka Architecture group, and follow-up stories.
C3. Follow-up stories and ship gate
Stories are created from the C1 and C2 outputs, filed with the owning teams.
Until then, system users and capabilities remain after revoke, so the
app-foopattern in section 3.1 still holds.Gate: disabling system users on revoke does not ship until C1.3 and C1.4 are resolved and the section 3 revoke rows are updated.
Workstream D: FQM adjustments (follow-on work - to be discussed and coordinated with team Athena)
D1. FQM: run the custom entity type migration after the entitlement switch
FQM listens to the existing
${ENV}.entitlementKafka topic and runs the migration after theUPGRADEevent for its own module id. In a mixed-version cluster it ignores events for other module ids.FQM sets
x-okapi-egress-use-gatewayitself on those calls, because the migration runs outside any tenant API call and MTE cannot set it.If Kong/APISIX has no route (the tenant is not entitled to the optional provider), FQM skips that dependency and retries later. The story defines how FQM tells "no route" from a transient failure.
The own-
UPGRADEtrigger does not prove that a provider in another application has been upgraded. The final trigger design is left to the FQM team. Suggested approach: the ownUPGRADEevent plus D2 retries, with re-running on provider events as a later option.Depends on A6 being deployed in the sidecar.
D2. FQM: make the migration idempotent and retry with backoff
D3. FQM: tolerate old and new provider API response shapes
Delivery order
In parallel: A1a, A2 (first release, no flag, after the A5 constraint is settled), A4, A5, A6, A8, C1, C2.
A1b, then A3a to A3g (needs A1, A2, A4). Set
EVENT_PUBLISHER_AWAIT_COMPLETION=truein MTE per environment once the core modules confirm (haveEVENT_CONFIRMATION_ENABLED=true– A3h)A7 alongside A6. B1 last, flag off, dry run before enabling.
C3 stories after C1 and C2, gated as above.
Workstream D is follow-on work, coordinated with the FQM team… D1 after A6 is in the sidecar. D2 and D3 any time.
Does this proposal handle when an application is half-upgraded? i.e. first module in app succeeds, while second module does not. This may be a pre-existing problem.