@app-vitals/agent-admin 1.93.0 → 1.93.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.93.
|
|
3
|
+
"version": "1.93.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.93.
|
|
47
|
+
"@app-vitals/agent-lib": "1.93.1",
|
|
48
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
50
|
"@prisma/client": "^7.10.0",
|
package/src/agent-provisioner.ts
CHANGED
|
@@ -482,7 +482,7 @@ function envEntryEqual(a: KubernetesEnvVar, b: KubernetesEnvVar): boolean {
|
|
|
482
482
|
|
|
483
483
|
/**
|
|
484
484
|
* True when the live container is missing anything the desired container
|
|
485
|
-
* specifies (image, env entries, resource values).
|
|
485
|
+
* specifies (image, env entries, resource values, probe settings).
|
|
486
486
|
*
|
|
487
487
|
* Subset semantics: extra live env vars (added manually via kubectl) and extra
|
|
488
488
|
* resource keys (injected by cluster autoscalers like GKE Autopilot) are NOT
|
|
@@ -510,6 +510,38 @@ export function containerDrifted(
|
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
for (const probe of PROBE_FIELDS) {
|
|
514
|
+
if (probeDrifted(current[probe], desired[probe])) return true;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** The container probes the manifest builder owns. */
|
|
521
|
+
const PROBE_FIELDS = [
|
|
522
|
+
"startupProbe",
|
|
523
|
+
"livenessProbe",
|
|
524
|
+
"readinessProbe",
|
|
525
|
+
] as const;
|
|
526
|
+
|
|
527
|
+
type Probe = KubernetesContainer["livenessProbe"];
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* True when the live probe is missing, or differs on any field the desired
|
|
531
|
+
* probe sets. Fields only the live probe has (API-server defaults such as
|
|
532
|
+
* successThreshold or httpGet.scheme) are not drift. A probe the manifest does
|
|
533
|
+
* not define is never drift.
|
|
534
|
+
*/
|
|
535
|
+
function probeDrifted(current: Probe, desired: Probe): boolean {
|
|
536
|
+
if (desired === undefined) return false;
|
|
537
|
+
if (current === undefined) return true;
|
|
538
|
+
for (const [key, value] of Object.entries(desired)) {
|
|
539
|
+
if (key === "httpGet") continue;
|
|
540
|
+
if (current[key] !== value) return true;
|
|
541
|
+
}
|
|
542
|
+
for (const [key, value] of Object.entries(desired.httpGet ?? {})) {
|
|
543
|
+
if (current.httpGet?.[key] !== value) return true;
|
|
544
|
+
}
|
|
513
545
|
return false;
|
|
514
546
|
}
|
|
515
547
|
|
|
@@ -1432,7 +1464,7 @@ export class KubernetesAgentProvisioner implements AgentProvisioner {
|
|
|
1432
1464
|
} else {
|
|
1433
1465
|
// Deployment already exists — re-apply the desired container spec when
|
|
1434
1466
|
// it has drifted. The manifest builder is the single source of truth
|
|
1435
|
-
// for image, env, and
|
|
1467
|
+
// for image, env, resources and probes; the strategic-merge patch upserts env
|
|
1436
1468
|
// entries by name, so manually-added extra vars survive. (Patching only
|
|
1437
1469
|
// the image here would mean existing Deployments never pick up env or
|
|
1438
1470
|
// resource changes shipped in a new admin version.)
|
|
@@ -1557,6 +1589,14 @@ export class KubernetesAgentProvisioner implements AgentProvisioner {
|
|
|
1557
1589
|
: {
|
|
1558
1590
|
image: desired.image,
|
|
1559
1591
|
resources: desired.resources,
|
|
1592
|
+
// Probes too: a Deployment created before a probe change
|
|
1593
|
+
// otherwise keeps its old probes for ever (two agents ran
|
|
1594
|
+
// a 1s liveness timeout and no startup probe for months).
|
|
1595
|
+
...Object.fromEntries(
|
|
1596
|
+
PROBE_FIELDS.filter(
|
|
1597
|
+
(probe) => desired[probe] !== undefined,
|
|
1598
|
+
).map((probe) => [probe, desired[probe]]),
|
|
1599
|
+
),
|
|
1560
1600
|
}),
|
|
1561
1601
|
...(volumeMounts.length > 0 ? { volumeMounts } : {}),
|
|
1562
1602
|
...(env.length > 0 || !policyOnly ? { env } : {}),
|
|
@@ -474,6 +474,54 @@ describe("KubernetesAgentProvisioner.reconcile() — image-update detection", ()
|
|
|
474
474
|
expect(resources?.requests?.cpu).toBe("500m");
|
|
475
475
|
expect(resources?.limits?.cpu).toBe("2");
|
|
476
476
|
});
|
|
477
|
+
it("patches a Deployment whose probes predate the current manifest", async () => {
|
|
478
|
+
const agentId = "agent-old-probes";
|
|
479
|
+
const resourceName = sanitizeAgentName(agentId);
|
|
480
|
+
const stale = buildAgentDeploymentManifest({
|
|
481
|
+
agentId,
|
|
482
|
+
namespace: NAMESPACE,
|
|
483
|
+
image: BASE_CONFIG.image,
|
|
484
|
+
imageTag: BASE_CONFIG.imageTag,
|
|
485
|
+
apiUrl: BASE_CONFIG.apiUrl,
|
|
486
|
+
pvcName: `${resourceName}-home`,
|
|
487
|
+
secretName: `${resourceName}-token`,
|
|
488
|
+
tokenSecretKey: "token",
|
|
489
|
+
});
|
|
490
|
+
const container = stale.spec.template.spec.containers[0];
|
|
491
|
+
const want = structuredClone(container);
|
|
492
|
+
container.startupProbe = undefined;
|
|
493
|
+
container.livenessProbe = {
|
|
494
|
+
...container.livenessProbe,
|
|
495
|
+
timeoutSeconds: 1,
|
|
496
|
+
successThreshold: 1,
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
const k8s = new RecordedKubernetesClient({
|
|
500
|
+
deployments: { [`${NAMESPACE}/${resourceName}`]: stale },
|
|
501
|
+
secrets: {},
|
|
502
|
+
pvcs: {},
|
|
503
|
+
});
|
|
504
|
+
const provisioner = new KubernetesAgentProvisioner(
|
|
505
|
+
k8s,
|
|
506
|
+
stubTokens() as AgentTokenService,
|
|
507
|
+
BASE_CONFIG,
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
const result = await provisioner.reconcile([{ id: agentId }]);
|
|
511
|
+
|
|
512
|
+
expect(result.updated).toEqual([agentId]);
|
|
513
|
+
expect(result.failed).toEqual([]);
|
|
514
|
+
const live = (await k8s.getDeployment(NAMESPACE, resourceName)).spec
|
|
515
|
+
.template.spec.containers[0];
|
|
516
|
+
expect(live.startupProbe).toEqual(want.startupProbe);
|
|
517
|
+
expect(live.livenessProbe?.timeoutSeconds).toBe(
|
|
518
|
+
want.livenessProbe?.timeoutSeconds,
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
// A second pass finds nothing left to change.
|
|
522
|
+
const again = await provisioner.reconcile([{ id: agentId }]);
|
|
523
|
+
expect(again.updated).toEqual([]);
|
|
524
|
+
});
|
|
477
525
|
});
|
|
478
526
|
|
|
479
527
|
// ─── containerDrifted ─────────────────────────────────────────────────────────
|
|
@@ -516,6 +564,54 @@ describe("containerDrifted", () => {
|
|
|
516
564
|
expect(containerDrifted(current, desired())).toBe(true);
|
|
517
565
|
});
|
|
518
566
|
|
|
567
|
+
it("drifts when the live container has no startup probe", () => {
|
|
568
|
+
const current = desired();
|
|
569
|
+
current.startupProbe = undefined;
|
|
570
|
+
expect(containerDrifted(current, desired())).toBe(true);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
it("drifts when a live probe setting differs from the desired one", () => {
|
|
574
|
+
const current = desired();
|
|
575
|
+
current.livenessProbe = { ...current.livenessProbe, timeoutSeconds: 1 };
|
|
576
|
+
expect(containerDrifted(current, desired())).toBe(true);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it("drifts when a live probe targets a different port", () => {
|
|
580
|
+
const current = desired();
|
|
581
|
+
current.readinessProbe = {
|
|
582
|
+
...current.readinessProbe,
|
|
583
|
+
httpGet: { path: "/health", port: 1 },
|
|
584
|
+
};
|
|
585
|
+
expect(containerDrifted(current, desired())).toBe(true);
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it("API-server probe defaults on the live container are not drift", () => {
|
|
589
|
+
const current = desired();
|
|
590
|
+
for (const probe of [
|
|
591
|
+
"startupProbe",
|
|
592
|
+
"livenessProbe",
|
|
593
|
+
"readinessProbe",
|
|
594
|
+
] as const) {
|
|
595
|
+
current[probe] = {
|
|
596
|
+
...current[probe],
|
|
597
|
+
successThreshold: 1,
|
|
598
|
+
httpGet: { ...current[probe]?.httpGet, port: 3459, scheme: "HTTP" },
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
const want = desired();
|
|
602
|
+
for (const probe of [
|
|
603
|
+
"startupProbe",
|
|
604
|
+
"livenessProbe",
|
|
605
|
+
"readinessProbe",
|
|
606
|
+
] as const) {
|
|
607
|
+
want[probe] = {
|
|
608
|
+
...want[probe],
|
|
609
|
+
httpGet: { ...want[probe]?.httpGet, port: 3459 },
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
expect(containerDrifted(current, want)).toBe(false);
|
|
613
|
+
});
|
|
614
|
+
|
|
519
615
|
it("extra live env vars are not drift", () => {
|
|
520
616
|
const current = desired();
|
|
521
617
|
current.env = [
|