From 2cd933f9a7715a5281f0a0ae28ce647215b393e0 Mon Sep 17 00:00:00 2001 From: SimoneDutto Date: Wed, 4 Dec 2024 16:24:45 +0100 Subject: [PATCH] fix minor --- cmd/jimmsrv/service/service.go | 4 ++-- internal/jimm/model_cleanup.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/jimmsrv/service/service.go b/cmd/jimmsrv/service/service.go index c4082a0ee..9d7aad8fe 100644 --- a/cmd/jimmsrv/service/service.go +++ b/cmd/jimmsrv/service/service.go @@ -261,14 +261,14 @@ func (s *Service) OpenFGACleanup(ctx context.Context, trigger <-chan time.Time) } } -// OpenFGACleanup starts a goroutine that cleans up any orphaned tuples from OpenFGA. +// CleanupModelsDying triggers every `trigger` time and calls the jimm methods to cleanup dying models. func (s *Service) CleanupModelsDying(ctx context.Context, trigger <-chan time.Time) error { for { select { case <-trigger: err := s.jimm.CleanupModelsDying(ctx) if err != nil { - zapctx.Error(ctx, "openfga cleanup", zap.Error(err)) + zapctx.Error(ctx, "dying models cleanup", zap.Error(err)) continue } case <-ctx.Done(): diff --git a/internal/jimm/model_cleanup.go b/internal/jimm/model_cleanup.go index 2ceabee8f..bcfac00d7 100644 --- a/internal/jimm/model_cleanup.go +++ b/internal/jimm/model_cleanup.go @@ -1,4 +1,5 @@ // Copyright 2024 Canonical. + package jimm import ( @@ -14,6 +15,8 @@ import ( "github.com/canonical/jimm/v3/internal/errors" ) +// CleanupModelsDying loops over dying models, contacting the respective controller. +// And deleting the model from our database if the error is `NotFound` which means the model was successfully deleted. func (j *JIMM) CleanupModelsDying(ctx context.Context) error { const op = errors.Op("jimm.WatchModelsDying")