Manage status for TCP element in the endpoint overview.

This commit is contained in:
Ludovic Fernandez 2019-07-18 15:56:04 +02:00 committed by Traefiker Bot
parent 75aedc8e94
commit 68c349bbfa
6 changed files with 108 additions and 11 deletions

View file

@ -115,30 +115,38 @@ func getHTTPMiddlewareSection(middlewares map[string]*runtime.MiddlewareInfo) *s
func getTCPRouterSection(routers map[string]*runtime.TCPRouterInfo) *section { func getTCPRouterSection(routers map[string]*runtime.TCPRouterInfo) *section {
var countErrors int var countErrors int
var countWarnings int
for _, rt := range routers { for _, rt := range routers {
if rt.Err != "" { switch rt.Status {
case runtime.StatusDisabled:
countErrors++ countErrors++
case runtime.StatusWarning:
countWarnings++
} }
} }
return &section{ return &section{
Total: len(routers), Total: len(routers),
Warnings: 0, // TODO Warnings: countWarnings,
Errors: countErrors, Errors: countErrors,
} }
} }
func getTCPServiceSection(services map[string]*runtime.TCPServiceInfo) *section { func getTCPServiceSection(services map[string]*runtime.TCPServiceInfo) *section {
var countErrors int var countErrors int
var countWarnings int
for _, svc := range services { for _, svc := range services {
if svc.Err != nil { switch svc.Status {
case runtime.StatusDisabled:
countErrors++ countErrors++
case runtime.StatusWarning:
countWarnings++
} }
} }
return &section{ return &section{
Total: len(services), Total: len(services),
Warnings: 0, // TODO Warnings: countWarnings,
Errors: countErrors, Errors: countErrors,
} }
} }

View file

@ -142,6 +142,31 @@ func TestHandler_Overview(t *testing.T) {
}, },
}, },
}, },
Status: runtime.StatusEnabled,
},
"tcpbar-service@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "127.0.0.2",
},
},
},
},
Status: runtime.StatusWarning,
},
"tcpfii-service@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "127.0.0.2",
},
},
},
},
Status: runtime.StatusDisabled,
}, },
}, },
TCPRouters: map[string]*runtime.TCPRouterInfo{ TCPRouters: map[string]*runtime.TCPRouterInfo{
@ -151,6 +176,7 @@ func TestHandler_Overview(t *testing.T) {
Service: "tcpfoo-service@myprovider", Service: "tcpfoo-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
Status: runtime.StatusEnabled,
}, },
"tcptest@myprovider": { "tcptest@myprovider": {
TCPRouter: &dynamic.TCPRouter{ TCPRouter: &dynamic.TCPRouter{
@ -158,6 +184,15 @@ func TestHandler_Overview(t *testing.T) {
Service: "tcpfoo-service@myprovider", Service: "tcpfoo-service@myprovider",
Rule: "HostSNI(`foo.bar.other`)", Rule: "HostSNI(`foo.bar.other`)",
}, },
Status: runtime.StatusWarning,
},
"tcpfoo@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
Service: "tcpfoo-service@myprovider",
Rule: "HostSNI(`foo.bar.other`)",
},
Status: runtime.StatusDisabled,
}, },
}, },
}, },

View file

@ -52,6 +52,7 @@ func TestHandler_TCP(t *testing.T) {
Passthrough: false, Passthrough: false,
}, },
}, },
Status: runtime.StatusEnabled,
}, },
"bar@myprovider": { "bar@myprovider": {
TCPRouter: &dynamic.TCPRouter{ TCPRouter: &dynamic.TCPRouter{
@ -59,6 +60,15 @@ func TestHandler_TCP(t *testing.T) {
Service: "foo-service@myprovider", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
Status: runtime.StatusWarning,
},
"foo@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)",
},
Status: runtime.StatusDisabled,
}, },
}, },
}, },
@ -173,6 +183,7 @@ func TestHandler_TCP(t *testing.T) {
}, },
}, },
UsedBy: []string{"foo@myprovider", "test@myprovider"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
Status: runtime.StatusEnabled,
}, },
"baz@myprovider": { "baz@myprovider": {
TCPService: &dynamic.TCPService{ TCPService: &dynamic.TCPService{
@ -185,6 +196,20 @@ func TestHandler_TCP(t *testing.T) {
}, },
}, },
UsedBy: []string{"foo@myprovider"}, UsedBy: []string{"foo@myprovider"},
Status: runtime.StatusWarning,
},
"foz@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "127.0.0.2:2345",
},
},
},
},
UsedBy: []string{"foo@myprovider"},
Status: runtime.StatusDisabled,
}, },
}, },
}, },

View file

@ -23,14 +23,14 @@
}, },
"tcp": { "tcp": {
"routers": { "routers": {
"errors": 0, "errors": 1,
"total": 2, "total": 3,
"warnings": 0 "warnings": 1
}, },
"services": { "services": {
"errors": 0, "errors": 1,
"total": 1, "total": 3,
"warnings": 0 "warnings": 1
} }
} }
} }

View file

@ -6,7 +6,18 @@
"name": "bar@myprovider", "name": "bar@myprovider",
"provider": "myprovider", "provider": "myprovider",
"rule": "Host(`foo.bar`)", "rule": "Host(`foo.bar`)",
"service": "foo-service@myprovider" "service": "foo-service@myprovider",
"status": "warning"
},
{
"entryPoints": [
"web"
],
"name": "foo@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar`)",
"service": "foo-service@myprovider",
"status": "disabled"
}, },
{ {
"entryPoints": [ "entryPoints": [
@ -16,6 +27,7 @@
"provider": "myprovider", "provider": "myprovider",
"rule": "Host(`foo.bar.other`)", "rule": "Host(`foo.bar.other`)",
"service": "foo-service@myprovider", "service": "foo-service@myprovider",
"status": "enabled",
"tls": { "tls": {
"passthrough": false "passthrough": false
} }

View file

@ -9,6 +9,7 @@
}, },
"name": "bar@myprovider", "name": "bar@myprovider",
"provider": "myprovider", "provider": "myprovider",
"status": "enabled",
"usedBy": [ "usedBy": [
"foo@myprovider", "foo@myprovider",
"test@myprovider" "test@myprovider"
@ -24,6 +25,22 @@
}, },
"name": "baz@myprovider", "name": "baz@myprovider",
"provider": "myprovider", "provider": "myprovider",
"status": "warning",
"usedBy": [
"foo@myprovider"
]
},
{
"loadBalancer": {
"servers": [
{
"address": "127.0.0.2:2345"
}
]
},
"name": "foz@myprovider",
"provider": "myprovider",
"status": "disabled",
"usedBy": [ "usedBy": [
"foo@myprovider" "foo@myprovider"
] ]