launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #16922
[Merge] lp:~wgrant/launchpad/ppa-reset-2.0-model into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/ppa-reset-2.0-model into lp:launchpad with lp:~wgrant/launchpad/ppa-reset-2.0-db as a prerequisite.
Commit message:
Basic model code for the new virtual builder reset protocol columns.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/ppa-reset-2.0-model/+merge/223396
Basic model code for the new virtual builder reset protocol columns added in https://code.launchpad.net/~wgrant/launchpad/ppa-reset-2.0-db/+merge/223395.
The only logic is to set date_clean_status_changed when clean_status changes, and to force clean_status to dirty when a builder is enabled.
--
https://code.launchpad.net/~wgrant/launchpad/ppa-reset-2.0-model/+merge/223396
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/ppa-reset-2.0-model into lp:launchpad.
=== modified file 'lib/lp/buildmaster/enums.py'
--- lib/lp/buildmaster/enums.py 2013-10-31 07:30:54 +0000
+++ lib/lp/buildmaster/enums.py 2014-06-17 12:41:36 +0000
@@ -6,6 +6,8 @@
__metaclass__ = type
__all__ = [
+ 'BuilderCleanStatus',
+ 'BuilderResetProtocol',
'BuildStatus',
'BuildQueueStatus',
'BuildFarmJobType',
@@ -183,3 +185,33 @@
The job is suspended, so should not be run.
""")
+
+
+class BuilderCleanStatus(DBEnumeratedType):
+
+ CLEAN = DBItem(0, """
+ Clean
+
+ The builder slave is ready for use.
+ """)
+
+ DIRTY = DBItem(1, """
+ Dirty
+
+ The builder slave is dirty and needs to be cleaned before use.
+ """)
+
+ CLEANING = DBItem(2, """
+ Cleaning
+
+ The builder slave is being cleaned.
+ """)
+
+
+class BuilderResetProtocol(DBEnumeratedType):
+
+ PROTO_1_1 = DBItem(11, """
+ 1.1
+
+ Original synchronous protocol with vm_host and buildd_name.
+ """)
=== modified file 'lib/lp/buildmaster/interfaces/builder.py'
--- lib/lp/buildmaster/interfaces/builder.py 2014-04-23 10:50:06 +0000
+++ lib/lp/buildmaster/interfaces/builder.py 2014-06-17 12:41:36 +0000
@@ -40,6 +40,8 @@
)
from zope.schema import (
Bool,
+ Choice,
+ Datetime,
Int,
List,
Text,
@@ -49,6 +51,10 @@
from lp import _
from lp.app.validators.name import name_validator
from lp.app.validators.url import builder_url_validator
+from lp.buildmaster.enums import (
+ BuilderCleanStatus,
+ BuilderResetProtocol,
+ )
from lp.registry.interfaces.role import IHasOwner
from lp.services.fields import (
PersonChoice,
@@ -181,6 +187,22 @@
title=_('Version'), required=False,
description=_('The version of launchpad-buildd on the slave.')))
+ clean_status = exported(Choice(
+ title=_("Clean status"), vocabulary=BuilderCleanStatus, readonly=True,
+ description=_("The readiness of the slave to take a job.")))
+
+ date_clean_status_changed = exported(Datetime(
+ title=_("Date clean status changed"), readonly=True,
+ description=_("The date the builder's clean status last changed.")))
+
+ vm_reset_protocol = exported(Choice(
+ title=_("VM reset protocol"), vocabulary=BuilderResetProtocol,
+ readonly=False,
+ description=_("The protocol version for resetting the VM.")))
+
+ def setCleanStatus(status):
+ """Update the clean status."""
+
def gotFailure():
"""Increment failure_count on the builder."""
=== modified file 'lib/lp/buildmaster/model/builder.py'
--- lib/lp/buildmaster/model/builder.py 2013-11-28 09:12:45 +0000
+++ lib/lp/buildmaster/model/builder.py 2014-06-17 12:41:36 +0000
@@ -32,7 +32,11 @@
from zope.security.proxy import removeSecurityProxy
from lp.app.errors import NotFoundError
-from lp.buildmaster.enums import BuildQueueStatus
+from lp.buildmaster.enums import (
+ BuilderCleanStatus,
+ BuilderResetProtocol,
+ BuildQueueStatus,
+ )
from lp.buildmaster.interfaces.builder import (
IBuilder,
IBuilderSet,
@@ -45,7 +49,10 @@
)
from lp.registry.interfaces.person import validate_public_person
from lp.services.database.bulk import load
+from lp.services.database.constants import UTC_NOW
+from lp.services.database.datetimecol import UtcDateTimeCol
from lp.services.database.decoratedresultset import DecoratedResultSet
+from lp.services.database.enumcol import EnumCol
from lp.services.database.interfaces import (
ISlaveStore,
IStore,
@@ -92,6 +99,10 @@
active = BoolCol(dbName='active', notNull=True, default=True)
failure_count = IntCol(dbName='failure_count', default=0, notNull=True)
version = StringCol(dbName='version')
+ clean_status = EnumCol(
+ enum=BuilderCleanStatus, default=BuilderCleanStatus.DIRTY)
+ vm_reset_protocol = EnumCol(enum=BuilderResetProtocol)
+ date_clean_status_changed = UtcDateTimeCol()
# The number of times a builder can consecutively fail before we
# reset its current job.
@@ -113,6 +124,7 @@
self._builderok = value
if value is True:
self.resetFailureCount()
+ self.setCleanStatus(BuilderCleanStatus.DIRTY)
builderok = property(_getBuilderok, _setBuilderok)
@@ -173,6 +185,11 @@
"""See IBuilder"""
return getUtility(IBuildQueueSet).getByBuilder(self)
+ def setCleanStatus(self, status):
+ """See `IBuilder`."""
+ self.clean_status = status
+ self.date_clean_status_changed = UTC_NOW
+
def failBuilder(self, reason):
"""See IBuilder"""
# XXX cprov 2007-04-17: ideally we should be able to notify the
=== modified file 'lib/lp/buildmaster/tests/test_builder.py'
--- lib/lp/buildmaster/tests/test_builder.py 2013-11-28 12:23:01 +0000
+++ lib/lp/buildmaster/tests/test_builder.py 2014-06-17 12:41:36 +0000
@@ -7,6 +7,7 @@
from zope.security.proxy import removeSecurityProxy
from lp.buildmaster.enums import (
+ BuilderCleanStatus,
BuildQueueStatus,
BuildStatus,
)
@@ -60,6 +61,19 @@
builder.builderok = True
self.assertEqual(0, builder.failure_count)
+ def test_setting_builderok_dirties(self):
+ builder = removeSecurityProxy(self.factory.makeBuilder())
+ builder.builderok = False
+ builder.setCleanStatus(BuilderCleanStatus.CLEAN)
+ builder.builderok = True
+ self.assertEqual(BuilderCleanStatus.DIRTY, builder.clean_status)
+
+ def test_setCleanStatus(self):
+ builder = self.factory.makeBuilder()
+ self.assertEqual(BuilderCleanStatus.DIRTY, builder.clean_status)
+ builder.setCleanStatus(BuilderCleanStatus.CLEAN)
+ self.assertEqual(BuilderCleanStatus.CLEAN, builder.clean_status)
+
def test_handleFailure_increments_failure_count(self):
builder = self.factory.makeBuilder()
self.assertEqual(0, builder.failure_count)
=== modified file 'lib/lp/soyuz/stories/webservice/xx-builders.txt'
--- lib/lp/soyuz/stories/webservice/xx-builders.txt 2013-11-28 06:46:11 +0000
+++ lib/lp/soyuz/stories/webservice/xx-builders.txt 2014-06-17 12:41:36 +0000
@@ -29,6 +29,8 @@
...
active
builderok
+ clean_status
+ date_clean_status_changed
failnotes
failure_count
manual
@@ -39,6 +41,7 @@
version
virtualized
vm_host
+ vm_reset_protocol
Changing builder properties
Follow ups