Add announce_ip_from_hostname support for sentinel
We recently added a announce_ip_from_hostname
setting to omnibus that allows setting the announce-ip
option dynamically at runtime: gitlab-org/omnibus-gitlab!6027 (merged).
We discovered an issue while trying to make use of this option during the initial hybrid deployment test: gitlab-com/gl-infra/k8s-workloads/tanka-deployments!374 (merged).
The option only applies to redis, and not to sentinel. That means that sentinels will still announce themselves via IP address. This might actually be workable, if we can mix-and-match hostnames and IPs. But it would be cleaner and safer to properly configure hostnames everywhere.
We should evaluate whether it is possible to port the service run
approach from redis to sentinel. For redis, we add this to sv-redis-run.erb
:
/opt/gitlab/embedded/bin/redis-server \
<%= File.join(node[@options[:service]]['dir'], "redis.conf") %> \
<% if node['redis']['announce_ip_from_hostname'] %>--replica-announce-ip "$(hostname -f)"<% end %>
We need to check if there is an equivalent command-line flag for sentinel announce-ip
.