Skip to content
New issue

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

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

Already on GitHub? # to your account

Support pluggable config providers #102

Merged
merged 2 commits into from
Feb 17, 2022
Merged

Support pluggable config providers #102

merged 2 commits into from
Feb 17, 2022

Conversation

feedmeapples
Copy link
Contributor

@feedmeapples feedmeapples commented Feb 13, 2022

What was changed

Adds support for pluggable Config providers:

  • adds Config Provider interface
  • it's wrapped in a Config Provider With Refresh (that periodically gets the config and caches it)
  • there is a default implementation of Config Provider that is used in our docker image (fs_config_provider)
  • people can start the server with their own provider instead

Why?

Flexibility in how the config is provided
TLS params periodic refresh

Checklist

  1. Closes

  2. How was this tested:

  • First start Temporal service with mTLS disabled
  • In UI server's config set refreshInterval: 30s, ex in development.yaml file
  • Load** UI server and open http://localhost:8080/ and verify namespaces are loaded
  • Stop Temporal service
  • Start a new Temporal service with mTLS enabled using https://github.com/temporalio/samples-server/tree/main/tls/tls-simple
  • Go to UI server development.yaml and set values for caFile, certFile, keyFile, enableHostVerification, serverName
  • Wait up to 30 seconds (refreshInterval) until you see 2022[/02/16]() 11:38:06 loaded new UI server configuration in the logs, should also print that it loaded new TLS CA, KEY etc
  • Open http://localhost:8080/ again and verify that the namespaces are loaded
  1. Any docs updates needed?

}
)

// NewServer returns a new instance of server that serves one or many services.
func NewServer(opts ...server_options.ServerOption) *Server {
serverOpts := server_options.NewServerOptions(opts)
cfgProvider, err := config.NewConfigProviderWithRefresh(*serverOpts.ConfigProvider)
Copy link
Member

Choose a reason for hiding this comment

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

This err is left unchecked, which may lead to cfgProvider being nil.

return c.JSON(http.StatusInternalServerError, err)
}

tls, err := rpc.CreateTLSConfig(cfg.TemporalGRPCAddress, &cfg.TLS)
Copy link
Member

Choose a reason for hiding this comment

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

Is this called on every request and never cached?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Config passed into rpc.CreateTLSConfig() is cashed, but the output of it is generated every time? And then rpc.CreateGRPCConnection() is also called every time. Shouldn't they be cached?

Copy link
Contributor Author

@feedmeapples feedmeapples Feb 16, 2022

Choose a reason for hiding this comment

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

right, figured to cache the GRPC connections once we add multi-connection support and work with the pool of connections. Can add caching now

ctx := context.Background()
cfg, _ := cfgProvider.GetConfig()
Copy link
Member

Choose a reason for hiding this comment

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

Why ignore error?

@feedmeapples feedmeapples merged commit 0b83e10 into main Feb 17, 2022
@feedmeapples feedmeapples deleted the pluggable-config branch February 17, 2022 18:59
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants