Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor globalConfiguration / WebProvider #1938

Merged
merged 1 commit into from
Aug 25, 2017

Conversation

juliens
Copy link
Member

@juliens juliens commented Aug 10, 2017

  • split the globalconfiguration to a new package (not in package server)
  • split traefik configuration and global configuration
  • webprovider is now in package provider
  • the run func need a global configuration and not a traefik configuration

@juliens juliens added WIP kind/enhancement a new or improved feature. labels Aug 10, 2017
@ldez ldez changed the title Refacto globalConfiguration / WebProvider Refactor globalConfiguration / WebProvider Aug 10, 2017
@ldez ldez added this to the 1.4 milestone Aug 11, 2017
@juliens juliens force-pushed the refacto-package-configuration branch from 94d42ec to dc348d3 Compare August 12, 2017 14:13
@ldez ldez added WIP and removed WIP labels Aug 15, 2017
@juliens juliens force-pushed the refacto-package-configuration branch from dc348d3 to 931ad6f Compare August 15, 2017 21:32
@nmengin nmengin force-pushed the refacto-package-configuration branch from 931ad6f to a568d2d Compare August 18, 2017 16:04
@ldez ldez added the size/L label Aug 19, 2017
Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliens Your refacto SGTM.
Only two suggestions.

server/server.go Outdated
statsRecorder := middlewares.NewStatsRecorder(server.globalConfiguration.Web.Statistics.RecentErrors)
server.globalConfiguration.Web.StatsRecorder = statsRecorder
serverMiddlewares = append(serverMiddlewares, statsRecorder)
}
Copy link
Contributor

@nmengin nmengin Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your mind about the deletion of the statsRecorder variable?

if server.globalConfiguration.Web.Statistics != nil {
    server.globalConfiguration.Web.StatsRecorder = middlewares.NewStatsRecorder(server.globalConfiguration.Web.Statistics.RecentErrors)
    serverMiddlewares = append(serverMiddlewares, server.globalConfiguration.Web.StatsRecorder)
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me

server/server.go Outdated
metricsMiddleware := thoas_stats.New()
server.globalConfiguration.Web.MetricsRecorder = metricsMiddleware
serverMiddlewares = append(serverMiddlewares, metricsMiddleware)
if server.globalConfiguration.Web.Statistics != nil {
Copy link
Contributor

@nmengin nmengin Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your mind about the deletion of the metricsMiddleware variable?

if server.globalConfiguration.Web.Statistics != nil {
    server.globalConfiguration.Web.MetricsRecorder = thoas_stats.New()
    serverMiddlewares = append(serverMiddlewares, server.globalConfiguration.Web.MetricsRecorder)
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me

@ldez ldez force-pushed the refacto-package-configuration branch 3 times, most recently from e046ae8 to 6674e82 Compare August 24, 2017 14:27
Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I find this refactor absolutely amazing 😍
👏 @juliens @ldez !
I have few comments / questions though

fmtlog.SetFlags(fmtlog.Lshortfile | fmtlog.LstdFlags)

// load global configuration
globalConfiguration := traefikConfiguration.GlobalConfiguration
http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = globalConfiguration.MaxIdleConnsPerHost
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure to understand/remember why we apply those parameters to DefaultTransport whereas we used those ones to apply to a specific instance (in server.go createHTTPTransport).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually like code before the introduction of the timeouts PR #1873 and gets reintroduced here, which it shouldn't. Can you align your version please.

Debug bool
CurrentConfigurations *safe.Safe
MetricsRecorder *thoas_stats.Stats
StatsRecorder *middlewares.StatsRecorder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended (MetricsRecorder & StatsRecorder)?

Copy link
Contributor

@m3co-code m3co-code Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho the naming is confusing. Can you rename MetricsRecorder with Stats to make the distinction with the existing Metrics implementation clear?

To be sure, fields like StatsRecorder can not be configured as part of the Web provider now?

server *Server
Auth *types.Auth
// Provider is a provider.Provider implementation that provides the UI
type Provider struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this struct embed a provider.BaseProvider like any other provider ?

if server.globalConfiguration.Web != nil && server.globalConfiguration.Web.Statistics != nil {
statsRecorder = middlewares.NewStatsRecorder(server.globalConfiguration.Web.Statistics.RecentErrors)
serverMiddlewares = append(serverMiddlewares, statsRecorder)
if server.globalConfiguration.Web != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these changes are compliant with the metrics refactor made in #1968

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @marco-jantke

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS it doesn't interfere with the metrics implementation but the naming confuses at the moment. Its a good step by the way to get rid of the global stats variable. Anyhow MetricsRecorder is a confusing naming. I would stick with Stats.

@dtomcej
Copy link
Contributor

dtomcej commented Aug 25, 2017

This may seem like a silly question, but if we are migrating the web provider to its own middleware, can we use this opportunity to rename it to something like 'api', or 'rest' or some sort of API-like provider name?

It can be very confusing for people to have the API and the Admin panel be named "web"

@timoreimann
Copy link
Contributor

+1 to what @dtomcej said.

@ldez
Copy link
Contributor

ldez commented Aug 25, 2017

It's not only a rest api but it's also an endpoint for the webui. A good name is hard to find.

@timoreimann
Copy link
Contributor

True...

Copy link
Contributor

@m3co-code m3co-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling the package naming is quite verbose, as one example configuration.TraeifkConfiguration. Should we maybe use only and consistently config like config.TraefikConfig?

fmtlog.SetFlags(fmtlog.Lshortfile | fmtlog.LstdFlags)

// load global configuration
globalConfiguration := traefikConfiguration.GlobalConfiguration
http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = globalConfiguration.MaxIdleConnsPerHost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually like code before the introduction of the timeouts PR #1873 and gets reintroduced here, which it shouldn't. Can you align your version please.

Debug bool
CurrentConfigurations *safe.Safe
MetricsRecorder *thoas_stats.Stats
StatsRecorder *middlewares.StatsRecorder
Copy link
Contributor

@m3co-code m3co-code Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho the naming is confusing. Can you rename MetricsRecorder with Stats to make the distinction with the existing Metrics implementation clear?

To be sure, fields like StatsRecorder can not be configured as part of the Web provider now?

if server.globalConfiguration.Web != nil && server.globalConfiguration.Web.Statistics != nil {
statsRecorder = middlewares.NewStatsRecorder(server.globalConfiguration.Web.Statistics.RecentErrors)
serverMiddlewares = append(serverMiddlewares, statsRecorder)
if server.globalConfiguration.Web != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS it doesn't interfere with the metrics implementation but the naming confuses at the moment. Its a good step by the way to get rid of the global stats variable. Anyhow MetricsRecorder is a confusing naming. I would stick with Stats.

Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏

@emilevauge
Copy link
Member

I have the feeling the package naming is quite verbose, as one example configuration.TraeifkConfiguration. Should we maybe use only and consistently config like config.TraefikConfig?

Hey @marco-jantke, we all use automatic completion today, so I think we can live we "long" package names ;)

Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉
LGTM

Copy link
Contributor

@m3co-code m3co-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

- Traefik configuration is in main
- Metrics and statsRecord are not global vars anymore
- run use GlobalConfiguration
- fix log rotation test to adapt to he new number of lines due to the refactoring
@ldez ldez force-pushed the refacto-package-configuration branch from 1bf033a to fa8396f Compare August 25, 2017 13:43
@traefiker traefiker merged commit e0af17a into traefik:master Aug 25, 2017
@juliens juliens deleted the refacto-package-configuration branch September 13, 2017 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement a new or improved feature. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants