Repository navigation
fix(infra): add DELETE cleanup policy to Artifact Registry (D116) - #94
Open
GMartin-Data wants to merge 1 commit into
Open
GMartin-Data wants to merge 1 commit into
GMartin-Data wants to merge 1 commit into
Conversation
A KEEP-only cleanup policy never deletes anything (Google docs: "Keep policies work with delete policies"). The repo accumulated 22/28 versions (~9 GB, ~17x free tier) despite two `--no-dry-run` arming attempts, which had nothing to arm. Root cause rectifies D115 (dry-run was a misdiagnosis). Add a DELETE policy (condition tag_state=ANY, matches all versions); the existing KEEP most_recent_versions/keep_count=3 protects the 3 newest of each package. When a version matches both, KEEP wins — prod images (dbt f7fcfea, ingestion ece987a, both #1 in top-3) are preserved. Unlike the dry_run field of D115 (no-op at plan: state==HCL==false), adding a block is a real structural diff — `terraform plan` shows "1 to change". Applying this plan IS the destructive arming (purge within ~24h), so it is left unapplied: arming is a deliberate post-defense step via dry-run + log review (see ~/explain/procedure-armement-ar-cleanup.md).
|
Ici GitHub je valide la revue |
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.
Contexte
Le repo Artifact Registry
datatalentaccumulait les versions d'images sansjamais être purgé : 22 versions
ingestion/ 28dbt, ~9 Go (~17× le freetier de 0,5 Go), malgré une cleanup policy censée n'en garder que 3 par image.
Le diagnostic initial (D115) attribuait l'inertie au mode dry-run.
C'était une erreur de diagnostic : le HCL portait déjà
cleanup_policy_dry_run = false, et deux armementsgcloud … --no-dry-run(02 et 03/06) n'ont rien purgé.Cause-racine réelle (D116) : la policy ne contenait qu'une entrée
KEEP.Or une policy
KEEPne supprime jamais rien par elle-même — doc Google,verbatim : « Keep policies work with delete policies to keep artifacts that would
be deleted according to the specifications of your delete policy ». Il manquait
une policy
DELETEpour désigner les candidats à la suppression. Sans elle,le
--no-dry-runn'avait rien à armer.Refs : D116 (cause rectifiée), D115 (diagnostic erroné conservé pour traçabilité),
D26 (free tier AR), D31 (
terraform planzéro diff — nuance ci-dessous).Décisions techniques
DELETE(tag_state=ANY, matche toutes les versions) +KEEP(keep_count=3). Quand une version matche les deux, laKEEPgagne (doc Google).dbt → f7fcfea…,ingestion → ece987a…, toutes deux #1 du top-3 → protégées parkeep_count=3.tag_state=ANYANYcouvre taguées + untaguées. LaDELETEexige au moins une condition (doc) ;ANYest la condition « tout matcher » valide.Changements
infra/main.tf— ajout du bloccleanup_policies { action = "DELETE" ; condition { tag_state = "ANY" } }avant le blocKEEPexistant. Commentaire HCL réécrit (D115 → D116).Validation
terraform planzéro diff »(D31), ce plan montre
1 to change— c'est attendu et voulu. L'ajout d'unbloc est un vrai diff structurel (≠ le champ
dry_runde D115, no-op au plancar state==HCL). C'est précisément ce qui rend ce fix corrigeable par Terraform,
là où D115 ne l'était pas.
Suite — PR délibérément NON mergée / NON armée
Appliquer ce plan EST l'armement destructif (pose la
DELETEcôté API → purgesous ~24 h). Le geste est volontairement différé post-soutenance : le process
GCP impose un dry-run + relecture des logs Cloud Logging pour prouver qu'aucune
image prod n'est supprimée avant de confirmer.
Procédure d'armement pas-à-pas (hors repo) :
~/explain/procedure-armement-ar-cleanup.md.Recompte attendu après purge : 3/3, repo ~1–1,5 Go.
Refs : D116, D115, D26, D31.