add changeset

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-08-13 19:03:13 +02:00
parent e671ac9592
commit 61aa6526f7
4 changed files with 13 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Avoid duplicate work by comparing previous processing rounds with the next
@@ -76,6 +76,7 @@ describe('DefaultCatalogProcessingEngine', () => {
kind: 'Location',
metadata: { name: 'test' },
},
hash: '',
state: new Map(),
nextUpdateAt: '',
lastDiscoveryAt: '',
@@ -137,6 +138,7 @@ describe('DefaultCatalogProcessingEngine', () => {
kind: 'Location',
metadata: { name: 'test' },
},
hash: '',
state: new Map(),
nextUpdateAt: '',
lastDiscoveryAt: '',
@@ -162,10 +162,11 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine {
const hash = hashBuilder.digest('hex');
if (hash === previousHash) {
console.log('skipping ', entityRef);
// If nothing changed in our produced outputs, we cannot have any
// significant effect on our surroundings; therefore, we just abort
// without any updates / stitching.
return;
}
console.log('going ahead with ', entityRef);
// If the result was marked as not OK, it signals that some part of the
// processing pipeline threw an exception. This can happen both as part of
@@ -124,11 +124,12 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
options: UpdateProcessedEntityOptions,
): Promise<void> {
const tx = txOpaque as Knex.Transaction;
const { id, errors } = options;
const { id, errors, hash } = options;
await tx<DbRefreshStateRow>('refresh_state')
.update({
errors,
hash,
})
.where('entity_id', id);
}
@@ -494,7 +495,7 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
processedEntity: i.processed_entity
? (JSON.parse(i.processed_entity) as Entity)
: undefined,
hash: i.hash,
hash: i.hash || '',
nextUpdateAt: i.next_update_at,
lastDiscoveryAt: i.last_discovery_at,
state: i.cache