blob: c4b66dc02647b726040904d0e4f8a04a4b146169 [file] [log] [blame]
// Copyright 2018 The LUCI Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Schemas for service configs.
syntax = "proto3";
package buildbucket;
import "google/protobuf/duration.proto";
import "go.chromium.org/luci/buildbucket/proto/project_config.proto";
option go_package = "go.chromium.org/luci/buildbucket/proto;buildbucketpb";
// Schema of settings.cfg file, a service config.
message SettingsCfg {
// Swarmbucket settings.
SwarmingSettings swarming = 1;
LogDogSettings logdog = 2;
ResultDBSettings resultdb = 4;
ExperimentSettings experiment = 5;
CipdSettings cipd = 6;
// List of Gerrit hosts to force git authentication for.
//
// By default public hosts are accessed anonymously, and the anonymous access
// has very low quota. Context needs to know all such hostnames in advance to
// be able to force authenticated access to them.
repeated string known_public_gerrit_hosts = 3;
// List of known backend configurations.
repeated BackendSetting backends = 7;
// A swarming_host -> backend_target map.
// It's used during the raw swarming to swarming based backend migration to
// derive a backend config from swarming related configs.
// So we could control the migration process behind the scene.
map<string, string> swarming_backends = 8;
// Custom metrics.
//
// Global config to register custom build metrics that more than one LUCI
// projects may report data to.
// Therefore, the metric names must be unique globally.
repeated CustomMetric custom_metrics = 9;
}
// Backend setting.
message BackendSetting {
// Target backend. e.g. "swarming://chromium-swarm".
string target = 1;
// hostname for the target backend. e.g. chromium-swarm.appspot.com
string hostname = 2;
// The associated UpdateBuildTask pubsub id for this task backend.
// This must be set in order for buildbucket to recieve task updates and send
// a pubsup topic that the task backend can use to send updates to.
// This id is provided by the backend owner, but added to buildbucket's service
// config by the buildbucket team.
// Buildbucket will subscribe to the pubsub subscription, which itself is
// subscribed to the topic that task backends send messages to.
// i.e.
// For this pubsub subscription:
// project/cr-buildbucket/subscriptions/chormium-swarm-backend
// and topic:
// project/cr-buildbucket/topics/chormium-swarm-backend
// The pubsub_id would be:
// chormium-swarm-backend
//
// DEPRECATED: please set into `full_mode` field.
string pubsub_id = 3 [deprecated = true];
// Setting for the fetch tasks cron job.
message BuildSyncSetting {
// Number of shards for Buildbucket to save the update_time of the builds on
// this backend.
//
// In Build model, we need to keep an index on the build update time in order
// to get all builds it haven't heard for a while.
// To avoid hotspotting, a new computed property NextBackendSyncTime is added
// for indexing, with format
// <backend_target>--<project>--<shard index>--<update_time>.
//
// Because some backends serves significantly larger amount of builds than
// other backends, we need different number of shards for each backend.
//
// Must be greater than or equal to 0, while 0 effectively means 1 shard.
//
// Note: when updating this field, the new number MUST be greater than the
// old one.
int32 shards = 1;
// How often should a incomplete build get updated. If Buildbucket doesn't
// hear from this build for sync_interval, it will sync it with its backend
// task.
//
// Buildbucket runs a cron job to find builds to sync every minute, so
// sync_interval_seconds must be greater than or equal to 60.
//
// If unset, a default threshold of 5min will be applied.
int32 sync_interval_seconds = 2;
// In the future, we could also add backoff factor here when have a use case.
}
// DEPRECATED: please set into `full_mode` field.
BuildSyncSetting build_sync_setting = 4 [deprecated = true];
// The corresponding backend should be a full-featured `TaskBackend`
// implementation.
message FullMode {
// The associated UpdateBuildTask pubsub id for this task backend.
// This must be set in order for buildbucket to recieve task updates and send
// a pubsup topic that the task backend can use to send updates to.
// This id is provided by the backend owner, but added to buildbucket's service
// config by the buildbucket team.
// Buildbucket will subscribe to the pubsub subscription, which itself is
// subscribed to the topic that task backends send messages to.
// i.e.
// For this pubsub subscription:
// project/cr-buildbucket/subscriptions/chormium-swarm-backend
// and topic:
// project/cr-buildbucket/topics/chormium-swarm-backend
// The pubsub_id would be:
// chormium-swarm-backend
string pubsub_id = 1;
// The setting for syncing backend tasks.
BuildSyncSetting build_sync_setting = 2;
// If set to true, visiting "cr-buildbucket.appspot.com/build/<build_id>"
// will be redirected to the corresponding task page instead of the Milo
// build page.
//
// To visit the Milo build page with this configuration on, please use
// "ci.chromium.org/b/<build_id>".
bool redirect_to_task_page = 3;
// If set to true, Buildbucket will set the final build status to SUCCESS
// if the backend task is SUCCESS, regardless the build's output status.
//
// For standard backends like Swarming, the build should always finish
// before the backend task - unless the task crashes or being killed.
// So in the case that build output status is not ended, Buildbucket
// sets the build's final status with the task's status -if it ends
// with a non SUCCESS status. But if the task has
// ended with a SUCCESS status while the build is still running, Buildbucket
// considers that impossible and sets the build to INFRA_FAILURE.
//
// But for other backends e.g. Skia, we cannot have the assumption that
// build always finishes before task. And to them a successful task always
// means a successful build.
bool succeed_build_if_task_is_succeeded = 4;
}
// The corresponding backend should be a `TaskBackendLite` implementation,
// where it doesn't support the task update and sync.
message LiteMode {
}
// The mode of the backend.
oneof Mode {
FullMode full_mode = 5;
LiteMode lite_mode = 6;
}
// Maximum time for Buildbucket to retry creating a task.
//
// Default timeout is 10 minutes.
//
// If the timeout is reached, the build is marked as INFRA_FAILURE status.
google.protobuf.Duration task_creating_timeout = 7;
}
// Swarmbucket settings.
message SwarmingSettings {
reserved 1; // default_hostname
// Swarmbucket build URLs will point to this Milo instance.
string milo_hostname = 2;
// These caches are available to all builders implicitly.
// A builder may override a cache specified here.
repeated BuilderConfig.CacheEntry global_caches = 4;
// CIPD package. Does not specify installation path.
message Package {
// CIPD package name, e.g. "infra/python/cpython/${platform}"
string package_name = 1;
// CIPD instance version, e.g. "version:2.7.15.chromium14".
// Used for non-canary builds.
string version = 2;
// CIPD instance version for canary builds.
// Defaults to version.
string version_canary = 3;
// Include in builders matching the predicate.
BuilderPredicate builders = 4;
// Subdirectory to install the package into, relative to the installation
// root. Useful if installing two packages at the same root would conflict.
string subdir = 5;
// Omit this package from the build having any of these experiments.
repeated string omit_on_experiment = 6;
// If non-empty, include this package only on builds which have any of these
// experiments set. `omit_on_experiment` takes precedence if an experiment
// is in both of these lists.
repeated string include_on_experiment = 7;
}
// Packages available to the user executable in $PATH.
// Installed in "{TASK_RUN_DIR}/cipd_bin_packages".
// "{TASK_RUN_DIR}/cipd_bin_packages" and
// "{TASK_RUN_DIR}/cipd_bin_packages/bin" are prepended to $PATH.
repeated Package user_packages = 5;
reserved 6; // luci_runner_package
// Package of buildbucket agent,
// https://chromium.googlesource.com/infra/luci/luci-go/+/HEAD/buildbucket/cmd/bbagent
// used to run LUCI executables.
Package bbagent_package = 8;
// CIPD package of kitchen binary. DEPRECATED. TODO(nodir): remove.
Package kitchen_package = 7;
// Package of alternative buildbucket agent sources.
// They should only be used in certain situations (i.e. in an experiment),
// so they should have constraints on either omit_on_experiment
// or include_on_experiment.
repeated Package alternative_agent_packages = 9;
// Packages for bbagent to use.
// Installed in "{TASK_RUN_DIR}/bbagent_utility_packages".
repeated Package bbagent_utility_packages = 10;
}
message LogDogSettings {
// Hostname of the LogDog instance to use, e.g. "logs.chromium.org".
string hostname = 1;
}
// ExperimentSettings controls all well-known global experiment values.
message ExperimentSettings {
message Experiment {
// The name of the global experiment.
string name = 1;
// The default_value (% chance, 0 - 100) of the global experiment.
//
// This must be greater than or equal to minimum_value.
int32 default_value = 2;
// The minimum_value (% chance, 0 - 100) of the global experiment.
//
// This will override lower Builder-defined experiment values.
int32 minimum_value = 3;
// Allows temporary exclusion of builders from the experiment.
// Each line here should have a corresponding bug to remove the exclusion.
//
// If a builder is excluded from this experiment, it acts as though
// default_value and minimum_value are both 0.
BuilderPredicate builders = 4;
// If this is true it means that the experiment has no effect, and is safe
// to stop setting in user configs. Additionally, Buildbucket will stop
// setting this experiment negatively on Builds.
//
// When removing a global experiment, set this to true rather than removing
// the experiment entirely, because Buildbucket still needs this to permit
// (and ignore) user configs which still mention reserved experiments (e.g.
// if we have "luci.something" which someone explicitly specifies, and we
// ramp it to 100% and remove it from the global spec, Buildbucket will
// start complaining that users are using a reserved experiment name, rather
// than just ignoring it).
//
// If inactive experiments appear in user configurations, it may cause
// warnings to be printed e.g. at config validation time and/or on the LUCI
// UI, etc.
bool inactive = 5;
}
repeated Experiment experiments = 1;
}
// A predicate for a builder.
message BuilderPredicate {
// OR-connected list of regular expressions for a string
// "{project}/{bucket}/{builder}".
// Each regex is wrapped in ^ and $ automatically.
// Examples:
//
// # All builders in "chromium" project
// regex: "chromium/.+"
// # A specific builder.
// regex: "infra/ci/infra-continuous-trusty-64"
//
// Defaults to [".*"].
repeated string regex = 1;
// Like regex field, but negation. Negation always wins.
repeated string regex_exclude = 2;
}
message ResultDBSettings {
// Hostname of the ResultDB instance to use, e.g. "results.api.cr.dev".
string hostname = 1;
}
message CipdSettings {
message Source {
// CIPD package name, e.g. "infra/tools/cipd/${platform}"
string package_name = 2;
// CIPD instance version, e.g. "L34sd94gsdgs4gsd" or some hash.
// Used for non-canary builds.
string version = 3;
// CIPD instance version for canary builds.
// Defaults to version.
string version_canary = 4;
}
// default CIPD server to use for this setting configuration,
// e.g. "chrome-infra-packages.appspot.com".
string server = 1;
// Source of the cipd package itself
Source source = 2;
}
// A CustomMetricBase tells the base metric of a given custom metric.
//
// Buildbucket will determine what to report to and the annotation for
// a given CustomMetric, based on the specified metric base. Visit
// http://shortn/_6bc0aXIouD to find all the supported metric bases.
enum CustomMetricBase {
CUSTOM_METRIC_BASE_UNSET = 0;
// Build event metrics.
// A counter metric for Build creation.
// Default metric field: None.
CUSTOM_METRIC_BASE_CREATED = 1;
// A counter metric for Build start..
// Default metric field: None.
CUSTOM_METRIC_BASE_STARTED = 2;
// A counter metric for Build completion..
// Default metric field: status.
CUSTOM_METRIC_BASE_COMPLETED = 3;
// The time elapsed from the build creation to the completion.
// Default metric field: status.
CUSTOM_METRIC_BASE_CYCLE_DURATIONS = 4;
// The time elapsed from the build start to the completion.
// Default metric field: status.
CUSTOM_METRIC_BASE_RUN_DURATIONS = 5;
// The time elapsed from the build creation to the start.
// Default metric field: None.
CUSTOM_METRIC_BASE_SCHEDULING_DURATIONS = 6;
// Builder metrics.
// The age of the oldest build that has been scheduled but not started yet
// (aka age of the oldest pending build).
// Default metric field: None.
CUSTOM_METRIC_BASE_MAX_AGE_SCHEDULED = 7;
// Number of Builds for each Build status.
// Default metric field: status.
CUSTOM_METRIC_BASE_COUNT = 8;
// Number of consecutive failures since the last successful build.
// Default metric field: status.
CUSTOM_METRIC_BASE_CONSECUTIVE_FAILURE_COUNT = 9;
}
// CustomMetric is a metric object that collects a series of data
// exported by a given metric class.
//
// All metrics are using luci.Builder schema at https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/buildbucket/metrics/builder.go;l=26-48;drc=b77d0c2bd4bbb536f8e349e993e3ca18818c51e7.
//
// Builders can then reference a custom metric by name to report their build
// metrics.
//
// Note: if you ever want to remove a custom metric, the best practice is to
// remove its references from builders first, then remove it from the service
// config. Otherwise any change to a builder config refers to this custom metric
// would fail validation (for using an unregistered custom metric). But this
// is not a hard error for build creation or event reporting: missing metric
// would just be silently ignored.
message CustomMetric {
// Name of the metric.
//
// Each builder that uses this metric needs to add a CustomMetricDefinition entry in
// their config, with the same name as here.
//
// Must be unique globally across all LUCI projects.
// Must conform to ^(/[a-zA-Z0-9_-]+)+$ (See
// https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/common/tsmon/registry/registry.go;l=33;drc=b77d0c2bd4bbb536f8e349e993e3ca18818c51e7).
string name = 1;
// Description of the metric.
string description = 2;
// Metric field names in addtion to the default ones.
//
// Default metric fields can be found in CustomMetricBase comments.
//
// Each builder that uses this metric must specify how to populate each
// field's value in their configurations, see CustomMetricDefinition.Fields.
//
// Must not have duplicates.
//
// Custom builder metric cannot have any custom fields in addition to their
// defaults, i.e. if it's one of
// * CUSTOM_METRIC_BASE_MAX_AGE_SCHEDULED
// * CUSTOM_METRIC_BASE_COUNT
// * CUSTOM_METRIC_BASE_CONSECUTIVE_FAILURE_COUNT
//
// The value type of all metric fields is always string.
// Each Field must conform to ^[A-Za-z_][A-Za-z0-9_]*$ (See
// https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/common/tsmon/registry/registry.go;l=34;drc=b77d0c2bd4bbb536f8e349e993e3ca18818c51e7).
//
// Note that the possible values of each field should be bounded.
// So below fields should not be included:
// * build id
// * any timestamp (e.g. build's creation time)
// * any markdown strings (e.g. build's summary_markdown)
// * any log strings (e.g. build's output logs)
// * any PII
// * build's gitiles commit hash
// * build's gerrit change number
// * etc
repeated string extra_fields = 3;
// Metric class determines which data to be collected and reported
// to the metric.
oneof class {
CustomMetricBase metric_base = 4;
}
}