Skip to content

Commit

Permalink
fix: node routingId/deploymentId is not unique
Browse files Browse the repository at this point in the history
Ex:
in case of error, a new node with same routingId/deploymentId will be
created
in case of runner idled because of inactivity, a new node with same
routingId/deploymentId will be created
  • Loading branch information
TBonnin committed Dec 5, 2024
1 parent 9831ce4 commit 0a2ded7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export async function up(knex: Knex): Promise<void> {
last_state_transition_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
);
`);
await trx.raw(`
CREATE UNIQUE INDEX idx_${NODES_TABLE}_routingId_deploymentId
ON ${NODES_TABLE}(routing_id, deployment_id);
`);
await trx.raw(`
CREATE INDEX idx_${NODES_TABLE}_routingId_state
ON ${NODES_TABLE}(routing_id, state)
Expand Down
22 changes: 0 additions & 22 deletions packages/fleet/lib/models/nodes.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,6 @@ describe('Nodes', () => {
lastStateTransitionAt: expect.any(Date)
});
});
it('should fail to create a node with the same routingId and deploymentId', async () => {
const routingId = 'my-routing-id';
await nodes.create(db, {
routingId,
deploymentId: activeDeployment.id,
url: 'http://localhost:3000',
image: 'nangohq/my-image:latest',
cpuMilli: 500,
memoryMb: 1024,
storageMb: 512
});
const result = await nodes.create(db, {
routingId,
deploymentId: activeDeployment.id,
url: 'http://localhost:3000',
image: 'nangohq/my-image:latest',
cpuMilli: 500,
memoryMb: 1024,
storageMb: 512
});
expect(result.isErr()).toBe(true);
});
it('should transition between valid states and error when transitioning between invalid states', async () => {
for (const from of nodeStates) {
for (const to of nodeStates) {
Expand Down

0 comments on commit 0a2ded7

Please # to comment.