[Launchpad-reviewers] [Merge] lp:~twom/launchpad/precache-gitrepository-branch-queries into lp:launchpad
Tom Wardill has proposed merging lp:~twom/launchpad/precache-gitrepository-branch-queries into lp:launchpad. Commit message: Precache gitrepository voting summary data Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~twom/launchpad/precache-gitrepository-branch-queries/+merge/354347 -- Your team Launchpad code reviewers is requested to review the proposed merge of lp:~twom/launchpad/precache-gitrepository-branch-queries into lp:launchpad. === modified file 'lib/lp/code/browser/branchmergeproposal.py' --- lib/lp/code/browser/branchmergeproposal.py 2018-07-16 00:49:00 + +++ lib/lp/code/browser/branchmergeproposal.py 2018-09-05 16:55:00 + @@ -890,7 +890,12 @@ @cachedproperty def reviews(self): """Return the decorated votes for the proposal.""" -users_vote = self.context.getUsersVoteReference(self.user) + +# this would use getUsersVoteReference, but we need to +# be able to cache the property. We dont' need to normalize +# the review types. +users_vote = [uv for uv in self.context.votes + if uv.reviewer == self.user] return [DecoratedCodeReviewVoteReference(vote, self.user, users_vote) for vote in self.context.votes if check_permission('launchpad.LimitedView', vote.reviewer)] === modified file 'lib/lp/code/browser/tests/test_gitrepository.py' --- lib/lp/code/browser/tests/test_gitrepository.py 2018-08-31 11:35:52 + +++ lib/lp/code/browser/tests/test_gitrepository.py 2018-09-05 16:55:00 + @@ -50,7 +50,10 @@ record_two_runs, TestCaseWithFactory, ) -from lp.testing.layers import DatabaseFunctionalLayer +from lp.testing.layers import ( +DatabaseFunctionalLayer, +LaunchpadFunctionalLayer, +) from lp.testing.matchers import ( Contains, HasQueryCount, @@ -96,7 +99,7 @@ class TestGitRepositoryView(BrowserTestCase): -layer = DatabaseFunctionalLayer +layer = LaunchpadFunctionalLayer def test_clone_instructions(self): repository = self.factory.makeGitRepository() @@ -275,6 +278,32 @@ self.assertEqual('1 branch', view._getBranchCountText(1)) self.assertEqual('2 branches', view._getBranchCountText(2)) +def test_landing_candidate_query_count(self): +repository = self.factory.makeGitRepository() +git_refs = self.factory.makeGitRefs( +repository, +paths=["refs/heads/master", "refs/heads/1.0", "refs/tags/1.1"]) + +def login_and_view(): +with FeatureFixture({"code.git.show_repository_mps": "on"}): +with person_logged_in(repository.owner): +browser = self.getViewBrowser(repository) +self.assertIsNotNone( +find_tag_by_id(browser.contents, 'landing-candidates')) + +def create_merge_proposal(): +bmp = self.factory.makeBranchMergeProposalForGit( +target_ref=git_refs[0], +set_state=BranchMergeProposalStatus.NEEDS_REVIEW) +self.factory.makePreviewDiff(merge_proposal=bmp) + +create_merge_proposal() +recorder1, recorder2 = record_two_runs( +login_and_view, +create_merge_proposal, +10) +self.assertThat(recorder2, HasQueryCount.byEquality(recorder1)) + def test_view_with_landing_targets(self): product = self.factory.makeProduct(name="foo", vcs=VCSType.GIT) target_repository = self.factory.makeGitRepository(target=product) @@ -296,6 +325,38 @@ self.assertIsNotNone( find_tag_by_id(browser.contents, 'landing-targets')) +def test_landing_target_query_count(self): +product = self.factory.makeProduct(name="foo", vcs=VCSType.GIT) +target_repository = self.factory.makeGitRepository(target=product) +source_repository = self.factory.makeGitRepository(target=product) + +def create_merge_proposal(): +target_git_refs = self.factory.makeGitRefs( +target_repository) +source_git_refs = self.factory.makeGitRefs( +source_repository) +bmp = self.factory.makeBranchMergeProposalForGit( +target_ref=target_git_refs[0], +source_ref=source_git_refs[0], +set_state=BranchMergeProposalStatus.NEEDS_REVIEW) +self.factory.makePreviewDiff(merge_proposal=bmp) + +def login_and_view(): +with FeatureFixture({"code.git.show_repository_mps": "on"}): +with person_logged_in(target_repository.owner): +browser = self.getViewBrowser( +source_repository, user=source_repository.owner) +self.assertIsNotNone( +find_tag_by_id(browser.contents, 'landing-targets')) + +
Re: [Launchpad-reviewers] [Merge] lp:~tobijk/launchpad-buildd/launchpad-buildd-bionic into lp:launchpad-buildd
Review: Needs Fixing Thanks for working on this! As well as the inline comments I've left, I'm pretty sure that this is going to need changes to the test suite. Diff comments: > === modified file 'lpbuildd/target/lxd.py' > --- lpbuildd/target/lxd.py2018-06-12 23:23:13 + > +++ lpbuildd/target/lxd.py2018-09-05 13:55:08 + > @@ -28,6 +28,7 @@ > from lpbuildd.util import ( > set_personality, > shell_escape, > +get_os_release Please keep these imports sorted, and make sure there's a comma at the end of each line. > ) > > > @@ -276,17 +277,32 @@ > else: > old_profile.delete() > > -raw_lxc_config = [ > -("lxc.aa_profile", "unconfined"), > -("lxc.cap.drop", ""), > -("lxc.cap.drop", "sys_time sys_module"), > -("lxc.cgroup.devices.deny", ""), > -("lxc.cgroup.devices.allow", ""), > -("lxc.mount.auto", ""), > -("lxc.mount.auto", "proc:rw sys:rw"), > -("lxc.network.0.ipv4", ipv4_address), > -("lxc.network.0.ipv4.gateway", self.ipv4_network.ip), > -] > +major, minor = get_os_release() > + > +if major >= 18: You're effectively using the OS release as a proxy for properties of LXD here. However, the OS release is a bad proxy to use for this, because at some point we may well want to switch to the LXD snap. Could you please find a way to make the behaviour conditional on the LXD version instead? You should be able to dig that out of `self._client.host_info`. > +raw_lxc_config = [ > +("lxc.apparmor.profile", "unconfined"), > +("lxc.cap.drop", ""), > +("lxc.cap.drop", "sys_time sys_module"), > +("lxc.cgroup.devices.deny", ""), > +("lxc.cgroup.devices.allow", ""), > +("lxc.mount.auto", ""), > +("lxc.mount.auto", "proc:rw sys:rw"), > +("lxc.net.0.ipv4.address", ipv4_address), > +("lxc.net.0.ipv4.gateway", self.ipv4_network.ip), > +] > +else: > +raw_lxc_config = [ > +("lxc.aa_profile", "unconfined"), > +("lxc.cap.drop", ""), > +("lxc.cap.drop", "sys_time sys_module"), > +("lxc.cgroup.devices.deny", ""), > +("lxc.cgroup.devices.allow", ""), > +("lxc.mount.auto", ""), > +("lxc.mount.auto", "proc:rw sys:rw"), > +("lxc.network.0.ipv4", ipv4_address), > +("lxc.network.0.ipv4.gateway", self.ipv4_network.ip), > +] Please could you reduce the duplication here? Most of the entries are identical, so you should be able to build up a list with conditional and unconditional `.append` and `.extend` calls. > # Linux 4.4 on powerpc doesn't support all the seccomp bits that LXD > # needs. > if self.arch == "powerpc": > @@ -341,7 +362,11 @@ > hostname_file.flush() > os.fchmod(hostname_file.fileno(), 0o644) > self.copy_in(hostname_file.name, "/etc/hostname") > -self.copy_in("/etc/resolv.conf", "/etc/resolv.conf") > +if os.path.exists("/run/systemd/resolve/resolv.conf"): > +self.copy_in("/run/systemd/resolve/resolv.conf", > +"/etc/resolv.conf") Should this possibly depend instead on whether /etc/resolv.conf is a symlink, and if so on what the target of the symlink is? > +else: > +self.copy_in("/etc/resolv.conf", "/etc/resolv.conf") > with tempfile.NamedTemporaryFile(mode="w+") as policy_rc_d_file: > policy_rc_d_file.write(policy_rc_d) > policy_rc_d_file.flush() -- https://code.launchpad.net/~tobijk/launchpad-buildd/launchpad-buildd-bionic/+merge/354331 Your team Launchpad code reviewers is requested to review the proposed merge of lp:~tobijk/launchpad-buildd/launchpad-buildd-bionic into lp:launchpad-buildd. ___ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp
[Launchpad-reviewers] [Merge] lp:~tobijk/launchpad-buildd/launchpad-buildd-bionic into lp:launchpad-buildd
Tobias Koch has proposed merging lp:~tobijk/launchpad-buildd/launchpad-buildd-bionic into lp:launchpad-buildd. Commit message: bionic compatibility Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~tobijk/launchpad-buildd/launchpad-buildd-bionic/+merge/354331 This patch makes launchpad-buildd work on Bionic. * Introduce a utility function that allows checking OS VERSION_ID from /etc/os-release * Based on major version id (e.g. 18 for Bionic) select matching raw.lxc settings (some parameter names have changed) * Fix a problem with header checks where uid and gid are set to 0 * Explicitly specify a root device, which seems to be mandatory now -- Your team Launchpad code reviewers is requested to review the proposed merge of lp:~tobijk/launchpad-buildd/launchpad-buildd-bionic into lp:launchpad-buildd. === modified file 'lpbuildd/target/lxd.py' --- lpbuildd/target/lxd.py 2018-06-12 23:23:13 + +++ lpbuildd/target/lxd.py 2018-09-05 13:55:08 + @@ -28,6 +28,7 @@ from lpbuildd.util import ( set_personality, shell_escape, +get_os_release ) @@ -276,17 +277,32 @@ else: old_profile.delete() -raw_lxc_config = [ -("lxc.aa_profile", "unconfined"), -("lxc.cap.drop", ""), -("lxc.cap.drop", "sys_time sys_module"), -("lxc.cgroup.devices.deny", ""), -("lxc.cgroup.devices.allow", ""), -("lxc.mount.auto", ""), -("lxc.mount.auto", "proc:rw sys:rw"), -("lxc.network.0.ipv4", ipv4_address), -("lxc.network.0.ipv4.gateway", self.ipv4_network.ip), -] +major, minor = get_os_release() + +if major >= 18: +raw_lxc_config = [ +("lxc.apparmor.profile", "unconfined"), +("lxc.cap.drop", ""), +("lxc.cap.drop", "sys_time sys_module"), +("lxc.cgroup.devices.deny", ""), +("lxc.cgroup.devices.allow", ""), +("lxc.mount.auto", ""), +("lxc.mount.auto", "proc:rw sys:rw"), +("lxc.net.0.ipv4.address", ipv4_address), +("lxc.net.0.ipv4.gateway", self.ipv4_network.ip), +] +else: +raw_lxc_config = [ +("lxc.aa_profile", "unconfined"), +("lxc.cap.drop", ""), +("lxc.cap.drop", "sys_time sys_module"), +("lxc.cgroup.devices.deny", ""), +("lxc.cgroup.devices.allow", ""), +("lxc.mount.auto", ""), +("lxc.mount.auto", "proc:rw sys:rw"), +("lxc.network.0.ipv4", ipv4_address), +("lxc.network.0.ipv4.gateway", self.ipv4_network.ip), +] # Linux 4.4 on powerpc doesn't support all the seccomp bits that LXD # needs. if self.arch == "powerpc": @@ -305,6 +321,11 @@ "parent": self.bridge_name, "type": "nic", }, +"root": { +"path": "/", +"pool": "default", +"type": "disk", +}, } self.client.profiles.create(self.profile_name, config, devices) @@ -341,7 +362,11 @@ hostname_file.flush() os.fchmod(hostname_file.fileno(), 0o644) self.copy_in(hostname_file.name, "/etc/hostname") -self.copy_in("/etc/resolv.conf", "/etc/resolv.conf") +if os.path.exists("/run/systemd/resolve/resolv.conf"): +self.copy_in("/run/systemd/resolve/resolv.conf", +"/etc/resolv.conf") +else: +self.copy_in("/etc/resolv.conf", "/etc/resolv.conf") with tempfile.NamedTemporaryFile(mode="w+") as policy_rc_d_file: policy_rc_d_file.write(policy_rc_d) policy_rc_d_file.flush() @@ -481,8 +506,8 @@ data = source_file.read() mode = stat.S_IMODE(os.fstat(source_file.fileno()).st_mode) headers = { -"X-LXD-uid": 0, -"X-LXD-gid": 0, +"X-LXD-uid": "0", +"X-LXD-gid": "0", "X-LXD-mode": "%#o" % mode, } try: === modified file 'lpbuildd/util.py' --- lpbuildd/util.py 2017-11-09 12:15:39 + +++ lpbuildd/util.py 2018-09-05 13:55:08 + @@ -44,3 +44,27 @@ setarch_cmd.append("--uname-2.6") return setarch_cmd + args + + +def get_os_release(): +version_id = None + +with file("/etc/os-release", "r") as fp: +for line in fp: +try: +key, value = line.strip().split("=", 1) +except ValueError: +continue + +if key == "VERSION_ID": +version_id = value.strip('"') +break + +if not version_id: +raise RuntimeError("Cannot
[Launchpad-reviewers] [Merge] lp:~cjwatson/charms/precise/squid-forwardproxy/dns-v4-first into lp:~canonical-launchpad-branches/charms/precise/squid-forwardproxy/trunk
Colin Watson has proposed merging lp:~cjwatson/charms/precise/squid-forwardproxy/dns-v4-first into lp:~canonical-launchpad-branches/charms/precise/squid-forwardproxy/trunk. Commit message: Add dns_v4_first configuration option. Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: Bug #1781970 in launchpad-buildd: "Snap fails to build, 503 proxy error" https://bugs.launchpad.net/launchpad-buildd/+bug/1781970 For more details, see: https://code.launchpad.net/~cjwatson/charms/precise/squid-forwardproxy/dns-v4-first/+merge/354316 PS4.5 doesn't have IPv6 yet, so Squid's default of preferring IPv6 addresses fails. -- Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/charms/precise/squid-forwardproxy/dns-v4-first into lp:~canonical-launchpad-branches/charms/precise/squid-forwardproxy/trunk. === modified file 'config.yaml' --- config.yaml 2016-07-05 11:24:43 + +++ config.yaml 2018-09-05 10:30:22 + @@ -99,3 +99,7 @@ default: '027' description: > Minimum umask which should be enforced while the proxy is running. + dns_v4_first: +type: boolean +default: false +description: If true, prefer IPv4 addresses for dual-stack sites. === modified file 'templates/main_config.template' --- templates/main_config.template 2016-07-05 11:24:43 + +++ templates/main_config.template 2018-09-05 10:30:22 + @@ -19,6 +19,10 @@ snmp_incoming_address {{ config.my_ip_address }} {% endif %} +{% if config.dns_v4_first %} +dns_v4_first on +{% endif %} + umask {{ config.umask }} logformat combined {{ config.log_format }} ___ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp