host: Prevent deadlock when restoring state
host: Prevent deadlock when restoring state

Container cleanup emits a cleanup event which attempts to persist to the
state database, but the state database is open for reading when
restoring state during startup, so running cleanup can deadlock.

Container.Watch (which is run in a goroutine during restore) runs the
cleanup in a deferred call, so there is no need to run the cleanup
directly in UnmarshalState, thus preventing the deadlock.

Signed-off-by: Lewis Marshall <748e1641a368164906d4a0c0e3965345453dcc93@lmars.net>

flynn/flynn,lmars/flynn,philiplb/flynn,lmars/flynn,flynn/flynn,lmars/flynn,philiplb/flynn,flynn/flynn,philiplb/flynn,lmars/flynn,philiplb/flynn,flynn/flynn,philiplb/flynn,flynn/flynn,lmars/flynn