Skip to content

Commit 61aa652

Browse files
committed
add changeset
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
1 parent e671ac9 commit 61aa652

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.changeset/cuddly-flowers-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@backstage/plugin-catalog-backend': patch
3+
---
4+
5+
Avoid duplicate work by comparing previous processing rounds with the next

plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ describe('DefaultCatalogProcessingEngine', () => {
7676
kind: 'Location',
7777
metadata: { name: 'test' },
7878
},
79+
hash: '',
7980
state: new Map(),
8081
nextUpdateAt: '',
8182
lastDiscoveryAt: '',
@@ -137,6 +138,7 @@ describe('DefaultCatalogProcessingEngine', () => {
137138
kind: 'Location',
138139
metadata: { name: 'test' },
139140
},
141+
hash: '',
140142
state: new Map(),
141143
nextUpdateAt: '',
142144
lastDiscoveryAt: '',

plugins/catalog-backend/src/next/DefaultCatalogProcessingEngine.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine {
162162

163163
const hash = hashBuilder.digest('hex');
164164
if (hash === previousHash) {
165-
console.log('skipping ', entityRef);
165+
// If nothing changed in our produced outputs, we cannot have any
166+
// significant effect on our surroundings; therefore, we just abort
167+
// without any updates / stitching.
166168
return;
167169
}
168-
console.log('going ahead with ', entityRef);
169170

170171
// If the result was marked as not OK, it signals that some part of the
171172
// processing pipeline threw an exception. This can happen both as part of

plugins/catalog-backend/src/next/database/DefaultProcessingDatabase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
124124
options: UpdateProcessedEntityOptions,
125125
): Promise<void> {
126126
const tx = txOpaque as Knex.Transaction;
127-
const { id, errors } = options;
127+
const { id, errors, hash } = options;
128128

129129
await tx<DbRefreshStateRow>('refresh_state')
130130
.update({
131131
errors,
132+
hash,
132133
})
133134
.where('entity_id', id);
134135
}
@@ -494,7 +495,7 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
494495
processedEntity: i.processed_entity
495496
? (JSON.parse(i.processed_entity) as Entity)
496497
: undefined,
497-
hash: i.hash,
498+
hash: i.hash || '',
498499
nextUpdateAt: i.next_update_at,
499500
lastDiscoveryAt: i.last_discovery_at,
500501
state: i.cache

0 commit comments

Comments
 (0)