Merge pull request #1170 from ogayot/FR-1983

Fix hanging when network is the last postinst model configured
This commit is contained in:
Michael Hudson-Doyle 2022-01-21 10:25:54 +13:00 committed by GitHub
commit 56ddf178e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 15 deletions

View File

@ -18,6 +18,7 @@ from collections import OrderedDict
import functools
import logging
import os
from typing import Set
import uuid
import yaml
@ -190,17 +191,11 @@ class SubiquityModel:
self._postinstall_event.set()
def _configured(self, model_name):
self._configured_names.add(model_name)
if model_name in self._cur_install_model_names:
stage = 'install'
names = self._cur_install_model_names
event = self._install_event
elif model_name in self._cur_postinstall_model_names:
stage = 'postinstall'
names = self._cur_postinstall_model_names
event = self._postinstall_event
else:
return
""" Add the model to the set of models that have been configured. If
there is no more model to configure in the relevant section(s) (i.e.,
INSTALL or POSTINSTALL), we trigger the associated event(s). """
def log_and_trigger(stage: str, names: Set[str],
event: asyncio.Event) -> None:
unconfigured = names - self._configured_names
log.debug(
"model %s for %s stage is configured, to go %s",
@ -208,6 +203,16 @@ class SubiquityModel:
if not unconfigured:
event.set()
self._configured_names.add(model_name)
if model_name in self._cur_install_model_names:
log_and_trigger(stage="install",
names=self._cur_install_model_names,
event=self._install_event)
if model_name in self._cur_postinstall_model_names:
log_and_trigger(stage="postinstall",
names=self._cur_postinstall_model_names,
event=self._postinstall_event)
async def wait_install(self):
if len(self._cur_install_model_names) == 0:
self._install_event.set()