Skip to content

Commit 6311e8b

Browse files
authored
fix(gateway): preserve prepared runtime options on auth rewarm
1 parent 5763b4b commit 6311e8b

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎src/gateway/server-reload-handlers.test.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ afterEach(() => {
953953

954954
async function runManagedOwnershipScenario(params: {
955955
kind: "noop" | "hot" | "restart";
956+
getPluginMetadataSnapshot?: ManagedReloaderParams["getPluginMetadataSnapshot"];
956957
loggingChanged?: boolean;
957958
queueRevert: boolean;
958959
secretProviderChanged?: boolean;
@@ -1018,6 +1019,7 @@ async function runManagedOwnershipScenario(params: {
10181019
activateSecretsRuntimeSnapshot(snapshot(initialConfig));
10191020
const reloader = startManagedGatewayConfigReloader({
10201021
initialConfig,
1022+
getPluginMetadataSnapshot: params.getPluginMetadataSnapshot,
10211023
readSnapshot: vi.fn(async () => createValidConfigSnapshot(configB, "hash-b")) as never,
10221024
subscribeToWrites: captureConfigWriteListener(writeListenerRef, false),
10231025
activateRuntimeSecrets: activateRuntimeSecrets as never,
@@ -1059,16 +1061,23 @@ describe("managed reload transaction ownership", () => {
10591061
});
10601062

10611063
it("rebuilds prepared model owners for a no-op secret-provider publication", async () => {
1064+
const pluginMetadataSnapshot = {} as never;
10621065
const result = await runManagedOwnershipScenario({
10631066
kind: "noop",
10641067
queueRevert: false,
10651068
secretProviderChanged: true,
1069+
getPluginMetadataSnapshot: () => pluginMetadataSnapshot,
10661070
});
10671071

10681072
expect(hoisted.advancePreparedModelRuntimeConfig).not.toHaveBeenCalled();
10691073
expect(hoisted.refreshPreparedModelRuntimeSnapshots).toHaveBeenCalledExactlyOnceWith(
10701074
result.configA,
1071-
{ gatewayLifecycle: true },
1075+
{
1076+
gatewayLifecycle: true,
1077+
catalogMode: "static",
1078+
allowGatewaySubagentBinding: true,
1079+
pluginMetadataSnapshot,
1080+
},
10721081
);
10731082
});
10741083

@@ -1077,11 +1086,13 @@ describe("managed reload transaction ownership", () => {
10771086
// resolution yields a different object, the rebuilt owner carries an
10781087
// identity no reader supplies, so every strict catalog read rejects it --
10791088
// reviving the failure on the very fallback meant to be safe.
1089+
const pluginMetadataSnapshot = {} as never;
10801090
const result = await runManagedOwnershipScenario({
10811091
kind: "noop",
10821092
queueRevert: false,
10831093
secretProviderChanged: true,
10841094
resolveToDistinctConfig: true,
1095+
getPluginMetadataSnapshot: () => pluginMetadataSnapshot,
10851096
});
10861097

10871098
const resolved = result.resolvedConfigs.at(-1);
@@ -1095,7 +1106,12 @@ describe("managed reload transaction ownership", () => {
10951106
const [rebuiltWith, options] = hoisted.refreshPreparedModelRuntimeSnapshots.mock.calls[0] ?? [];
10961107
expect(rebuiltWith).toBe(resolved);
10971108
expect(rebuiltWith).not.toBe(result.configA);
1098-
expect(options).toEqual({ gatewayLifecycle: true });
1109+
expect(options).toEqual({
1110+
gatewayLifecycle: true,
1111+
catalogMode: "static",
1112+
allowGatewaySubagentBinding: true,
1113+
pluginMetadataSnapshot,
1114+
});
10991115
});
11001116

11011117
it("applies a current in-process hot config", async () => {

‎src/gateway/server-reload-managed.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,12 @@ export function startManagedGatewayConfigReloader(
500500
// candidate. `secrets.providers.*` resolves to a different object, and
501501
// stamping the rebuilt owner with the pre-resolution identity makes every
502502
// strict catalog read reject it -- the failure this fix exists to remove.
503+
const pluginMetadataSnapshot = params.getPluginMetadataSnapshot?.();
503504
await refreshPreparedModelRuntimeSnapshots(lastCommittedRuntimeConfig ?? nextConfig, {
504505
gatewayLifecycle: true,
506+
catalogMode: "static",
507+
allowGatewaySubagentBinding: true,
508+
...(pluginMetadataSnapshot ? { pluginMetadataSnapshot } : {}),
505509
});
506510
}
507511
},

0 commit comments

Comments
 (0)