fix(server-nestjs): make Registry create paths idempotent - #2625
Closed
shikanime wants to merge 2 commits into
Closed
fix(server-nestjs): make Registry create paths idempotent#2625shikanime wants to merge 2 commits into
shikanime wants to merge 2 commits into
Conversation
shikanime
force-pushed
the
fix/registry-create-idempotent
branch
2 times, most recently
from
August 28, 2026 11:01
1cb3ff2 to
e87970f
Compare
shikanime
force-pushed
the
fix/registry-create-idempotent
branch
3 times, most recently
from
August 28, 2026 14:20
2c732bd to
9eeaba3
Compare
shikanime
commented
Aug 28, 2026
Comment on lines
+233
to
+244
| @@ -253,14 +241,7 @@ export class RegistryService { | |||
| harborRuleCount: this.harborConfig.ruleCount, | |||
| harborRetentionCron: this.harborConfig.retentionCron, | |||
| }) | |||
| const retentionId = await this.client.getRetentionId(project.slug) | |||
| span?.setAttribute('registry.retention.exists', !!retentionId) | |||
| const result = retentionId | |||
| ? await this.client.updateRetention(retentionId, policy) | |||
| : await this.client.createRetention(policy) | |||
| if (result.status >= 300) { | |||
| throw new Error(`Harbor retention policy failed (${result.status})`) | |||
| } | |||
| await this.client.ensureRetention(project.slug, policy) | |||
Member
Author
There was a problem hiding this comment.
Remove this function, just directly call this.client.ensureRetention
|
shikanime
force-pushed
the
fix/registry-create-idempotent
branch
from
August 28, 2026 16:10
853eb26 to
d117bd7
Compare
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr> Change-Id: Ie0abe96c02dfa5421e7e787bc4d8ad1f6a6a6964
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr> Change-Id: I6e86475b1c00e5b9a5b0a15cc8f5e1736a6a6964
shikanime
force-pushed
the
fix/registry-create-idempotent
branch
from
August 28, 2026 16:27
eeedb12 to
e1cbb2d
Compare
shikanime
marked this pull request as ready for review
August 28, 2026 16:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

1 New Issue
0 Fixed Issues
0 Accepted Issues
Issues liées
#2620 (fermer délibérément après la fusion)
Quel est le comportement actuel ?
Lors d'une synchronisation concurrente (cron + événement), deux appels peuvent tenter de créer la même ressource Harbor en parallèle. Le POST perdant reçoit une erreur 409 (conflit) et la synchronisation échoue avec une erreur.
Quatre chemins de création sont concernés : la création de projet, l'ajout d'un membre de groupe, la création d'un robot et la création d'une stratégie de rétention. Chacun était protégé par un GET d'existence préalable dans la couche métier, mais sous une course cette garde ne suffisait pas.
Comportement attendu
L'idempotence est encapsulée dans le service client (
registry-client.service.ts) sous un motifensure*create-first : on tente la création ; si la ressource existe déjà (409), on la met à jour puis on relit l'état courant. La synchronisation devient idempotente face à la course.Changements
registry-client.service.tsexposeensureProject,ensureGroupMember,ensureRobotetensureRetention: chaque méthode tente la création, puis réconcilie sur un 409.null, la couche métier déclenche une rotation pour obtenir un secret frais.registry.service.ts) est simplifiée : elle appelle les méthodesensure*et ne gère plus les statuts 409 elle-même.