Skip to content

Commit

Permalink
Merge upstream changes from repo https://chromium.googlesource.com/in…
Browse files Browse the repository at this point in the history
…fra/infra branch main
  • Loading branch information
web-flow authored Apr 17, 2022
2 parents 4d57dd6 + 34ecdc8 commit 241b845
Show file tree
Hide file tree
Showing 395 changed files with 54,585 additions and 33,706 deletions.
6 changes: 3 additions & 3 deletions 3pp/nsjail/3pp.pb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ create {
repo: "https://github.com/google/nsjail"
tag_pattern: "%s"

# We would like to use a fixed version of nsjail so that we can keep a
# copy of its config proto in our codebase. Fixed to 3.0 for now.
version_restriction: { op: EQ val: "3.0"}
# We would like to use a fixed version of nsjail so that we can keep
# its config stable in our codebase. Fixed to 3.1 for now.
version_restriction: { op: EQ val: "3.1"}
}
patch_dir: "patches"
patch_version: "chromium.1"
Expand Down
8 changes: 4 additions & 4 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ deps = {

"infra/luci":
"{chromium_git}/infra/luci/luci-py@" +
"bd51a9097394ef662736f9ec0ea6cfeb4c7bd09a",
"6a2dbb0f0bfe491689d64069dc93d563c4f10f14",

# This unpinned dependency is present because it is used by the trybots for
# the recipes-py repo; They check out infra with this at HEAD, and then apply
Expand All @@ -39,15 +39,15 @@ deps = {

"infra/go/src/go.chromium.org/luci":
"{chromium_git}/infra/luci/luci-go@" +
"01cb6ea19c643c03eb9fae45757b14c6f57ca343",
"01a09a2dad397ae39e45b2c1d9f7bcb3f8bbd11f",

"infra/go/src/go.chromium.org/chromiumos/config":
"{chromium_git}/chromiumos/config@" +
"dad32402130e08783ed01aa67c69bfbd7c2a3d61",
"401d6f02d9efcd1e458f427ae4614610e729bdf7",

"infra/go/src/go.chromium.org/chromiumos/infra/proto":
"{chromium_git}/chromiumos/infra/proto@" +
"67347c16c08bd5670ec528b9dac9767ad4b692f8",
"87a479a140520b572d396dbf7d231bb1c816b1d3",

# Appengine third_party DEPS
"infra/appengine/third_party/bootstrap":
Expand Down
20 changes: 0 additions & 20 deletions appengine/cr-buildbucket/PRESUBMIT.py

This file was deleted.

48 changes: 8 additions & 40 deletions appengine/cr-buildbucket/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@
from go.chromium.org.luci.buildbucket.proto import service_config_pb2
import errors

CURRENT_BUCKET_SCHEMA_VERSION = 12
CURRENT_BUCKET_SCHEMA_VERSION = 13
ACL_SET_NAME_RE = re.compile('^[a-z0-9_]+$')

# The default percentage of builds that are marked as canary.
# This number is relatively high so we treat canary seriously and that we have
# a strong signal if the canary is broken.
_DEFAULT_CANARY_PERCENTAGE = 10

# The memcache key for get_all_bucket_ids_async cache.
_MEMCACHE_ALL_BUCKET_IDS_KEY = 'all_bucket_ids_v1'
# Expiration time for get_all_bucket_ids_async cache.
Expand Down Expand Up @@ -118,12 +113,6 @@ def validate_buildbucket_cfg(cfg, ctx):

validate_access_list(acl_set.acls, ctx)

mixin_ctx = validation.Context( # pragma: no cover
on_message=lambda msg: ctx.msg(msg.severity, '%s', msg.text))
swarmingcfg.validate_builder_mixins(cfg.builder_mixins, mixin_ctx)
mixins_are_valid = not mixin_ctx.result().has_errors
mixin_by_name = {m.name: m for m in cfg.builder_mixins}

bucket_names = set()

for i, bucket in enumerate(cfg.buckets):
Expand Down Expand Up @@ -151,8 +140,7 @@ def validate_buildbucket_cfg(cfg, ctx):
if bucket.HasField('swarming'): # pragma: no cover
with ctx.prefix('swarming: '):
swarmingcfg.validate_project_cfg(
bucket.swarming, well_known_experiments, mixin_by_name,
mixins_are_valid, ctx
bucket.swarming, well_known_experiments, ctx
)


Expand Down Expand Up @@ -475,11 +463,8 @@ def cron_update_buckets():
"""Synchronizes bucket entities with configs fetched from luci-config.
When storing in the datastore, inlines the referenced ACL sets and clears
the acl_sets message field. Also inlines swarmbucket builder defaults and
mixins and clears Builder.mixins field.
the acl_sets message field.
"""
import flatten_swarmingcfg

config_map = config.get_project_configs(
cfg_path(), project_config_pb2.BuildbucketCfg
)
Expand Down Expand Up @@ -507,7 +492,6 @@ def cron_update_buckets():
project_cfg.SerializeToString(deterministic=True)
).hexdigest()
acl_sets_by_name = {a.name: a for a in project_cfg.acl_sets}
builder_mixins_by_name = {m.name: m for m in project_cfg.builder_mixins}

for bucket_cfg in project_cfg.buckets:
bucket_key = Bucket.make_key(
Expand Down Expand Up @@ -540,31 +524,15 @@ def cron_update_buckets():
builders_to_delete = set(builders)
builders_to_put = []
if bucket_cfg.HasField('swarming'):
# Pull builder defaults out and apply defaults.
defaults = bucket_cfg.swarming.builder_defaults
bucket_cfg.swarming.ClearField('builder_defaults')
if not any(d.startswith('pool:') for d in defaults.dimensions):
defaults.dimensions.append(
'pool:luci.%s.%s' %
(project_id, short_bucket_name(bucket_cfg.name))
)
defaults.swarming_host = (
defaults.swarming_host or bucket_cfg.swarming.hostname
)

f = 'task_template_canary_percentage'
if not defaults.HasField(f) and bucket_cfg.swarming.HasField(f):
defaults.task_template_canary_percentage.CopyFrom(
bucket_cfg.swarming.task_template_canary_percentage
)

for b in bucket_cfg.swarming.builders:
flatten_swarmingcfg.flatten_builder(
b, defaults, builder_mixins_by_name
)
builder_key = Builder.make_key(project_id, bucket_key.id(), b.name)
builders_to_delete.discard(builder_key)
builder = builders.get(builder_key)
if not any(d.startswith('pool:') for d in b.dimensions):
b.dimensions.append(
'pool:luci.%s.%s' %
(project_id, short_bucket_name(bucket_cfg.name))
)
if builder and builder.config_hash == Builder.compute_hash(b):
continue
builders_to_put.append(b)
Expand Down
21 changes: 16 additions & 5 deletions appengine/cr-buildbucket/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import buildtags
import config
import experiments
import flatten_swarmingcfg
import errors
import events
import model
Expand Down Expand Up @@ -238,7 +237,8 @@ def compute_tag_set(sbr):
def compute_experiments(sbr, builder_cfg, settings):
"""Returns a Dict[str, bool] of enabled/disabled experiments."""
global_exps = []
ignored_exps = []
# not enable BBAGENT_DOWNLOAD_CIPD for swarmbucket or v1 related flow.
ignored_exps = [experiments.BBAGENT_DOWNLOAD_CIPD]

for exp in settings.experiment.experiments:
if exp.inactive:
Expand Down Expand Up @@ -663,6 +663,19 @@ def _apply_global_settings(settings, build_proto):
_add_configured_cache(build_proto, c)


def _read_properties(recipe):
"""Parses build properties from the recipe message.
Expects the message to be valid.
"""
result = dict(p.split(':', 1) for p in recipe.properties)
for p in recipe.properties_j: # pragma: no cover
k, v = p.split(':', 1)
parsed = json.loads(v)
result[k] = parsed
return result


@ndb.tasklet
def _apply_builder_config_async(builder_cfg, build_proto, exps):
"""Applies project_config_pb2.Builder to a builds_pb2.Build."""
Expand Down Expand Up @@ -694,9 +707,7 @@ def _apply_builder_config_async(builder_cfg, build_proto, exps):
build_proto.exe.cipd_version = (
builder_cfg.recipe.cipd_version or 'refs/heads/master'
)
build_proto.input.properties.update(
flatten_swarmingcfg.read_properties(builder_cfg.recipe)
)
build_proto.input.properties.update(_read_properties(builder_cfg.recipe))
build_proto.input.properties['recipe'] = builder_cfg.recipe.name
build_proto.infra.recipe.cipd_package = builder_cfg.recipe.cipd_package
build_proto.infra.recipe.name = builder_cfg.recipe.name
Expand Down
1 change: 0 additions & 1 deletion appengine/cr-buildbucket/flatten_swarmingcfg.py

This file was deleted.

74 changes: 1 addition & 73 deletions appengine/cr-buildbucket/legacy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import config
import creation
import errors
import flatten_swarmingcfg
import model
import search
import service
Expand Down Expand Up @@ -165,36 +164,7 @@ def assert_object(name, value):
assert_object('swarming', swarming)
swarming = copy.deepcopy(swarming)

override_builder_cfg_data = swarming.pop('override_builder_cfg', None)
if override_builder_cfg_data is not None:
assert_object('swarming.override_builder_cfg', override_builder_cfg_data)
if 'build_numbers' in override_builder_cfg_data:
bad(
'swarming.override_builder_cfg parameter '
'cannot override build_numbers'
)

override_builder_cfg = project_config_pb2.Builder()
try:
protoutil.merge_dict(override_builder_cfg_data, override_builder_cfg)
except TypeError as ex:
bad('swarming.override_builder_cfg parameter: %s', ex)
if override_builder_cfg.name:
bad('swarming.override_builder_cfg cannot override builder name')
if override_builder_cfg.mixins:
bad('swarming.override_builder_cfg cannot use mixins')
if any(d.startswith('pool:') for d in override_builder_cfg.dimensions):
logging.warning(
'pool is being overridden: %s', override_builder_cfg.dimensions
)
if 'pool:' in override_builder_cfg.dimensions:
bad('swarming.override_builder_cfg cannot remove pool dimension')
with ctx.prefix('swarming.override_builder_cfg parameter: '):
swarmingcfg.validate_builder_cfg(
override_builder_cfg, set(), [], False, ctx
)

if swarming:
if swarming: # pragma: no cover
bad('unrecognized keys in swarming param: %r', swarming.keys())

properties = params.get('properties')
Expand Down Expand Up @@ -317,51 +287,9 @@ def put_request_message_to_build_request(put_request, well_known_experiments):
parameters=parameters,
lease_expiration_date=lease_expiration_date,
pubsub_callback_auth_token=pubsub_callback_auth_token,
override_builder_cfg=_override_builder_cfg_func(parameters),
)


def _override_builder_cfg_func(parameters):
"""Returns a function that overrides a Builder config.
May return None.
See creation.BuildRequest.override_builder_cfg.
"""
swarming_param = parameters.get(_PARAM_SWARMING) or {}
overrides_dict = swarming_param.get('override_builder_cfg')
if not overrides_dict:
return None

base_overrides = project_config_pb2.Builder()
protoutil.merge_dict(overrides_dict, base_overrides)

def _merge(cfg):
over = project_config_pb2.Builder()
over.CopyFrom(base_overrides)

# handle the case where the caller is updating the old recipe message but
# the `cfg` uses the new `exe` field.
if cfg.HasField('exe') and over.HasField('recipe'):
exe, recipe = over.exe, over.recipe

new_props = json.loads(over.properties or '{}')
new_props.update(flatten_swarmingcfg.read_properties(recipe))

if recipe.name:
new_props['recipe'] = recipe.name

exe.cipd_package = recipe.cipd_package
exe.cipd_version = recipe.cipd_version

over.ClearField('recipe')
over.properties = json.dumps(new_props)

return flatten_swarmingcfg.merge_builder(cfg, over)

return _merge


def builds_to_messages(builds, include_lease_key=False):
"""Converts model.Build objects to BuildMessage objects.
Expand Down
Loading

0 comments on commit 241b845

Please sign in to comment.