mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-07 03:18:12 +00:00
Issues #389 and #390: Remove /host_run/dbus and /host/var/lib/connman bind mounts for non-ResinOS-1.X devices
On ResinOS 2.X the default mounts should not include the previously deprecated host_run, and there's no connman which makes the connman mount confusing. This is a breaking change as it is not backwards-compatible on non-ResinOS instances of the supervisor. Change-Type: major Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
f7c702b845
commit
b64ed9568c
@ -214,8 +214,8 @@ fetch = (app, setDeviceUpdateState = true) ->
|
||||
throw err
|
||||
|
||||
shouldMountKmod = (image) ->
|
||||
device.getOSVersion().then (osVersion) ->
|
||||
return false if not /^Resin OS 1./.test(osVersion)
|
||||
device.isResinOSv1().then (isV1) ->
|
||||
return false if not isV1
|
||||
Promise.using docker.imageRootDirMounted(image), (rootDir) ->
|
||||
utils.getOSVersion(rootDir + '/etc/os-release')
|
||||
.then (version) ->
|
||||
@ -225,8 +225,9 @@ shouldMountKmod = (image) ->
|
||||
return false
|
||||
|
||||
application.start = start = (app) ->
|
||||
volumes = utils.defaultVolumes
|
||||
binds = utils.defaultBinds(app.appId)
|
||||
device.isResinOSv1().then (isV1) ->
|
||||
volumes = utils.defaultVolumes(isV1)
|
||||
binds = utils.defaultBinds(app.appId, isV1)
|
||||
alreadyStarted = false
|
||||
Promise.try ->
|
||||
# Parse the env vars before trying to access them, that's because they have to be stringified for knex..
|
||||
|
@ -224,3 +224,8 @@ do ->
|
||||
|
||||
exports.getOSVersion = memoizePromise ->
|
||||
utils.getOSVersion(config.hostOsVersionPath)
|
||||
|
||||
exports.isResinOSv1 = memoizePromise ->
|
||||
exports.getOSVersion().then (osVersion) ->
|
||||
return true if /^Resin OS 1./.test(osVersion)
|
||||
return false
|
@ -265,8 +265,10 @@ do ->
|
||||
docker.modem.dialAsync = Promise.promisify(docker.modem.dial)
|
||||
createContainer = (options, internalId) ->
|
||||
Promise.using writeLockImages(), ->
|
||||
Promise.join(
|
||||
knex('image').select().where('repoTag', options.Image)
|
||||
.then (images) ->
|
||||
device.isResinOSv1()
|
||||
(images, isV1) ->
|
||||
throw new Error('Only images created via the Supervisor can be used for creating containers.') if images.length == 0
|
||||
knex.transaction (tx) ->
|
||||
Promise.try ->
|
||||
@ -277,8 +279,8 @@ do ->
|
||||
.then (id) ->
|
||||
options.HostConfig ?= {}
|
||||
options.Volumes ?= {}
|
||||
_.assign(options.Volumes, utils.defaultVolumes)
|
||||
options.HostConfig.Binds = utils.defaultBinds("containers/#{id}")
|
||||
_.assign(options.Volumes, utils.defaultVolumes(isV1))
|
||||
options.HostConfig.Binds = utils.defaultBinds("containers/#{id}", isV1)
|
||||
query = ''
|
||||
query = "name=#{options.Name}&" if options.Name?
|
||||
optsf =
|
||||
@ -300,6 +302,7 @@ do ->
|
||||
containerId = data.Id
|
||||
tx('container').update({ containerId }).where({ id })
|
||||
.return(data)
|
||||
)
|
||||
exports.createContainer = (req, res) ->
|
||||
createContainer(req.body)
|
||||
.then (data) ->
|
||||
|
@ -242,26 +242,32 @@ exports.getOSVersion = (path) ->
|
||||
console.log('Could not get OS Version: ', err, err.stack)
|
||||
return undefined
|
||||
|
||||
exports.defaultVolumes = {
|
||||
exports.defaultVolumes = (includeV1Volumes) ->
|
||||
volumes = {
|
||||
'/data': {}
|
||||
'/lib/modules': {}
|
||||
'/lib/firmware': {}
|
||||
'/host/var/lib/connman': {}
|
||||
'/host/run/dbus': {}
|
||||
}
|
||||
}
|
||||
if includeV1Volumes
|
||||
volumes['/host/var/lib/connman'] = {}
|
||||
volumes['/host_run/dbus'] = {}
|
||||
return volumes
|
||||
|
||||
exports.getDataPath = (identifier) ->
|
||||
return config.dataPath + '/' + identifier
|
||||
|
||||
exports.defaultBinds = (dataPath) ->
|
||||
return [
|
||||
exports.defaultBinds = (dataPath, includeV1Binds) ->
|
||||
binds = [
|
||||
exports.getDataPath(dataPath) + ':/data'
|
||||
'/lib/modules:/lib/modules'
|
||||
'/lib/firmware:/lib/firmware'
|
||||
'/run/dbus:/host_run/dbus'
|
||||
'/run/dbus:/host/run/dbus'
|
||||
'/var/lib/connman:/host/var/lib/connman'
|
||||
]
|
||||
if includeV1Binds
|
||||
binds.push('/run/dbus:/host_run/dbus')
|
||||
binds.push('/var/lib/connman:/host/var/lib/connman')
|
||||
return binds
|
||||
|
||||
exports.validComposeOptions = [
|
||||
'command'
|
||||
|
Loading…
x
Reference in New Issue
Block a user