Skip to content

Commit

Permalink
fix minor
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneDutto committed Dec 4, 2024
1 parent 7417251 commit 2cd933f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/jimmsrv/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 3 additions & 0 deletions internal/jimm/model_cleanup.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2024 Canonical.

package jimm

import (
Expand All @@ -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")

Expand Down

0 comments on commit 2cd933f

Please sign in to comment.