mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Avoid problems with null app names or invalid container names when migrating from old supervisors
Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
91b6a1fd48
commit
8fac5c0e32
@ -288,7 +288,7 @@ isExecFormatError = (err) ->
|
||||
generateContainerName = (app) ->
|
||||
randomHexString.generate()
|
||||
.then (randomString) ->
|
||||
sanitisedAppName = app.name.replace(/[^a-zA-Z0-9]+/g, '_')
|
||||
sanitisedAppName = (app.name ? 'app').replace(/[^a-zA-Z0-9]+/g, '_')
|
||||
return "#{sanitisedAppName}_#{randomString}"
|
||||
|
||||
application.start = start = (app) ->
|
||||
@ -944,7 +944,10 @@ migrateContainerIdApps = ->
|
||||
docker.getContainer(app.containerId).inspect()
|
||||
.catchReturn({ Name: null })
|
||||
.then (container) ->
|
||||
app.containerName = sanitiseContainerName(container.Name)
|
||||
if container.Name?
|
||||
app.containerName = sanitiseContainerName(container.Name)
|
||||
else
|
||||
app.containerName = null
|
||||
app.containerId = null
|
||||
knex('app').update(app).where({ id: app.id })
|
||||
.then ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user