Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions common/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var _ Client = (*elasticWrapper)(nil)
func NewClient(config *Config) (Client, error) {
client, err := elastic.NewClient(
elastic.SetURL(config.URL.String()),
elastic.SetSniff(false),
elastic.SetRetrier(elastic.NewBackoffRetrier(elastic.NewExponentialBackoff(128*time.Millisecond, 513*time.Millisecond))),
elastic.SetDecoder(&elastic.NumberDecoder{}), // critical to ensure decode of int64 won't lose precise
)
Expand Down
15 changes: 13 additions & 2 deletions common/elasticsearch/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,23 @@ import (
// Config for connecting to ElasticSearch
type (
Config struct {
URL url.URL `yaml:url` //nolint:govet
Indices map[string]string `yaml:indices` //nolint:govet
URL url.URL `yaml:"url"` //nolint:govet
Username *string `yaml:"username"`
Password *string `yaml:"password"`
Copy link
Member

Choose a reason for hiding this comment

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

Do we even want to support putting passwords to yaml files? A more secure way I think would be to only accept passwords programmatically. Now that we added server options, this can be done elegantly.

Copy link
Contributor

Choose a reason for hiding this comment

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

at least our current solution allows password in yaml:
https://github.com/temporalio/temporal/blob/master/common/service/config/config.go#L224

one more thing is accept passwords programmatically requires the user to use our service like lib, while currently users can basically directly use our published docker.

Copy link
Contributor

Choose a reason for hiding this comment

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

one more thing: the user / pass can be passed in from environment vars: https://github.com/temporalio/temporal/blob/master/docker/config_template.yaml#L32
this is how the secrets were used in my prev company

Copy link
Member

Choose a reason for hiding this comment

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

That's true. Why *string and not string like on the other cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

that is true

@linvon could you plz change the *string to string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I've changed it

Indices map[string]string `yaml:"indices"` //nolint:govet
}
)

// GetVisibilityIndex return visibility index name
func (cfg *Config) GetVisibilityIndex() string {
return cfg.Indices[common.VisibilityAppName]
}

// CompleteUserInfo complete url.URL with username and password for ElasticSearch
func (cfg *Config) CompleteUserInfo() {
if cfg.Username != nil && cfg.Password != nil {
cfg.URL.User = url.UserPassword(*cfg.Username, *cfg.Password)
} else if cfg.Username != nil {
cfg.URL.User = url.User(*cfg.Username)
}
}
1 change: 1 addition & 0 deletions temporal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ func (s *Server) getServiceParams(
return nil, fmt.Errorf("unable to find advanced visibility store in config for %q key", advancedVisStoreKey)
}

advancedVisStore.ElasticSearch.CompleteUserInfo()
esClient, err := elasticsearch.NewClient(advancedVisStore.ElasticSearch)
if err != nil {
return nil, fmt.Errorf("error creating elastic search client: %v", err)
Expand Down