Fix ES client for nil password

Merged Dmitry Gruzd requested to merge 368703-fix-es-client-500 into master

What does this MR do and why?

This MR fixes the elasticsearch_config method to address https://gitlab.com/gitlab-org/gitlab/-/issues/368703. Currently if we only set username, password will be set to nil and break the elasticsearch client.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

  1. Enable Advanced Search
  2. Set the username with empty password
ApplicationSetting.current.update(elasticsearch_username: 'test', elasticsearch_password: '')
  1. Build Elasticsearch client using elasticsearch_config
::Elasticsearch::Client.new(ApplicationSetting.current.elasticsearch_config)
  1. It shouldn't raise an exception

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #368703

Edited by Dmitry Gruzd