Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not do any mirror configuration when installing core #1707

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions subiquity/client/controllers/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import asyncio
import logging

from subiquitycore.tuicontroller import Skip

from subiquity.common.types import (
MirrorCheckStatus,
MirrorGet,
Expand All @@ -33,6 +35,8 @@ class MirrorController(SubiquityTuiController):

async def make_ui(self):
mirror_response: MirrorGet = await self.endpoint.GET()
if not mirror_response.relevant:
raise Skip
# We could do all sort of things with the list of candidate mirrors in
# the UI ; like suggesting the next mirror automatically if the first
# candidate fails. For now, we keep things simple.
Expand Down
1 change: 1 addition & 0 deletions subiquity/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ class MirrorPostResponse(enum.Enum):

@attr.s(auto_attribs=True)
class MirrorGet:
relevant: bool
elected: Optional[str]
candidates: List[str]
staged: Optional[str]
Expand Down
40 changes: 28 additions & 12 deletions subiquity/server/controllers/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,12 @@ async def on_source(self):
# apply_autoinstall_config but this is out of scope.
raise RuntimeError("source model has changed but autoinstall"
" configuration is already being applied")
self.test_apt_configurer = get_apt_configurer(
self.app, self.app.controllers.Source.get_handler())
source_entry = self.app.base_model.source.current
if source_entry.variant == 'core':
self.test_apt_configurer = None
else:
self.test_apt_configurer = get_apt_configurer(
self.app, self.app.controllers.Source.get_handler())
self.source_configured_event.set()

def serialize(self):
Expand Down Expand Up @@ -327,7 +331,9 @@ async def run_mirror_testing(self, output: io.StringIO) -> None:
# apply_apt_config and run_apt_config_check. Just make sure we still
# use the original one.
configurer = self.test_apt_configurer
assert configurer is not None
if configurer is None:
# i.e. core
return
await configurer.apply_apt_config(
self.context, final=False)
await configurer.run_apt_config_check(output)
Expand All @@ -342,15 +348,25 @@ async def wait_config(self, variation_name: str) -> AptConfigurer:
async def GET(self) -> MirrorGet:
elected: Optional[str] = None
staged: Optional[str] = None
if self.model.primary_elected is not None:
elected = self.model.primary_elected.uri
if self.model.primary_staged is not None:
staged = self.model.primary_staged.uri

compatibles = self.model.compatible_primary_candidates()
# Skip the country-mirrors if they have not been resolved yet.
candidates = [c.uri for c in compatibles if c.uri is not None]
return MirrorGet(elected=elected, candidates=candidates, staged=staged)
candidates: List[str] = []
source_entry = self.app.base_model.source.current
if source_entry.variant == 'core':
relevant = False
else:
relevant = True
if self.model.primary_elected is not None:
elected = self.model.primary_elected.uri
if self.model.primary_staged is not None:
staged = self.model.primary_staged.uri

compatibles = self.model.compatible_primary_candidates()
# Skip the country-mirrors if they have not been resolved yet.
candidates = [c.uri for c in compatibles if c.uri is not None]
return MirrorGet(
relevant=relevant,
elected=elected,
candidates=candidates,
staged=staged)

async def POST(self, data: Optional[MirrorPost]) -> MirrorPostResponse:
log.debug(data)
Expand Down
Loading