Fix not rebuilding site resources from blueprint

This commit is contained in:
Owen
2025-12-07 22:13:26 -05:00
parent e10f7efcbe
commit 24cdac95cd
2 changed files with 13 additions and 12 deletions

View File

@@ -133,15 +133,12 @@ export async function applyBlueprint({
`Updating client resource ${result.newSiteResource.siteResourceId} on site ${site.sites.siteId}` `Updating client resource ${result.newSiteResource.siteResourceId} on site ${site.sites.siteId}`
); );
if (result.oldSiteResource) { await handleMessagingForUpdatedSiteResource(
// this was an update result.oldSiteResource,
await handleMessagingForUpdatedSiteResource( result.newSiteResource,
result.oldSiteResource, { siteId: site.sites.siteId, orgId: site.sites.orgId },
result.newSiteResource, trx
{ siteId: site.sites.siteId, orgId: site.sites.orgId }, );
trx
);
}
// await addClientTargets( // await addClientTargets(
// site.newt.newtId, // site.newt.newtId,
@@ -188,4 +185,4 @@ export async function applyBlueprint({
} }
return blueprint; return blueprint;
} }

View File

@@ -328,23 +328,27 @@ export async function updateSiteResource(
} }
export async function handleMessagingForUpdatedSiteResource( export async function handleMessagingForUpdatedSiteResource(
existingSiteResource: SiteResource, existingSiteResource: SiteResource | undefined,
updatedSiteResource: SiteResource, updatedSiteResource: SiteResource,
site: { siteId: number; orgId: string }, site: { siteId: number; orgId: string },
trx: Transaction trx: Transaction
) { ) {
const { mergedAllClients } = const { mergedAllClients } =
await rebuildClientAssociationsFromSiteResource( await rebuildClientAssociationsFromSiteResource(
existingSiteResource, // we want to rebuild based on the existing resource then we will apply the change to the destination below existingSiteResource || updatedSiteResource, // we want to rebuild based on the existing resource then we will apply the change to the destination below
trx trx
); );
// after everything is rebuilt above we still need to update the targets and remote subnets if the destination changed // after everything is rebuilt above we still need to update the targets and remote subnets if the destination changed
const destinationChanged = const destinationChanged =
existingSiteResource &&
existingSiteResource.destination !== updatedSiteResource.destination; existingSiteResource.destination !== updatedSiteResource.destination;
const aliasChanged = const aliasChanged =
existingSiteResource &&
existingSiteResource.alias !== updatedSiteResource.alias; existingSiteResource.alias !== updatedSiteResource.alias;
// if the existingSiteResource is undefined (new resource) we don't need to do anything here, the rebuild above handled it all
if (destinationChanged || aliasChanged) { if (destinationChanged || aliasChanged) {
const [newt] = await trx const [newt] = await trx
.select() .select()