Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 gateway/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ func (gw *Gateway) isCriticalFailure(component string) bool {
return true
}

// Consider RPC critical only if using RPC and gw not in emergency mode
if component == "rpc" && gw.GetConfig().Policies.PolicySource == "rpc" && !rpc.IsEmergencyMode() {
// Consider RPC critical only if using RPC
if component == "rpc" && gw.GetConfig().Policies.PolicySource == "rpc" {
return true
}

Expand Down
38 changes: 0 additions & 38 deletions gateway/health_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/TykTechnologies/tyk/apidef"
"github.com/TykTechnologies/tyk/config"
"github.com/TykTechnologies/tyk/rpc"
"github.com/TykTechnologies/tyk/storage"
)

Expand Down Expand Up @@ -355,7 +354,6 @@ func TestGateway_isCriticalFailure(t *testing.T) {
component string
check HealthCheckItem
setupConfig func(*config.Config)
setupFunc func(*testing.T)
expectedResult bool
}{
{
Expand Down Expand Up @@ -458,49 +456,13 @@ func TestGateway_isCriticalFailure(t *testing.T) {
},
expectedResult: true, // Critical based on component and config, not status
},
{
name: "rpc component is NOT critical when PolicySource is rpc but in emergency mode",
component: "rpc",
check: HealthCheckItem{
Status: Fail,
ComponentType: System,
},
setupConfig: func(conf *config.Config) {
conf.Policies.PolicySource = "rpc"
},
setupFunc: func(t *testing.T) {
rpc.SetEmergencyMode(t, true)
},
expectedResult: false,
},
{
name: "rpc component is critical when PolicySource is rpc and NOT in emergency mode",
component: "rpc",
check: HealthCheckItem{
Status: Fail,
ComponentType: System,
},
setupConfig: func(conf *config.Config) {
conf.Policies.PolicySource = "rpc"
},
setupFunc: func(t *testing.T) {
rpc.SetEmergencyMode(t, false)
},
expectedResult: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create a new gateway instance for each test
conf := config.Config{}
tt.setupConfig(&conf)

// Setup emergency mode if needed
if tt.setupFunc != nil {
tt.setupFunc(t)
}

gw := NewGateway(conf, nil)

// Call the function under test
Expand Down
Loading