Fix rebuild generation reconciliation (Refs #155)
This commit is contained in:
@@ -710,3 +710,35 @@ it.each(['cancelled', 'failed'])(
|
||||
).toEqual({ history_expired_at: expect.any(String) });
|
||||
}
|
||||
);
|
||||
|
||||
it('retains completed rebuild evidence when a stale job binding hid an unreconciled generation', async () => {
|
||||
const a = await api();
|
||||
const hosts = await import('../../src/lib/server/hosts/index.js');
|
||||
const host = hosts.createHost({ name: 'Host' });
|
||||
a.db
|
||||
.prepare(
|
||||
"INSERT INTO native_instances(id,server,host_id,generation,library_id,image,port,created_at) VALUES('instance','s',?,2,'lib','image',1,?)"
|
||||
)
|
||||
.run(host.id, old);
|
||||
a.db
|
||||
.prepare(
|
||||
"INSERT INTO server_deployments(id,server,action,state,stage,started_at,finished_at,triggered_by) VALUES('cancelled','s','rebuild','cancelled','cancelled',?,?,'test')"
|
||||
)
|
||||
.run(old, old);
|
||||
const command = hosts.queueHostOperation(
|
||||
host.id,
|
||||
'instance.rebuild',
|
||||
{ nextGeneration: 3 },
|
||||
{ instanceId: 'instance', generation: 2 }
|
||||
);
|
||||
hosts.reportHostOperation(host.id, command.id, { state: 'completed' });
|
||||
a.db
|
||||
.prepare(
|
||||
"INSERT INTO native_provisioning(deployment_id,instance_id,generation,operation_id,applied_at) VALUES('cancelled','instance',1,?,?)"
|
||||
)
|
||||
.run(command.id, old);
|
||||
a.saveFleetSettings({ ...a.fleetSettings(), provisioningKeepDays: 1, historyKeepCount: 0 });
|
||||
expect(a.pruneHistory('provisioning')).toBe(0);
|
||||
a.db.prepare("UPDATE native_instances SET generation=3 WHERE id='instance'").run();
|
||||
expect(a.pruneHistory('provisioning')).toBe(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user