afdo: Implement kernel afdo verification builders.
As a part of PUpr project, we need to move the publish of new
kernel profiles out of PFQ. This patch implements the builder that
performs the publish. More importantly, this builder adds a new
functionality that old PFQ doesn't have: we will take the latest
kernel profile, try to patch the ebuild, and build kernel to see
if there's any problem with profile, before publishing it.
The patch mainly generalized the functions for
orderfile-verify-toolchain builder to support both orderfile and
kernel AFDO profiles. And also uses new build API for future
transitions.
BUG=chromium:990855,chromium:984153
TEST=https://ci.chromium.org/p/chromeos/builders/general/Try/b8903406507089410256
Change-Id: I5695c4258420ead180943d22a8d1bfa207a3095e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1763922
Tested-by: Tiancong Wang <tcwang@google.com>
Commit-Queue: Tiancong Wang <tcwang@google.com>
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
diff --git a/api/controller/toolchain.py b/api/controller/toolchain.py
index ab6645a..a88f859 100644
--- a/api/controller/toolchain.py
+++ b/api/controller/toolchain.py
@@ -7,50 +7,50 @@
from __future__ import print_function
-import os
-
from chromite.api import validate
-from chromite.lib import cros_logging as logging
-from chromite.lib import gs
+from chromite.api.gen.chromite.api import toolchain_pb2
from chromite.lib import toolchain_util
+_VALID_ARTIFACT_TYPES = [toolchain_pb2.ORDERFILE, toolchain_pb2.KERNEL_AFDO]
+
@validate.require('build_target.name')
+@validate.is_in('artifact_type', _VALID_ARTIFACT_TYPES)
@validate.validation_complete
-def UpdateChromeEbuildWithOrderfile(input_proto, _output_proto, _config):
- """Update Chrome ebuild with most recent unvetted orderfile.
+def UpdateEbuildWithAFDOArtifacts(input_proto, output_proto, _config):
+ """Update Chrome or kernel ebuild with most recent unvetted artifacts.
Args:
- input_proto (UpdateChromeEbuildRequest): The input proto
- _output_proto (UpdateChromeEbuildResponse): Empty output proto
+ input_proto (VerifyAFDOArtifactsRequest): The input proto
+ output_proto (VerifyAFDOArtifactsResponse): The output proto
_config (api_config.ApiConfig): The API call config.
"""
board = input_proto.build_target.name
- toolchain_util.OrderfileUpdateChromeEbuild(board)
+ artifact_type = input_proto.artifact_type
+ if artifact_type is toolchain_pb2.ORDERFILE:
+ status = toolchain_util.OrderfileUpdateChromeEbuild(board)
+ else:
+ status = toolchain_util.AFDOUpdateKernelEbuild(board)
+ output_proto.status = status
+@validate.require('build_target.name')
+@validate.is_in('artifact_type', _VALID_ARTIFACT_TYPES)
@validate.validation_complete
-def UploadVettedOrderfile(_input_proto, output_proto, _config):
+def UploadVettedAFDOArtifacts(input_proto, output_proto, _config):
"""Upload a vetted orderfile to GS bucket.
Args:
- _input_proto (UploadVettedOrderfileRequest): Empty input proto
- output_proto (UploadVettedOrderfileResponse): The output proto
+ input_proto (VerifyAFDOArtifactsRequest): The input proto
+ output_proto (VerifyAFDOArtifactsResponse): The output proto
_config (api_config.ApiConfig): The API call config.
"""
- gs_context = gs.GSContext()
- orderfile = toolchain_util.FindLatestChromeOrderfile(
- toolchain_util.ORDERFILE_GS_URL_UNVETTED)
+ board = input_proto.build_target.name
+ if input_proto.artifact_type is toolchain_pb2.ORDERFILE:
+ artifact_type = 'orderfile'
+ else:
+ artifact_type = 'kernel_afdo'
- if gs_context.Exists(
- os.path.join(toolchain_util.ORDERFILE_GS_URL_VETTED, orderfile)):
- output_proto.status = False
- return
-
- source_url = os.path.join(toolchain_util.ORDERFILE_GS_URL_UNVETTED, orderfile)
- dest_url = os.path.join(toolchain_util.ORDERFILE_GS_URL_VETTED, orderfile)
-
- logging.info('Copying tarball from %s to %s', source_url, dest_url)
- gs_context.Copy(source_url, dest_url, acl='public-read')
- output_proto.status = True
+ output_proto.status = toolchain_util.UploadAndPublishVettedAFDOArtifacts(
+ artifact_type, board)