← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/archive-enable-recalculate-virt into lp:launchpad

 

Review: Approve code



Diff comments:

> === modified file 'lib/lp/soyuz/model/archive.py'
> --- lib/lp/soyuz/model/archive.py	2015-07-08 16:05:11 +0000
> +++ lib/lp/soyuz/model/archive.py	2015-08-27 14:19:30 +0000
> @@ -2022,12 +2022,40 @@
>                  AND BinaryPackageBuild.status = %s;
>              """, params=(status.value, self.id, BuildStatus.NEEDSBUILD.value))
>  
> +    def _recalculateBuildVirtualization(self):
> +        """Update BinaryPackageBuild.virtualized for this archive."""
> +        store = Store.of(self)
> +        if self.require_virtualized:
> +            # We can avoid the Processor join in this case.
> +            builds = store.find(
> +                BinaryPackageBuild,
> +                BinaryPackageBuild.archive == self,
> +                BinaryPackageBuild.status == BuildStatus.NEEDSBUILD)
> +            builds.set(virtualized=True)
> +        else:
> +            store.execute("""
> +                UPDATE BinaryPackageBuild
> +                SET virtualized = NOT Processor.supports_nonvirtualized
> +                FROM Processor
> +                WHERE
> +                    -- insert self.id here
> +                    BinaryPackageBuild.archive = %s
> +                    AND BinaryPackageBuild.processor = Processor.id
> +                    -- Build is in state BuildStatus.NEEDSBUILD (0)
> +                    AND BinaryPackageBuild.status = %s;
> +                """, params=(self.id, BuildStatus.NEEDSBUILD.value))
> +            store.invalidate()

Heh, this time you *do* want BulkUpdate -- it exists exactly for this purpose. But you'll still have to Store.invalidate.

You'll also need to fix BuildQueue.virtualized.

> +
>      def enable(self):
>          """See `IArchive`."""
>          assert self._enabled == False, "This archive is already enabled."
>          assert self.is_active, "Deleted archives can't be enabled."
>          self._enabled = True
>          self._setBuildQueueStatuses(BuildQueueStatus.WAITING)
> +        # Suspended builds may have the wrong virtualization setting (due to
> +        # changes to either Archive.require_virtualized or
> +        # Processor.supports_nonvirtualized) and need to be updated.
> +        self._recalculateBuildVirtualization()
>  
>      def disable(self):
>          """See `IArchive`."""


-- 
https://code.launchpad.net/~cjwatson/launchpad/archive-enable-recalculate-virt/+merge/269371
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References