@checkstack/healthcheck-backend 0.16.3 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/healthcheck-gitops-kinds.test.ts +13 -10
- package/src/healthcheck-gitops-kinds.ts +17 -1
- package/src/index.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @checkstack/healthcheck-backend
|
|
2
2
|
|
|
3
|
+
## 0.16.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9a320fe: Fixed an issue where GitOps-provisioned health checks were not added to the background execution queue immediately upon association.
|
|
8
|
+
- @checkstack/satellite-backend@0.2.13
|
|
9
|
+
|
|
10
|
+
## 0.16.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [adc89a8]
|
|
15
|
+
- @checkstack/gitops-backend@0.2.3
|
|
16
|
+
- @checkstack/catalog-backend@0.5.4
|
|
17
|
+
- @checkstack/satellite-backend@0.2.12
|
|
18
|
+
|
|
3
19
|
## 0.16.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -115,6 +115,10 @@ function createMockService() {
|
|
|
115
115
|
})
|
|
116
116
|
.filter(Boolean);
|
|
117
117
|
}),
|
|
118
|
+
getConfiguration: mock(async (id: string) => {
|
|
119
|
+
const config = configs.find((c) => c.id === id);
|
|
120
|
+
return config as unknown as HealthCheckConfiguration | undefined;
|
|
121
|
+
}),
|
|
118
122
|
};
|
|
119
123
|
}
|
|
120
124
|
|
|
@@ -217,16 +221,13 @@ describe("Healthcheck GitOps Kind: Healthcheck", () => {
|
|
|
217
221
|
});
|
|
218
222
|
|
|
219
223
|
function buildKind() {
|
|
220
|
-
|
|
221
|
-
createService: () =>
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
getHealthCheckRegistry: () => mockHCRegistry as never,
|
|
228
|
-
getCollectorRegistry: () => mockCollectorRegistry as never,
|
|
229
|
-
});
|
|
224
|
+
const mockDeps = {
|
|
225
|
+
createService: () => mockService as any,
|
|
226
|
+
getHealthCheckRegistry: () => mockHCRegistry as any,
|
|
227
|
+
getCollectorRegistry: () => mockCollectorRegistry as any,
|
|
228
|
+
getQueueManager: () => ({ getQueue: () => ({ scheduleRecurring: async () => "job-123" }) } as any),
|
|
229
|
+
};
|
|
230
|
+
return buildHealthcheckKind(mockDeps);
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
it("creates a new healthcheck configuration and returns entityId", async () => {
|
|
@@ -488,9 +489,11 @@ describe("Healthcheck GitOps Kind: System Extension", () => {
|
|
|
488
489
|
associateSystem: mockService.associateSystem,
|
|
489
490
|
disassociateSystem: mockService.disassociateSystem,
|
|
490
491
|
getSystemConfigurations: mockService.getSystemConfigurations,
|
|
492
|
+
getConfiguration: mockService.getConfiguration,
|
|
491
493
|
}) as never,
|
|
492
494
|
getHealthCheckRegistry: () => createMockHealthCheckRegistry() as never,
|
|
493
495
|
getCollectorRegistry: () => createMockCollectorRegistry() as never,
|
|
496
|
+
getQueueManager: () => ({ getQueue: () => ({ scheduleRecurring: async () => "job-123" }) } as any),
|
|
494
497
|
});
|
|
495
498
|
}
|
|
496
499
|
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
arrayField,
|
|
23
23
|
enumField,
|
|
24
24
|
} from "@checkstack/backend-api";
|
|
25
|
+
import type { QueueManager } from "@checkstack/queue-api";
|
|
26
|
+
import { scheduleHealthCheck } from "./queue-executor";
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Lazy accessor functions — populated during init(), consumed during reconcile.
|
|
@@ -32,6 +34,7 @@ interface HealthcheckGitOpsKindsDeps {
|
|
|
32
34
|
createService: () => HealthCheckService;
|
|
33
35
|
getHealthCheckRegistry: () => HealthCheckRegistry;
|
|
34
36
|
getCollectorRegistry: () => CollectorRegistry;
|
|
37
|
+
getQueueManager: () => QueueManager;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
// ─── Healthcheck Spec Schema ───────────────────────────────────────────────
|
|
@@ -323,8 +326,21 @@ export function buildSystemHealthcheckExtension(
|
|
|
323
326
|
includeLocal: entry.includeLocal,
|
|
324
327
|
});
|
|
325
328
|
|
|
329
|
+
// Retrieve config to get the interval for scheduling
|
|
330
|
+
const config = await service.getConfiguration(configId);
|
|
331
|
+
if (config) {
|
|
332
|
+
await scheduleHealthCheck({
|
|
333
|
+
queueManager: deps.getQueueManager(),
|
|
334
|
+
payload: {
|
|
335
|
+
configId,
|
|
336
|
+
systemId: systemEntityId,
|
|
337
|
+
},
|
|
338
|
+
intervalSeconds: config.intervalSeconds,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
326
342
|
context.logger.info(
|
|
327
|
-
`GitOps: associated ${entry.ref.kind} "${entry.ref.name}" (${configId}) with System "${entity.metadata.name}"`,
|
|
343
|
+
`GitOps: associated ${entry.ref.kind} "${entry.ref.name}" (${configId}) with System "${entity.metadata.name}" and scheduled execution`,
|
|
328
344
|
);
|
|
329
345
|
}
|
|
330
346
|
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
type HealthCheckRegistry,
|
|
20
20
|
type CollectorRegistry,
|
|
21
21
|
} from "@checkstack/backend-api";
|
|
22
|
+
import type { QueueManager } from "@checkstack/queue-api";
|
|
22
23
|
import { integrationEventExtensionPoint } from "@checkstack/integration-backend";
|
|
23
24
|
import { entityKindExtensionPoint } from "@checkstack/gitops-backend";
|
|
24
25
|
import { z } from "zod";
|
|
@@ -99,6 +100,7 @@ export default createBackendPlugin({
|
|
|
99
100
|
let gitopsDb: SafeDatabase<typeof schema> | undefined;
|
|
100
101
|
let gitopsHealthCheckRegistry: HealthCheckRegistry | undefined;
|
|
101
102
|
let gitopsCollectorRegistry: CollectorRegistry | undefined;
|
|
103
|
+
let gitopsQueueManager: QueueManager | undefined;
|
|
102
104
|
|
|
103
105
|
const kindRegistry = env.getExtensionPoint(entityKindExtensionPoint);
|
|
104
106
|
registerHealthcheckGitOpsKinds({
|
|
@@ -125,6 +127,11 @@ export default createBackendPlugin({
|
|
|
125
127
|
throw new Error("CollectorRegistry not initialized");
|
|
126
128
|
return gitopsCollectorRegistry;
|
|
127
129
|
},
|
|
130
|
+
getQueueManager: () => {
|
|
131
|
+
if (!gitopsQueueManager)
|
|
132
|
+
throw new Error("QueueManager not initialized");
|
|
133
|
+
return gitopsQueueManager;
|
|
134
|
+
},
|
|
128
135
|
});
|
|
129
136
|
|
|
130
137
|
env.registerInit({
|
|
@@ -155,6 +162,7 @@ export default createBackendPlugin({
|
|
|
155
162
|
gitopsDb = database;
|
|
156
163
|
gitopsHealthCheckRegistry = healthCheckRegistry;
|
|
157
164
|
gitopsCollectorRegistry = collectorRegistry;
|
|
165
|
+
gitopsQueueManager = queueManager;
|
|
158
166
|
|
|
159
167
|
// Create catalog client for notification delegation
|
|
160
168
|
const catalogClient = rpcClient.forPlugin(CatalogApi);
|