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

refactor how mirror data is handled #626

Merged
merged 3 commits into from Feb 4, 2020

Conversation

mwhudson
Copy link
Collaborator

This is prep work for allowing autoinstalls to specify a complete apt
config.

@mwhudson mwhudson mentioned this pull request Jan 30, 2020
Copy link
Contributor

@raharper raharper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple questions and comments.



def get_default_mirror():
return get_mirror(DEFAULT, "primary", get_architecture())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move the get_mirror() call to the object initialization so we can cache it? It won't change during the lifetime of the install so we can save some execs and overhead if we keep it around.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we recently made use of python3's lru_cache() in cloud-init

from functools import lru_cache()

@lru_cache()
def get_default_mirror()

...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked a bit, see what you think now.

subiquity/models/mirror.py Show resolved Hide resolved
This is prep work for allowing autoinstalls to specify a complete apt
config.
Copy link
Contributor

@raharper raharper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I'm fine with things; I've some suggestions if you're interested.

],
}

ARCHITECTURE = get_architecture()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this create a side-effect of executing dpkg if something imports this module?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, nothing outside of this module uses DEFAULT_MIRROR or ARCHITECTURE and the API being used are the method son the MirrorModel itself, could we move these values to the class itself? then they can be properties that are cached after initialization in init?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes more sense, thanks.

@mwhudson mwhudson merged commit f8e8931 into canonical:master Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants