mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-19 10:52:04 +00:00
fix: race condition + frontend refetching
This commit is contained in:
@@ -51,6 +51,11 @@ func (d *Daemon) handleEC2RunInstances(msg *nats.Msg) {
|
||||
respondWithError(msg, awserrors.ErrorMissingParameter)
|
||||
return
|
||||
}
|
||||
if d.imageService == nil {
|
||||
slog.Error("handleEC2RunInstances image service not initialized")
|
||||
respondWithError(msg, awserrors.ErrorServerInternal)
|
||||
return
|
||||
}
|
||||
if _, err := d.imageService.GetAMIConfig(*runInstancesInput.ImageId); err != nil {
|
||||
slog.Error("handleEC2RunInstances AMI not found", "imageId", *runInstancesInput.ImageId, "err", err)
|
||||
respondWithError(msg, awserrors.ErrorInvalidAMIIDNotFound)
|
||||
|
||||
@@ -224,8 +224,8 @@ func TestHandleEC2RunInstances_MessageParsing(t *testing.T) {
|
||||
// Start test NATS server
|
||||
natsURL := sharedNATSURL
|
||||
|
||||
// Create test daemon
|
||||
daemon := createTestDaemon(t, natsURL)
|
||||
// Create test daemon with all services initialized (image, key, etc.)
|
||||
daemon := createFullTestDaemon(t, natsURL)
|
||||
|
||||
// Subscribe to the ec2.launch topic with the handler
|
||||
sub, err := daemon.natsConn.QueueSubscribe("ec2.launch", "hive-workers", daemon.handleEC2RunInstances)
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
@@ -29,6 +29,7 @@ export const ec2InstancesQueryOptions = queryOptions({
|
||||
const command = new DescribeInstancesCommand({})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2InstanceQueryOptions = (instanceId: string) =>
|
||||
@@ -40,6 +41,7 @@ export const ec2InstanceQueryOptions = (instanceId: string) =>
|
||||
})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2InstanceTypesQueryOptions = queryOptions({
|
||||
@@ -55,6 +57,7 @@ export const ec2InstanceTypesQueryOptions = queryOptions({
|
||||
})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2ImagesQueryOptions = queryOptions({
|
||||
@@ -132,6 +135,7 @@ export const ec2SnapshotsQueryOptions = queryOptions({
|
||||
const command = new DescribeSnapshotsCommand({})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2SnapshotQueryOptions = (snapshotId: string) =>
|
||||
@@ -143,6 +147,7 @@ export const ec2SnapshotQueryOptions = (snapshotId: string) =>
|
||||
})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2VpcsQueryOptions = queryOptions({
|
||||
@@ -170,6 +175,7 @@ export const ec2VolumesQueryOptions = queryOptions({
|
||||
const command = new DescribeVolumesCommand({})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
export const ec2VolumeQueryOptions = (volumeId: string) =>
|
||||
@@ -181,4 +187,5 @@ export const ec2VolumeQueryOptions = (volumeId: string) =>
|
||||
})
|
||||
return getEc2Client().send(command)
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user