1
0
Fork 0

config: deal with multiple errors and their criticality

Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
mpl 2019-07-15 17:04:04 +02:00 committed by Traefiker Bot
parent 62800116d3
commit 6fdd48509e
45 changed files with 725 additions and 412 deletions

View file

@ -8,7 +8,7 @@ import (
"strings"
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/containous/traefik/pkg/log"
"github.com/containous/traefik/pkg/types"
@ -24,17 +24,17 @@ const (
const nextPageHeader = "X-Next-Page"
type serviceInfoRepresentation struct {
*dynamic.ServiceInfo
*runtime.ServiceInfo
ServerStatus map[string]string `json:"serverStatus,omitempty"`
}
// RunTimeRepresentation is the configuration information exposed by the API handler.
type RunTimeRepresentation struct {
Routers map[string]*dynamic.RouterInfo `json:"routers,omitempty"`
Middlewares map[string]*dynamic.MiddlewareInfo `json:"middlewares,omitempty"`
Routers map[string]*runtime.RouterInfo `json:"routers,omitempty"`
Middlewares map[string]*runtime.MiddlewareInfo `json:"middlewares,omitempty"`
Services map[string]*serviceInfoRepresentation `json:"services,omitempty"`
TCPRouters map[string]*dynamic.TCPRouterInfo `json:"tcpRouters,omitempty"`
TCPServices map[string]*dynamic.TCPServiceInfo `json:"tcpServices,omitempty"`
TCPRouters map[string]*runtime.TCPRouterInfo `json:"tcpRouters,omitempty"`
TCPServices map[string]*runtime.TCPServiceInfo `json:"tcpServices,omitempty"`
}
type pageInfo struct {
@ -48,7 +48,7 @@ type Handler struct {
dashboard bool
debug bool
// runtimeConfiguration is the data set used to create all the data representations exposed by the API.
runtimeConfiguration *dynamic.RuntimeConfiguration
runtimeConfiguration *runtime.Configuration
staticConfig static.Configuration
statistics *types.Statistics
// stats *thoasstats.Stats // FIXME stats
@ -58,10 +58,10 @@ type Handler struct {
// New returns a Handler defined by staticConfig, and if provided, by runtimeConfig.
// It finishes populating the information provided in the runtimeConfig.
func New(staticConfig static.Configuration, runtimeConfig *dynamic.RuntimeConfiguration) *Handler {
func New(staticConfig static.Configuration, runtimeConfig *runtime.Configuration) *Handler {
rConfig := runtimeConfig
if rConfig == nil {
rConfig = &dynamic.RuntimeConfiguration{}
rConfig = &runtime.Configuration{}
}
return &Handler{

View file

@ -10,7 +10,7 @@ import (
"testing"
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -198,7 +198,7 @@ func TestHandler_EntryPoints(t *testing.T) {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
handler := New(test.conf, &dynamic.RuntimeConfiguration{})
handler := New(test.conf, &runtime.Configuration{})
router := mux.NewRouter()
handler.Append(router)

View file

@ -7,25 +7,25 @@ import (
"strconv"
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/log"
)
type routerRepresentation struct {
*dynamic.RouterInfo
*runtime.RouterInfo
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
}
type serviceRepresentation struct {
*dynamic.ServiceInfo
*runtime.ServiceInfo
ServerStatus map[string]string `json:"serverStatus,omitempty"`
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
}
type middlewareRepresentation struct {
*dynamic.MiddlewareInfo
*runtime.MiddlewareInfo
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
}

View file

@ -11,6 +11,7 @@ import (
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -26,13 +27,13 @@ func TestHandler_HTTP(t *testing.T) {
testCases := []struct {
desc string
path string
conf dynamic.RuntimeConfiguration
conf runtime.Configuration
expected expected
}{
{
desc: "all routers, but no config",
path: "/api/http/routers",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
nextPage: "1",
@ -42,8 +43,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all routers",
path: "/api/http/routers",
conf: dynamic.RuntimeConfiguration{
Routers: map[string]*dynamic.RouterInfo{
conf: runtime.Configuration{
Routers: map[string]*runtime.RouterInfo{
"test@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -71,8 +72,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all routers, pagination, 1 res per page, want page 2",
path: "/api/http/routers?page=2&per_page=1",
conf: dynamic.RuntimeConfiguration{
Routers: map[string]*dynamic.RouterInfo{
conf: runtime.Configuration{
Routers: map[string]*runtime.RouterInfo{
"bar@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -107,7 +108,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all routers, pagination, 19 results overall, 7 res per page, want page 3",
path: "/api/http/routers?page=3&per_page=7",
conf: dynamic.RuntimeConfiguration{
conf: runtime.Configuration{
Routers: generateHTTPRouters(19),
},
expected: expected{
@ -119,7 +120,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all routers, pagination, 5 results overall, 10 res per page, want page 2",
path: "/api/http/routers?page=2&per_page=10",
conf: dynamic.RuntimeConfiguration{
conf: runtime.Configuration{
Routers: generateHTTPRouters(5),
},
expected: expected{
@ -129,7 +130,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all routers, pagination, 10 results overall, 10 res per page, want page 2",
path: "/api/http/routers?page=2&per_page=10",
conf: dynamic.RuntimeConfiguration{
conf: runtime.Configuration{
Routers: generateHTTPRouters(10),
},
expected: expected{
@ -139,8 +140,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one router by id",
path: "/api/http/routers/bar@myprovider",
conf: dynamic.RuntimeConfiguration{
Routers: map[string]*dynamic.RouterInfo{
conf: runtime.Configuration{
Routers: map[string]*runtime.RouterInfo{
"bar@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -148,6 +149,7 @@ func TestHandler_HTTP(t *testing.T) {
Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
},
Status: "enabled",
},
},
},
@ -159,8 +161,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one router by id, that does not exist",
path: "/api/http/routers/foo@myprovider",
conf: dynamic.RuntimeConfiguration{
Routers: map[string]*dynamic.RouterInfo{
conf: runtime.Configuration{
Routers: map[string]*runtime.RouterInfo{
"bar@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -178,7 +180,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one router by id, but no config",
path: "/api/http/routers/foo@myprovider",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusNotFound,
},
@ -186,7 +188,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all services, but no config",
path: "/api/http/services",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
nextPage: "1",
@ -196,10 +198,10 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all services",
path: "/api/http/services",
conf: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
"bar@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
conf: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"bar@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -211,11 +213,11 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider", "test@myprovider"},
}
si.UpdateStatus("http://127.0.0.1", "UP")
si.UpdateServerStatus("http://127.0.0.1", "UP")
return si
}(),
"baz@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
"baz@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -227,7 +229,7 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider"},
}
si.UpdateStatus("http://127.0.0.2", "UP")
si.UpdateServerStatus("http://127.0.0.2", "UP")
return si
}(),
},
@ -241,10 +243,10 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all services, 1 res per page, want page 2",
path: "/api/http/services?page=2&per_page=1",
conf: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
"bar@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
conf: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"bar@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -256,11 +258,11 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider", "test@myprovider"},
}
si.UpdateStatus("http://127.0.0.1", "UP")
si.UpdateServerStatus("http://127.0.0.1", "UP")
return si
}(),
"baz@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
"baz@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -272,11 +274,11 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider"},
}
si.UpdateStatus("http://127.0.0.2", "UP")
si.UpdateServerStatus("http://127.0.0.2", "UP")
return si
}(),
"test@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
"test@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -288,7 +290,7 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider", "test@myprovider"},
}
si.UpdateStatus("http://127.0.0.4", "UP")
si.UpdateServerStatus("http://127.0.0.4", "UP")
return si
}(),
},
@ -302,10 +304,10 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one service by id",
path: "/api/http/services/bar@myprovider",
conf: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
"bar@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
conf: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"bar@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -317,7 +319,7 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider", "test@myprovider"},
}
si.UpdateStatus("http://127.0.0.1", "UP")
si.UpdateServerStatus("http://127.0.0.1", "UP")
return si
}(),
},
@ -330,10 +332,10 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one service by id, that does not exist",
path: "/api/http/services/nono@myprovider",
conf: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
"bar@myprovider": func() *dynamic.ServiceInfo {
si := &dynamic.ServiceInfo{
conf: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"bar@myprovider": func() *runtime.ServiceInfo {
si := &runtime.ServiceInfo{
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
@ -345,7 +347,7 @@ func TestHandler_HTTP(t *testing.T) {
},
UsedBy: []string{"foo@myprovider", "test@myprovider"},
}
si.UpdateStatus("http://127.0.0.1", "UP")
si.UpdateServerStatus("http://127.0.0.1", "UP")
return si
}(),
},
@ -357,7 +359,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one service by id, but no config",
path: "/api/http/services/foo@myprovider",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusNotFound,
},
@ -365,7 +367,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all middlewares, but no config",
path: "/api/http/middlewares",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
nextPage: "1",
@ -375,8 +377,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all middlewares",
path: "/api/http/middlewares",
conf: dynamic.RuntimeConfiguration{
Middlewares: map[string]*dynamic.MiddlewareInfo{
conf: runtime.Configuration{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -412,8 +414,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "all middlewares, 1 res per page, want page 2",
path: "/api/http/middlewares?page=2&per_page=1",
conf: dynamic.RuntimeConfiguration{
Middlewares: map[string]*dynamic.MiddlewareInfo{
conf: runtime.Configuration{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -449,8 +451,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one middleware by id",
path: "/api/http/middlewares/auth@myprovider",
conf: dynamic.RuntimeConfiguration{
Middlewares: map[string]*dynamic.MiddlewareInfo{
conf: runtime.Configuration{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -485,8 +487,8 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one middleware by id, that does not exist",
path: "/api/http/middlewares/foo@myprovider",
conf: dynamic.RuntimeConfiguration{
Middlewares: map[string]*dynamic.MiddlewareInfo{
conf: runtime.Configuration{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -504,7 +506,7 @@ func TestHandler_HTTP(t *testing.T) {
{
desc: "one middleware by id, but no config",
path: "/api/http/middlewares/foo@myprovider",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusNotFound,
},
@ -517,6 +519,8 @@ func TestHandler_HTTP(t *testing.T) {
t.Parallel()
rtConf := &test.conf
// To lazily initialize the Statuses.
rtConf.PopulateUsedBy()
handler := New(static.Configuration{API: &static.API{}, Global: &static.Global{}}, rtConf)
router := mux.NewRouter()
handler.Append(router)
@ -560,10 +564,10 @@ func TestHandler_HTTP(t *testing.T) {
}
}
func generateHTTPRouters(nbRouters int) map[string]*dynamic.RouterInfo {
routers := make(map[string]*dynamic.RouterInfo, nbRouters)
func generateHTTPRouters(nbRouters int) map[string]*runtime.RouterInfo {
routers := make(map[string]*runtime.RouterInfo, nbRouters)
for i := 0; i < nbRouters; i++ {
routers[fmt.Sprintf("bar%2d@myprovider", i)] = &dynamic.RouterInfo{
routers[fmt.Sprintf("bar%2d@myprovider", i)] = &runtime.RouterInfo{
Router: &dynamic.Router{
EntryPoints: []string{"web"},
Service: "foo-service@myprovider",

View file

@ -5,7 +5,7 @@ import (
"net/http"
"reflect"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/containous/traefik/pkg/log"
)
@ -60,37 +60,45 @@ func (h Handler) getOverview(rw http.ResponseWriter, request *http.Request) {
}
}
func getHTTPRouterSection(routers map[string]*dynamic.RouterInfo) *section {
func getHTTPRouterSection(routers map[string]*runtime.RouterInfo) *section {
var countErrors int
var countWarnings int
for _, rt := range routers {
if rt.Err != "" {
switch rt.Status {
case runtime.StatusDisabled:
countErrors++
case runtime.StatusWarning:
countWarnings++
}
}
return &section{
Total: len(routers),
Warnings: 0, // TODO
Warnings: countWarnings,
Errors: countErrors,
}
}
func getHTTPServiceSection(services map[string]*dynamic.ServiceInfo) *section {
func getHTTPServiceSection(services map[string]*runtime.ServiceInfo) *section {
var countErrors int
var countWarnings int
for _, svc := range services {
if svc.Err != nil {
switch svc.Status {
case runtime.StatusDisabled:
countErrors++
case runtime.StatusWarning:
countWarnings++
}
}
return &section{
Total: len(services),
Warnings: 0, // TODO
Warnings: countWarnings,
Errors: countErrors,
}
}
func getHTTPMiddlewareSection(middlewares map[string]*dynamic.MiddlewareInfo) *section {
func getHTTPMiddlewareSection(middlewares map[string]*runtime.MiddlewareInfo) *section {
var countErrors int
for _, md := range middlewares {
if md.Err != nil {
@ -100,12 +108,12 @@ func getHTTPMiddlewareSection(middlewares map[string]*dynamic.MiddlewareInfo) *s
return &section{
Total: len(middlewares),
Warnings: 0, // TODO
Warnings: 0,
Errors: countErrors,
}
}
func getTCPRouterSection(routers map[string]*dynamic.TCPRouterInfo) *section {
func getTCPRouterSection(routers map[string]*runtime.TCPRouterInfo) *section {
var countErrors int
for _, rt := range routers {
if rt.Err != "" {
@ -120,7 +128,7 @@ func getTCPRouterSection(routers map[string]*dynamic.TCPRouterInfo) *section {
}
}
func getTCPServiceSection(services map[string]*dynamic.TCPServiceInfo) *section {
func getTCPServiceSection(services map[string]*runtime.TCPServiceInfo) *section {
var countErrors int
for _, svc := range services {
if svc.Err != nil {

View file

@ -9,6 +9,7 @@ import (
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/containous/traefik/pkg/provider/docker"
"github.com/containous/traefik/pkg/provider/file"
@ -33,14 +34,14 @@ func TestHandler_Overview(t *testing.T) {
desc string
path string
confStatic static.Configuration
confDyn dynamic.RuntimeConfiguration
confDyn runtime.Configuration
expected expected
}{
{
desc: "without data in the dynamic configuration",
path: "/api/overview",
confStatic: static.Configuration{API: &static.API{}, Global: &static.Global{}},
confDyn: dynamic.RuntimeConfiguration{},
confDyn: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
jsonFile: "testdata/overview-empty.json",
@ -50,21 +51,34 @@ func TestHandler_Overview(t *testing.T) {
desc: "with data in the dynamic configuration",
path: "/api/overview",
confStatic: static.Configuration{API: &static.API{}, Global: &static.Global{}},
confDyn: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
confDyn: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"foo-service@myprovider": {
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{
{
URL: "http://127.0.0.1",
},
},
Servers: []dynamic.Server{{URL: "http://127.0.0.1"}},
},
},
Status: runtime.StatusEnabled,
},
"bar-service@myprovider": {
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{{URL: "http://127.0.0.1"}},
},
},
Status: runtime.StatusWarning,
},
"fii-service@myprovider": {
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
Servers: []dynamic.Server{{URL: "http://127.0.0.1"}},
},
},
Status: runtime.StatusDisabled,
},
},
Middlewares: map[string]*dynamic.MiddlewareInfo{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -85,9 +99,10 @@ func TestHandler_Overview(t *testing.T) {
Prefix: "/toto",
},
},
Err: []string{"error"},
},
},
Routers: map[string]*dynamic.RouterInfo{
Routers: map[string]*runtime.RouterInfo{
"bar@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -95,6 +110,7 @@ func TestHandler_Overview(t *testing.T) {
Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
},
Status: runtime.StatusEnabled,
},
"test@myprovider": {
Router: &dynamic.Router{
@ -103,9 +119,19 @@ func TestHandler_Overview(t *testing.T) {
Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"},
},
Status: runtime.StatusWarning,
},
"foo@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"},
},
Status: runtime.StatusDisabled,
},
},
TCPServices: map[string]*dynamic.TCPServiceInfo{
TCPServices: map[string]*runtime.TCPServiceInfo{
"tcpfoo-service@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -118,7 +144,7 @@ func TestHandler_Overview(t *testing.T) {
},
},
},
TCPRouters: map[string]*dynamic.TCPRouterInfo{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"tcpbar@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
@ -156,7 +182,7 @@ func TestHandler_Overview(t *testing.T) {
Rancher: &rancher.Provider{},
},
},
confDyn: dynamic.RuntimeConfiguration{},
confDyn: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
jsonFile: "testdata/overview-providers.json",
@ -175,7 +201,7 @@ func TestHandler_Overview(t *testing.T) {
Jaeger: &jaeger.Config{},
},
},
confDyn: dynamic.RuntimeConfiguration{},
confDyn: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
jsonFile: "testdata/overview-features.json",

View file

@ -7,18 +7,18 @@ import (
"strconv"
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/log"
)
type tcpRouterRepresentation struct {
*dynamic.TCPRouterInfo
*runtime.TCPRouterInfo
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
}
type tcpServiceRepresentation struct {
*dynamic.TCPServiceInfo
*runtime.TCPServiceInfo
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
}

View file

@ -9,6 +9,7 @@ import (
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -24,13 +25,13 @@ func TestHandler_TCP(t *testing.T) {
testCases := []struct {
desc string
path string
conf dynamic.RuntimeConfiguration
conf runtime.Configuration
expected expected
}{
{
desc: "all TCP routers, but no config",
path: "/api/tcp/routers",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
nextPage: "1",
@ -40,8 +41,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "all TCP routers",
path: "/api/tcp/routers",
conf: dynamic.RuntimeConfiguration{
TCPRouters: map[string]*dynamic.TCPRouterInfo{
conf: runtime.Configuration{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"test@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
@ -70,8 +71,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "all TCP routers, pagination, 1 res per page, want page 2",
path: "/api/tcp/routers?page=2&per_page=1",
conf: dynamic.RuntimeConfiguration{
TCPRouters: map[string]*dynamic.TCPRouterInfo{
conf: runtime.Configuration{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"bar@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
@ -104,8 +105,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one TCP router by id",
path: "/api/tcp/routers/bar@myprovider",
conf: dynamic.RuntimeConfiguration{
TCPRouters: map[string]*dynamic.TCPRouterInfo{
conf: runtime.Configuration{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"bar@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
@ -123,8 +124,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one TCP router by id, that does not exist",
path: "/api/tcp/routers/foo@myprovider",
conf: dynamic.RuntimeConfiguration{
TCPRouters: map[string]*dynamic.TCPRouterInfo{
conf: runtime.Configuration{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"bar@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},
@ -141,7 +142,7 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one TCP router by id, but no config",
path: "/api/tcp/routers/bar@myprovider",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusNotFound,
},
@ -149,7 +150,7 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "all tcp services, but no config",
path: "/api/tcp/services",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusOK,
nextPage: "1",
@ -159,8 +160,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "all tcp services",
path: "/api/tcp/services",
conf: dynamic.RuntimeConfiguration{
TCPServices: map[string]*dynamic.TCPServiceInfo{
conf: runtime.Configuration{
TCPServices: map[string]*runtime.TCPServiceInfo{
"bar@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -196,8 +197,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "all tcp services, 1 res per page, want page 2",
path: "/api/tcp/services?page=2&per_page=1",
conf: dynamic.RuntimeConfiguration{
TCPServices: map[string]*dynamic.TCPServiceInfo{
conf: runtime.Configuration{
TCPServices: map[string]*runtime.TCPServiceInfo{
"bar@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -244,8 +245,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one tcp service by id",
path: "/api/tcp/services/bar@myprovider",
conf: dynamic.RuntimeConfiguration{
TCPServices: map[string]*dynamic.TCPServiceInfo{
conf: runtime.Configuration{
TCPServices: map[string]*runtime.TCPServiceInfo{
"bar@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -268,8 +269,8 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one tcp service by id, that does not exist",
path: "/api/tcp/services/nono@myprovider",
conf: dynamic.RuntimeConfiguration{
TCPServices: map[string]*dynamic.TCPServiceInfo{
conf: runtime.Configuration{
TCPServices: map[string]*runtime.TCPServiceInfo{
"bar@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -291,7 +292,7 @@ func TestHandler_TCP(t *testing.T) {
{
desc: "one tcp service by id, but no config",
path: "/api/tcp/services/foo@myprovider",
conf: dynamic.RuntimeConfiguration{},
conf: runtime.Configuration{},
expected: expected{
statusCode: http.StatusNotFound,
},

View file

@ -10,6 +10,7 @@ import (
"github.com/containous/mux"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/config/runtime"
"github.com/containous/traefik/pkg/config/static"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -26,14 +27,14 @@ func TestHandler_RawData(t *testing.T) {
testCases := []struct {
desc string
path string
conf dynamic.RuntimeConfiguration
conf runtime.Configuration
expected expected
}{
{
desc: "Get rawdata",
path: "/api/rawdata",
conf: dynamic.RuntimeConfiguration{
Services: map[string]*dynamic.ServiceInfo{
conf: runtime.Configuration{
Services: map[string]*runtime.ServiceInfo{
"foo-service@myprovider": {
Service: &dynamic.Service{
LoadBalancer: &dynamic.LoadBalancerService{
@ -46,7 +47,7 @@ func TestHandler_RawData(t *testing.T) {
},
},
},
Middlewares: map[string]*dynamic.MiddlewareInfo{
Middlewares: map[string]*runtime.MiddlewareInfo{
"auth@myprovider": {
Middleware: &dynamic.Middleware{
BasicAuth: &dynamic.BasicAuth{
@ -69,7 +70,7 @@ func TestHandler_RawData(t *testing.T) {
},
},
},
Routers: map[string]*dynamic.RouterInfo{
Routers: map[string]*runtime.RouterInfo{
"bar@myprovider": {
Router: &dynamic.Router{
EntryPoints: []string{"web"},
@ -87,7 +88,7 @@ func TestHandler_RawData(t *testing.T) {
},
},
},
TCPServices: map[string]*dynamic.TCPServiceInfo{
TCPServices: map[string]*runtime.TCPServiceInfo{
"tcpfoo-service@myprovider": {
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
@ -100,7 +101,7 @@ func TestHandler_RawData(t *testing.T) {
},
},
},
TCPRouters: map[string]*dynamic.TCPRouterInfo{
TCPRouters: map[string]*runtime.TCPRouterInfo{
"tcpbar@myprovider": {
TCPRouter: &dynamic.TCPRouter{
EntryPoints: []string{"web"},

View file

@ -9,7 +9,8 @@
"addPrefixTest@anotherprovider"
],
"service": "foo-service@myprovider",
"rule": "Host(`foo.bar`)"
"rule": "Host(`foo.bar`)",
"status": "enabled"
},
"test@myprovider": {
"entryPoints": [
@ -20,7 +21,8 @@
"auth"
],
"service": "foo-service@myprovider",
"rule": "Host(`foo.bar.other`)"
"rule": "Host(`foo.bar.other`)",
"status": "enabled"
}
},
"middlewares": {
@ -62,6 +64,7 @@
],
"passHostHeader": false
},
"status": "enabled",
"usedBy": [
"bar@myprovider",
"test@myprovider"
@ -74,14 +77,16 @@
"web"
],
"service": "tcpfoo-service@myprovider",
"rule": "HostSNI(`foo.bar`)"
"rule": "HostSNI(`foo.bar`)",
"status": "enabled"
},
"tcptest@myprovider": {
"entryPoints": [
"web"
],
"service": "tcpfoo-service@myprovider",
"rule": "HostSNI(`foo.bar.other`)"
"rule": "HostSNI(`foo.bar.other`)",
"status": "enabled"
}
},
"tcpServices": {
@ -93,6 +98,7 @@
}
]
},
"status": "enabled",
"usedBy": [
"tcpbar@myprovider",
"tcptest@myprovider"

View file

@ -6,19 +6,19 @@
},
"http": {
"middlewares": {
"errors": 0,
"errors": 1,
"total": 3,
"warnings": 0
},
"routers": {
"errors": 0,
"total": 2,
"warnings": 0
"errors": 1,
"total": 3,
"warnings": 1
},
"services": {
"errors": 0,
"total": 1,
"warnings": 0
"errors": 1,
"total": 3,
"warnings": 1
}
},
"tcp": {

View file

@ -9,5 +9,6 @@
"name": "bar@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
}

View file

@ -6,7 +6,8 @@
"name": "bar14@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar14`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
},
{
"entryPoints": [
@ -15,7 +16,8 @@
"name": "bar15@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar15`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
},
{
"entryPoints": [
@ -24,7 +26,8 @@
"name": "bar16@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar16`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
},
{
"entryPoints": [
@ -33,7 +36,8 @@
"name": "bar17@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar17`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
},
{
"entryPoints": [
@ -42,6 +46,7 @@
"name": "bar18@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar18`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
}
]

View file

@ -6,6 +6,7 @@
"name": "baz@myprovider",
"provider": "myprovider",
"rule": "Host(`toto.bar`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
}
]

View file

@ -10,7 +10,8 @@
"name": "bar@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
},
{
"entryPoints": [
@ -23,6 +24,7 @@
"name": "test@myprovider",
"provider": "myprovider",
"rule": "Host(`foo.bar.other`)",
"service": "foo-service@myprovider"
"service": "foo-service@myprovider",
"status": "enabled"
}
]

View file

@ -12,6 +12,7 @@
"serverStatus": {
"http://127.0.0.1": "UP"
},
"status": "enabled",
"usedBy": [
"foo@myprovider",
"test@myprovider"

View file

@ -13,6 +13,7 @@
"serverStatus": {
"http://127.0.0.2": "UP"
},
"status": "enabled",
"usedBy": [
"foo@myprovider"
]

View file

@ -13,6 +13,7 @@
"serverStatus": {
"http://127.0.0.1": "UP"
},
"status": "enabled",
"usedBy": [
"foo@myprovider",
"test@myprovider"
@ -32,6 +33,7 @@
"serverStatus": {
"http://127.0.0.2": "UP"
},
"status": "enabled",
"usedBy": [
"foo@myprovider"
]