fix(service): don't panic in UpdateIngress and DeleteIngress without redis (#5227)

This commit is contained in:
Daisuke Iuchi authored and GitHub committed 2026-11-16 18:17:43 -08:00
1 parent 6e289a118e
commit f45e8db5c4
2 files changed
+42 -2

No files matched your search

+4 -2
View File
@@ -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
}
+38
View File
@@ -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)
})
}