mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
compose: Use the hostname on the host as default hostname for services with host network mode
Otherwise if the hostname on the supervisor container differs from the hostname on the host, the current and target services will never match. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
557b6a8d07
commit
08a98f47e4
@ -799,11 +799,13 @@ module.exports = class ApplicationManager extends EventEmitter
|
||||
firmware: pathExistsOnHost('/lib/firmware')
|
||||
modules: pathExistsOnHost('/lib/modules')
|
||||
})
|
||||
(opts, supervisorApiHost, hostPathExists) =>
|
||||
fs.readFileAsync(path.join(constants.rootMountPoint, '/etc/hostname')).then(String)
|
||||
(opts, supervisorApiHost, hostPathExists, hostnameOnHost) =>
|
||||
configOpts = {
|
||||
appName: app.name
|
||||
supervisorApiHost
|
||||
hostPathExists
|
||||
hostnameOnHost
|
||||
}
|
||||
_.assign(configOpts, opts)
|
||||
volumes = JSON.parse(app.volumes)
|
||||
|
@ -257,6 +257,9 @@ module.exports = class Service
|
||||
return "#{@appId}_#{k}"
|
||||
return k
|
||||
|
||||
if @networkMode == 'host' and @hostname == ''
|
||||
@hostname = opts.hostnameOnHost
|
||||
|
||||
@networks[@networkMode] ?= {}
|
||||
|
||||
@restartPolicy = createRestartPolicy(serviceProperties.restart)
|
||||
@ -459,9 +462,8 @@ module.exports = class Service
|
||||
hostname = container.Config.Hostname
|
||||
# A hostname equal to the first part of the container ID actually
|
||||
# means no hostname was specified
|
||||
if hostname == container.Id.substr(0, 12) or
|
||||
(networkMode == 'host' and hostname == os.hostname())
|
||||
hostname = ''
|
||||
if hostname.length is 12 and container.Id.startsWith(hostname)
|
||||
hostname = ''
|
||||
|
||||
service = {
|
||||
appId: appId
|
||||
|
Loading…
Reference in New Issue
Block a user