From f45e8db5c4b0d586a5e68da5e95d414687565a2c Mon Sep 17 00:00:00 2001 From: Daisuke Iuchi <42408108+da1suk8@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:17:43 +0900 Subject: [PATCH] fix(service): don't panic in UpdateIngress and DeleteIngress without redis (#5227) --- pkg/service/ingress.go | 6 ++++-- pkg/service/ingress_test.go | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/pkg/service/ingress.go b/pkg/service/ingress.go index a4abb641b..8fa32d907 100644 --- a/pkg/service/ingress.go +++ b/pkg/service/ingress.go @@ -300,7 +300,8 @@ func (s *IngressService) UpdateIngress(ctx context.Context, req *livekit.UpdateI return nil, twirpAuthError(err) } - if s.psrpcClient == nil { + // without redis there is a client, on the local message bus, but no store + if s.psrpcClient == nil || s.store == nil { return nil, ErrIngressNotConnected } @@ -395,7 +396,8 @@ func (s *IngressService) DeleteIngress(ctx context.Context, req *livekit.DeleteI return nil, twirpAuthError(err) } - if s.psrpcClient == nil { + // without redis there is a client, on the local message bus, but no store + if s.psrpcClient == nil || s.store == nil { return nil, ErrIngressNotConnected } diff --git a/pkg/service/ingress_test.go b/pkg/service/ingress_test.go index f391e4482..dcc36cb7f 100644 --- a/pkg/service/ingress_test.go +++ b/pkg/service/ingress_test.go @@ -155,3 +155,41 @@ func TestIngressAPIWithNilState(t *testing.T) { require.Equal(t, 1, store.DeleteIngressCallCount()) }) } + +// Without redis there is no ingress store (see getIngressStore), but there is an +// ingress client, on the local message bus. Every ingress API must answer +// ErrIngressNotConnected there instead of reaching for the store. +func TestIngressAPIWithoutStore(t *testing.T) { + svc := service.NewIngressServiceWithIngressLauncher( + &config.IngressConfig{}, + "nodeID", + nil, + unusedIngressClient{}, + nil, + &servicefakes.FakeIOClient{}, + &telemetryfakes.FakeTelemetryService{}, + &servicefakes.FakeIngressLauncher{}, + ) + + adminCtx := service.WithGrants(context.Background(), &auth.ClaimGrants{Video: &auth.VideoGrant{IngressAdmin: true}}, "") + + t.Run("CreateIngress", func(t *testing.T) { + _, err := svc.CreateIngress(adminCtx, &livekit.CreateIngressRequest{InputType: livekit.IngressInput_RTMP_INPUT}) + require.ErrorIs(t, err, service.ErrIngressNotConnected) + }) + + t.Run("ListIngress", func(t *testing.T) { + _, err := svc.ListIngress(adminCtx, &livekit.ListIngressRequest{}) + require.ErrorIs(t, err, service.ErrIngressNotConnected) + }) + + t.Run("UpdateIngress", func(t *testing.T) { + _, err := svc.UpdateIngress(adminCtx, &livekit.UpdateIngressRequest{IngressId: "IN_test"}) + require.ErrorIs(t, err, service.ErrIngressNotConnected) + }) + + t.Run("DeleteIngress", func(t *testing.T) { + _, err := svc.DeleteIngress(adminCtx, &livekit.DeleteIngressRequest{IngressId: "IN_test"}) + require.ErrorIs(t, err, service.ErrIngressNotConnected) + }) +}