mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-07 19:38:13 +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
|
throw err
|
||||||
|
|
||||||
shouldMountKmod = (image) ->
|
shouldMountKmod = (image) ->
|
||||||
device.getOSVersion().then (osVersion) ->
|
device.isResinOSv1().then (isV1) ->
|
||||||
return false if not /^Resin OS 1./.test(osVersion)
|
return false if not isV1
|
||||||
Promise.using docker.imageRootDirMounted(image), (rootDir) ->
|
Promise.using docker.imageRootDirMounted(image), (rootDir) ->
|
||||||
utils.getOSVersion(rootDir + '/etc/os-release')
|
utils.getOSVersion(rootDir + '/etc/os-release')
|
||||||
.then (version) ->
|
.then (version) ->
|
||||||
@ -225,8 +225,9 @@ shouldMountKmod = (image) ->
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
application.start = start = (app) ->
|
application.start = start = (app) ->
|
||||||
volumes = utils.defaultVolumes
|
device.isResinOSv1().then (isV1) ->
|
||||||
binds = utils.defaultBinds(app.appId)
|
volumes = utils.defaultVolumes(isV1)
|
||||||
|
binds = utils.defaultBinds(app.appId, isV1)
|
||||||
alreadyStarted = false
|
alreadyStarted = false
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
# Parse the env vars before trying to access them, that's because they have to be stringified for knex..
|
# 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 ->
|
exports.getOSVersion = memoizePromise ->
|
||||||
utils.getOSVersion(config.hostOsVersionPath)
|
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)
|
docker.modem.dialAsync = Promise.promisify(docker.modem.dial)
|
||||||
createContainer = (options, internalId) ->
|
createContainer = (options, internalId) ->
|
||||||
Promise.using writeLockImages(), ->
|
Promise.using writeLockImages(), ->
|
||||||
|
Promise.join(
|
||||||
knex('image').select().where('repoTag', options.Image)
|
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
|
throw new Error('Only images created via the Supervisor can be used for creating containers.') if images.length == 0
|
||||||
knex.transaction (tx) ->
|
knex.transaction (tx) ->
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
@ -277,8 +279,8 @@ do ->
|
|||||||
.then (id) ->
|
.then (id) ->
|
||||||
options.HostConfig ?= {}
|
options.HostConfig ?= {}
|
||||||
options.Volumes ?= {}
|
options.Volumes ?= {}
|
||||||
_.assign(options.Volumes, utils.defaultVolumes)
|
_.assign(options.Volumes, utils.defaultVolumes(isV1))
|
||||||
options.HostConfig.Binds = utils.defaultBinds("containers/#{id}")
|
options.HostConfig.Binds = utils.defaultBinds("containers/#{id}", isV1)
|
||||||
query = ''
|
query = ''
|
||||||
query = "name=#{options.Name}&" if options.Name?
|
query = "name=#{options.Name}&" if options.Name?
|
||||||
optsf =
|
optsf =
|
||||||
@ -300,6 +302,7 @@ do ->
|
|||||||
containerId = data.Id
|
containerId = data.Id
|
||||||
tx('container').update({ containerId }).where({ id })
|
tx('container').update({ containerId }).where({ id })
|
||||||
.return(data)
|
.return(data)
|
||||||
|
)
|
||||||
exports.createContainer = (req, res) ->
|
exports.createContainer = (req, res) ->
|
||||||
createContainer(req.body)
|
createContainer(req.body)
|
||||||
.then (data) ->
|
.then (data) ->
|
||||||
|
@ -242,26 +242,32 @@ exports.getOSVersion = (path) ->
|
|||||||
console.log('Could not get OS Version: ', err, err.stack)
|
console.log('Could not get OS Version: ', err, err.stack)
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
exports.defaultVolumes = {
|
exports.defaultVolumes = (includeV1Volumes) ->
|
||||||
|
volumes = {
|
||||||
'/data': {}
|
'/data': {}
|
||||||
'/lib/modules': {}
|
'/lib/modules': {}
|
||||||
'/lib/firmware': {}
|
'/lib/firmware': {}
|
||||||
'/host/var/lib/connman': {}
|
|
||||||
'/host/run/dbus': {}
|
'/host/run/dbus': {}
|
||||||
}
|
}
|
||||||
|
if includeV1Volumes
|
||||||
|
volumes['/host/var/lib/connman'] = {}
|
||||||
|
volumes['/host_run/dbus'] = {}
|
||||||
|
return volumes
|
||||||
|
|
||||||
exports.getDataPath = (identifier) ->
|
exports.getDataPath = (identifier) ->
|
||||||
return config.dataPath + '/' + identifier
|
return config.dataPath + '/' + identifier
|
||||||
|
|
||||||
exports.defaultBinds = (dataPath) ->
|
exports.defaultBinds = (dataPath, includeV1Binds) ->
|
||||||
return [
|
binds = [
|
||||||
exports.getDataPath(dataPath) + ':/data'
|
exports.getDataPath(dataPath) + ':/data'
|
||||||
'/lib/modules:/lib/modules'
|
'/lib/modules:/lib/modules'
|
||||||
'/lib/firmware:/lib/firmware'
|
'/lib/firmware:/lib/firmware'
|
||||||
'/run/dbus:/host_run/dbus'
|
|
||||||
'/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 = [
|
exports.validComposeOptions = [
|
||||||
'command'
|
'command'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user