New install: a failed or removed install's short name can be used again

Found in the VM test: after a failed install, retrying with the same
short name was refused, and the unique short name per product would
have blocked it anyway. A failed install's record is replaced; a removed
one keeps its history under another name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:39:36 +02:00
co-authored by Claude Opus 5.5
parent b0d81ed195
commit 016d1ea17e
2 changed files with 29 additions and 1 deletions
+21
View File
@@ -264,3 +264,24 @@ describe('ports and alerts', () => {
expect(servers.serverProblems({ ...base, lastStats: { disks: [] } }, ram, [], NOW).map(p => p.type)).toEqual(['ram_high']);
});
});
describe('reusing a short name (found in the VM test)', () => {
test('after a failed install the same short name can be used again', async () => {
const { server } = await joinServer();
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
const first = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
const [job] = (await jobs.poll(server, { agentApiVersion: 1, agentVersion: '1.0.0', mode: 'church', runningJobId: null }, NOW)).jobs;
await jobs.receiveReport(server, signedReport(job, 'failed'), NOW);
const again = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
expect(again.deployment.id).not.toBe(first.deployment.id);
expect(await db.deployment.findUnique({ where: { id: first.deployment.id } })).toBeNull();
expect(again.deployment).toMatchObject({ webPort: 20000, apiPort: 20001 });
});
test('a live install keeps its name', async () => {
const { server } = await joinServer();
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.other.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'SHORT_NAME_TAKEN' });
});
});