From bac107a7df617ecaf4e16ec8fac61ffdd166e0c3 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Fri, 19 Dec 2025 22:33:05 +0100 Subject: [PATCH] Start IAM service Signed-off-by: Bryan Frimin --- pkg/iam/service.go | 24 ++++++++++++++++++++++++ pkg/probod/probod.go | 12 ++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/pkg/iam/service.go b/pkg/iam/service.go index 4b27b224c..b864e89d5 100644 --- a/pkg/iam/service.go +++ b/pkg/iam/service.go @@ -125,6 +125,30 @@ func NewService( return svc, nil } +func (s *Service) Run(ctx context.Context) error { + runCtx, stopAll := context.WithCancel(ctx) + defer stopAll() + + errCh := make(chan error, 1) + go func() { + errCh <- s.SAMLService.Run(runCtx) + }() + + select { + case <-ctx.Done(): + stopAll() + <-errCh + return ctx.Err() + case err := <-errCh: + if err != nil { + s.logger.ErrorCtx(ctx, "iam service failed", log.Error(err)) + return err + } + + return nil + } +} + func (s *Service) GetMembership(ctx context.Context, membershipID gid.GID) (*coredata.Membership, error) { var ( scope = coredata.NewScopeFromObjectID(membershipID) diff --git a/pkg/probod/probod.go b/pkg/probod/probod.go index b2c724409..9bdf6af55 100644 --- a/pkg/probod/probod.go +++ b/pkg/probod/probod.go @@ -491,14 +491,14 @@ func (impl *Implm) Run( }, ) - samlServiceCtx, stopSAMLService := context.WithCancel(context.Background()) + iamServiceCtx, stopIAMService := context.WithCancel(context.Background()) wg.Go( func() { - if iamService.SAMLService != nil { - if err := iamService.SAMLService.Run(samlServiceCtx); err != nil { - cancel(fmt.Errorf("saml service crashed: %w", err)) - } + + if err := iamService.Run(iamServiceCtx); err != nil { + cancel(fmt.Errorf("iam service crashed: %w", err)) } + }, ) @@ -517,7 +517,7 @@ func (impl *Implm) Run( stopMailer() stopSlackSender() stopExportJobExporter() - stopSAMLService() + stopIAMService() stopApiServer() stopTrustCenterServer()