go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/deploy/api/modelpb/asset.proto (about) 1 // Copyright 2022 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 syntax = "proto3"; 16 17 package deploy.model; 18 19 option go_package = "go.chromium.org/luci/deploy/api/modelpb"; 20 21 import "google/protobuf/timestamp.proto"; 22 import "google/rpc/status.proto"; 23 24 import "go.chromium.org/luci/deploy/api/modelpb/actuation.proto"; 25 import "go.chromium.org/luci/deploy/api/modelpb/artifact.proto"; 26 import "go.chromium.org/luci/deploy/api/modelpb/deployment.proto"; 27 28 29 // Asset represents a Cloud resource (or a bunch of resources) actuated as 30 // a single unit. 31 message Asset { 32 // Unique ID of this asset. 33 // 34 // Defines the asset type (in particular what oneof branch is expected to 35 // be populated in AssetState). 36 // 37 // Matches full resource name of the asset's root resource per Google Cloud 38 // API conventions. For now only Appengine services are supported with asset 39 // ID being "apps/<app-id>". 40 string id = 1; 41 42 // The snapshot of the most recent actuation. 43 // 44 // This is the most recent actuation. Most of the time it will be an actuation 45 // that made SKIP_UPTODATE decision (since most of the time assets are 46 // up-to-date). 47 // 48 // May still be in-flight. 49 Actuation last_actuation = 2; 50 51 // The last actuation decision regarding this asset. 52 // 53 // It is the decision that was made by the `last_actuation` when it started. 54 ActuationDecision last_decision = 3; 55 56 // The snapshot of the most recent actuation with ACTUATE_* decision. 57 // 58 // It is the actuation that changed (or attempted to change) this asset the 59 // last time. 60 // 61 // May still be in-flight. 62 Actuation last_actuate_actuation = 4; 63 64 // The last ACTUATE_* actuation decision regarding this asset. 65 // 66 // It is the decision that was made by the `last_actuate_actuation` when it 67 // started. 68 ActuationDecision last_actuate_decision = 5; 69 70 // Asset configuration as defined in the IaC repo. 71 // 72 // It's the configuration consumed the deployment system itself. Actuated 73 // resources are configured via `intended_state`. 74 AssetConfig config = 6; 75 76 // The intended state of the asset as defined in the IaC repo. 77 // 78 // It is the intended asset state reported by the actuator during its most 79 // recent BeginActuation call. This state is derived purely from the committed 80 // configuration. The actuator will try to move the asset into this state. 81 // 82 // Has its `state` oneof populated according to the asset kind using 83 // IntendedState sub-fields. Never contains an erroneous AssetState. 84 // 85 // May be missing for new assets if they are misconfigured in the IaC repo. 86 AssetState intended_state = 7; 87 88 // The last successfully applied intended state. 89 // 90 // May be different from `intended_state` for assets being actuated right now 91 // of for disabled, locked or broken assets. 92 // 93 // Has its `state` oneof populated according to the asset kind using 94 // IntendedState sub-fields. Never contains an erroneous AssetState. 95 // 96 // May be missing for new assets if they never had successful actuations. 97 AssetState applied_state = 8; 98 99 // The actual state of the asset as reported by the actuator most recently. 100 // 101 // It is the captured asset state reported by the actuator during its most 102 // BeginActuation or EndActuation calls. Matches some real most recently 103 // observed state of the asset, regardless how this state came to be. 104 // 105 // Has its `state` oneof populated according to the asset kind using 106 // CapturedState sub-fields. Never contains an erroneous AssetState. 107 // 108 // May be missing for new assets if the actuator fails to capture their state. 109 AssetState reported_state = 9; 110 111 // The last state applied by the actuator itself. 112 // 113 // For up-to-date assets it matches `intended_state` and `reported_state`. 114 // 115 // If during an actuation cycle the actuator partially updates some resources 116 // and then fails, `actuated_state` may be some intermediate state between 117 // the intended and the initial pre-actuation states. 118 // 119 // If some external entity (not the actuator) messes with the asset, 120 // `reported_state` may be different from `actuated_state`. 121 // 122 // Has its `state` oneof populated according to the asset kind using 123 // CapturedState sub-fields. Never contains an erroneous AssetState. 124 // 125 // May be missing for new assets while they are being actuated or if the 126 // actuator fails to capture their post-actuation state. 127 AssetState actuated_state = 10; 128 129 // Populated if the actuator failed to capture the post-actuation state. 130 // 131 // If this field is set then `actuated_state` likely doesn't match reality 132 // and the next actuation attempt will likely trigger the anti-stomp 133 // protection. 134 google.rpc.Status post_actuation_status = 11; 135 } 136 137 138 // AssetHistory captures an actuation decision made by the backend regarding 139 // some asset along with all data that led to it, as well as the corresponding 140 // actuation outcome. 141 message AssetHistory { 142 // The parent asset ID. 143 string asset_id = 1; 144 // Index in the asset's history log, monotonically increasing starting with 1. 145 int64 history_id = 2; 146 147 // The decision made by the backend. 148 ActuationDecision decision = 3; 149 // The snapshot of the associated actuation. 150 Actuation actuation = 4; 151 152 // Reported asset configuration as defined in the IaC repo. 153 AssetConfig config = 5; 154 // Reported intended state of the asset as defined in the IaC repo. 155 AssetState intended_state = 6; 156 // Reported actual state of the asset (as scanned by the actuator). 157 AssetState reported_state = 7; 158 // The last successfully applied intended state **prior** to the actuation. 159 AssetState last_applied_state = 8; 160 // The reported state **after** the actuation, if it was performed. 161 AssetState post_actuation_state = 9; 162 // Number of consecutive failures prior to this entry (excluding itself). 163 int64 prior_consecutive_failures = 10; 164 } 165 166 167 // Asset configuration as defined in the IaC repo. 168 message AssetConfig { 169 // True to actuate the asset, false to leave it alone. 170 bool enable_automation = 1; 171 // How many inactive GAE versions to keep. 172 int32 inactive_versions_to_keep = 2; 173 } 174 175 176 // A snapshot of the intended or captured state of an asset. 177 // 178 // Also contains information about the actuator and the deployment at the time 179 // the state was captured. This is useful for the historical log of states. 180 message AssetState { 181 // When this state was captured. 182 google.protobuf.Timestamp timestamp = 1; 183 // The deployment configuration at the time the state was captured. 184 Deployment deployment = 2; 185 // The actuator that performed the capture. 186 ActuatorInfo actuator = 3; 187 // Error details if the asset state could not be captured. 188 google.rpc.Status status = 4; 189 190 // The intended or captured state of the asset if `status` is OK. 191 oneof state { 192 // For assets with ID "apps/<app-id>". 193 AppengineState appengine = 10; 194 } 195 } 196 197 198 // Intended or captured state of an Appengine service. 199 message AppengineState { 200 // A list of services (sorted by name) with intended or captured state. 201 message Service { 202 // Name of the service e.g. "default". 203 string name = 1; 204 205 // A list of service versions sorted by name. 206 message Version { 207 // Name of the version e.g. "11120-9f81d82". 208 string name = 1; 209 210 // State which is defined in the config and which can't be easily captured 211 // using Cloud APIs. 212 // 213 // This field is populated in `intended_state`. 214 message IntendedState { 215 // The artifact (GAE tarball) that should be running there. 216 ArtifactID artifact = 1; 217 // Path to the service YAML within the tarball. 218 string yaml_path = 2; 219 // Vars passed to `gaedeploy` for substitution in the YAML. 220 map<string, string> luci_vars = 3; 221 } 222 IntendedState intended_state = 2; 223 224 // State which is captured using Cloud APIs and which can't be defined 225 // in the config (at least not directly). 226 // 227 // This field is populated in `reported_state` and `actuated_state`. 228 // 229 // See https://cloud.google.com/appengine/docs/admin-api/reference/rpc/google.appengine.v1#google.appengine.v1.Version 230 message CapturedState { 231 // E.g. "F4". 232 string instance_class = 1; 233 // E.g. "standard". 234 string env = 2; 235 // E.g. "go116" 236 string runtime = 3; 237 // Some runtimes have channels. 238 string runtime_channel = 4; 239 // Some runtimes have API versions. 240 string runtime_api_version = 5; 241 // Email of who uploaded this version. 242 string created_by = 6; 243 // When it was uploaded. 244 google.protobuf.Timestamp create_time = 7; 245 // Serving URL of this version specifically. 246 string version_url = 8; 247 } 248 CapturedState captured_state = 3; 249 } 250 repeated Version versions = 2; 251 252 // Traffic splitting method. 253 enum TrafficSplitting { 254 TRAFFIC_SPLITTING_UNSPECIFIED = 0; 255 256 COOKIE = 1; 257 IP = 2; 258 RANDOM = 3; 259 } 260 TrafficSplitting traffic_splitting = 3; 261 262 // Traffic allocation as a map from version name to [0, 1000]. 263 map<string, int32> traffic_allocation = 4; 264 } 265 repeated Service services = 1; 266 267 // State which is defined in the config and which can't be easily captured 268 // using Cloud APIs. 269 // 270 // This field is populated in `intended_state`. 271 message IntendedState { 272 // The list of deployable YAMLs (such as "cron.yaml"). 273 message DeployableYaml { 274 // The artifact (GAE tarball) with the YAML. 275 ArtifactID artifact = 1; 276 // Path to the YAML within the tarball. 277 string yaml_path = 2; 278 } 279 repeated DeployableYaml deployable_yamls = 1; 280 } 281 IntendedState intended_state = 2; 282 283 // State which is captured using Cloud APIs and which can't be defined 284 // in the config (at least not directly). 285 // 286 // This field is populated in `reported_state` and `actuated_state`. 287 // 288 // See https://cloud.google.com/appengine/docs/admin-api/reference/rpc/google.appengine.v1#google.appengine.v1.Application 289 message CapturedState { 290 // E.g. "us-central". 291 string location_id = 1; 292 // Default service hostname. 293 string default_hostname = 2; 294 295 // What kind of a database is associated with the app. 296 enum DatabaseType { 297 DATABASE_TYPE_UNSPECIFIED = 0; 298 299 CLOUD_DATASTORE = 1; 300 CLOUD_FIRESTORE = 2; 301 CLOUD_DATASTORE_COMPATIBILITY = 3; 302 } 303 DatabaseType database_type = 3; 304 } 305 CapturedState captured_state = 3; 306 }