Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(internal/jimm/jimm.go): introduces a jimm constructor #1468

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/jimmctl/cmd/relation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func initializeEnvironment(c *gc.C, ctx context.Context, db *db.Database, u dbmo
}

func (s *relationSuite) TestListRelations(c *gc.C) {
env := initializeEnvironment(c, context.Background(), &s.JIMM.Database, *s.AdminUser)
env := initializeEnvironment(c, context.Background(), s.JIMM.Database, *s.AdminUser)
bClient := s.SetupCLIAccess(c, "alice") // alice is superuser

relations := []apiparams.RelationshipTuple{{
Expand Down Expand Up @@ -420,7 +420,7 @@ func (s *relationSuite) TestListRelations(c *gc.C) {
}

func (s *relationSuite) TestListRelationsWithError(c *gc.C) {
env := initializeEnvironment(c, context.Background(), &s.JIMM.Database, *s.AdminUser)
env := initializeEnvironment(c, context.Background(), s.JIMM.Database, *s.AdminUser)
// alice is superuser
bClient := s.SetupCLIAccess(c, "alice")

Expand Down
26 changes: 2 additions & 24 deletions cmd/jimmsrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,35 +183,13 @@ func start(ctx context.Context, s *service.Service) error {
CorsAllowedOrigins: corsAllowedOrigins,
LogSQL: logSQL,
LogLevel: logLevel,
IsLeader: os.Getenv("JIMM_IS_LEADER") != "",
})
if err != nil {
return err
}

isLeader := os.Getenv("JIMM_IS_LEADER") != ""
if isLeader {
s.Go(func() error { return jimmsvc.WatchControllers(ctx) }) // Deletes dead/dying models, updates model config.
}
s.Go(func() error { return jimmsvc.WatchModelSummaries(ctx) })

if isLeader {
zapctx.Info(ctx, "attempting to start JWKS rotator and generate OAuth secret key")
s.Go(func() error {
if err := jimmsvc.StartJWKSRotator(ctx, time.NewTicker(time.Hour).C, time.Now().UTC().AddDate(0, 3, 0)); err != nil {
zapctx.Error(ctx, "failed to start JWKS rotator", zap.Error(err))
return err
}
return nil
})
s.Go(func() error {
return jimmsvc.OpenFGACleanup(ctx, time.NewTicker(6*time.Hour).C)
})
}

if isLeader {
// No need for s.Go() since this routine doesn't return an error.
go jimmsvc.MonitorResources(ctx)
}
jimmsvc.StartServices(ctx, s)

httpsrv := &http.Server{
Addr: addr,
Expand Down
Loading
Loading