Skip to content

Commit 04445c3

Browse files
authored
Merge branch 'GoogleCloudPlatform:main' into mc-parameterized
2 parents 205254c + b828c9b commit 04445c3

15 files changed

+313
-38
lines changed

mmv1/products/apphub/Application.yaml

+21-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,30 @@ async:
4343
path: 'error'
4444
message: 'message'
4545
custom_code:
46+
constants: 'templates/terraform/constants/apphub_application.go.tmpl'
47+
custom_diff:
48+
- 'apphubApplicationCustomizeDiff'
4649
examples:
47-
- name: 'application_basic'
50+
- name: 'apphub_application_basic'
51+
primary_resource_id: 'example'
52+
vars:
53+
application_id: 'example-application'
54+
location: 'us-east1'
55+
scope_type: 'REGIONAL'
56+
test_vars_overrides:
57+
'location': '"us-east1"'
58+
'scope_type': '"REGIONAL"'
59+
- name: 'apphub_application_global_basic'
4860
config_path: 'templates/terraform/examples/apphub_application_basic.tf.tmpl'
4961
primary_resource_id: 'example'
5062
vars:
5163
application_id: 'example-application'
52-
- name: 'application_full'
53-
config_path: 'templates/terraform/examples/apphub_application_full.tf.tmpl'
64+
location: 'global'
65+
scope_type: 'GLOBAL'
66+
test_vars_overrides:
67+
'location': '"global"'
68+
'scope_type': '"GLOBAL"'
69+
- name: 'apphub_application_full'
5470
primary_resource_id: 'example2'
5571
vars:
5672
application_id: 'example-application'
@@ -171,10 +187,11 @@ properties:
171187
properties:
172188
- name: 'type'
173189
type: Enum
174-
description: "Required. Scope Type. \n Possible values:\nREGIONAL"
190+
description: "Required. Scope Type. \n Possible values:\nREGIONAL\nGLOBAL"
175191
required: true
176192
enum_values:
177193
- 'REGIONAL'
194+
- 'GLOBAL'
178195
- name: 'uid'
179196
type: String
180197
description: 'Output only. A universally unique identifier (in UUID4 format) for

mmv1/products/compute/ServiceAttachment.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ properties:
169169
type: Integer
170170
description: |
171171
The number of consumer Network Connectivity Center spokes that the connected Private Service Connect endpoint has propagated to.
172-
min_version: 'beta'
173172
output: true
174173
- name: 'targetService'
175174
type: String
@@ -266,5 +265,4 @@ properties:
266265
If the connection preference of the service attachment is ACCEPT_AUTOMATIC, the limit applies to each project that contains a connected endpoint.
267266
268267
If unspecified, the default propagated connection limit is 250.
269-
min_version: 'beta'
270268
default_from_api: true

mmv1/products/gkebackup/RestorePlan.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ examples:
5959
name: 'restore-all-ns'
6060
network_name: 'default'
6161
subnetwork_name: 'default'
62+
deletion_protection: 'true'
6263
test_env_vars:
6364
project: 'PROJECT_NAME'
64-
deletion_protection: 'true'
6565
test_vars_overrides:
6666
'deletion_protection': 'false'
6767
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -74,9 +74,9 @@ examples:
7474
name: 'rollback-ns'
7575
network_name: 'default'
7676
subnetwork_name: 'default'
77+
deletion_protection: 'true'
7778
test_env_vars:
7879
project: 'PROJECT_NAME'
79-
deletion_protection: 'true'
8080
test_vars_overrides:
8181
'deletion_protection': 'false'
8282
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -89,9 +89,9 @@ examples:
8989
name: 'rollback-app'
9090
network_name: 'default'
9191
subnetwork_name: 'default'
92+
deletion_protection: 'true'
9293
test_env_vars:
9394
project: 'PROJECT_NAME'
94-
deletion_protection: 'true'
9595
test_vars_overrides:
9696
'deletion_protection': 'false'
9797
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -104,9 +104,9 @@ examples:
104104
name: 'all-groupkinds'
105105
network_name: 'default'
106106
subnetwork_name: 'default'
107+
deletion_protection: 'true'
107108
test_env_vars:
108109
project: 'PROJECT_NAME'
109-
deletion_protection: 'true'
110110
test_vars_overrides:
111111
'deletion_protection': 'false'
112112
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -119,9 +119,9 @@ examples:
119119
name: 'rename-ns'
120120
network_name: 'default'
121121
subnetwork_name: 'default'
122+
deletion_protection: 'true'
122123
test_env_vars:
123124
project: 'PROJECT_NAME'
124-
deletion_protection: 'true'
125125
test_vars_overrides:
126126
'deletion_protection': 'false'
127127
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -134,9 +134,9 @@ examples:
134134
name: 'transform-rule'
135135
network_name: 'default'
136136
subnetwork_name: 'default'
137+
deletion_protection: 'true'
137138
test_env_vars:
138139
project: 'PROJECT_NAME'
139-
deletion_protection: 'true'
140140
test_vars_overrides:
141141
'deletion_protection': 'false'
142142
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -149,9 +149,9 @@ examples:
149149
name: 'gitops-mode'
150150
network_name: 'default'
151151
subnetwork_name: 'default'
152+
deletion_protection: 'true'
152153
test_env_vars:
153154
project: 'PROJECT_NAME'
154-
deletion_protection: 'true'
155155
test_vars_overrides:
156156
'deletion_protection': 'false'
157157
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -164,9 +164,9 @@ examples:
164164
name: 'restore-order'
165165
network_name: 'default'
166166
subnetwork_name: 'default'
167+
deletion_protection: 'true'
167168
test_env_vars:
168169
project: 'PROJECT_NAME'
169-
deletion_protection: 'true'
170170
test_vars_overrides:
171171
'deletion_protection': 'false'
172172
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'
@@ -179,9 +179,9 @@ examples:
179179
name: 'volume-res'
180180
network_name: 'default'
181181
subnetwork_name: 'default'
182+
deletion_protection: 'true'
182183
test_env_vars:
183184
project: 'PROJECT_NAME'
184-
deletion_protection: 'true'
185185
test_vars_overrides:
186186
'deletion_protection': 'false'
187187
'network_name': 'acctest.BootstrapSharedTestNetwork(t, "gke-cluster")'

mmv1/products/spanner/Instance.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,40 @@ properties:
228228
should be trying to achieve for the instance.
229229
This number is on a scale from 0 (no utilization) to 100 (full utilization).
230230
231+
- name: 'asymmetricAutoscalingOptions'
232+
type: Array
233+
description: |
234+
Asymmetric autoscaling options for specific replicas.
235+
item_type:
236+
type: NestedObject
237+
properties:
238+
- name: 'replicaSelection'
239+
type: NestedObject
240+
required: true
241+
properties:
242+
- name: 'location'
243+
type: String
244+
required: true
245+
description: |
246+
The location of the replica to apply asymmetric autoscaling options.
247+
- name: 'overrides'
248+
type: NestedObject
249+
required: true
250+
properties:
251+
- name: 'autoscalingLimits'
252+
type: NestedObject
253+
required: true
254+
properties:
255+
- name: 'minNodes'
256+
type: Integer
257+
required: true
258+
description: |
259+
The minimum number of nodes for this specific replica.
260+
- name: 'maxNodes'
261+
type: Integer
262+
required: true
263+
description: |
264+
The maximum number of nodes for this specific replica.
231265
- name: 'edition'
232266
type: Enum
233267
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
func apphubApplicationCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
2+
if diff.HasChange("location") || diff.HasChange("scope.0.type") {
3+
location := diff.Get("location")
4+
scope_type := diff.Get("scope.0.type")
5+
6+
if scope_type == "GLOBAL" {
7+
if location != "global" {
8+
return fmt.Errorf("Error validating location %s with %s scope type", location, scope_type)
9+
}
10+
} else {
11+
if location == "global" {
12+
return fmt.Errorf("Error validating location %s with %s scope type", location, scope_type)
13+
}
14+
}
15+
}
16+
return nil
17+
}

mmv1/templates/terraform/encoders/spanner_instance_update.go.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ if d.HasChange("autoscaling_config") {
4646
if d.HasChange("autoscaling_config.0.autoscaling_targets.0.storage_utilization_percent") {
4747
updateMask = append(updateMask, "autoscalingConfig.autoscalingTargets.storageUtilizationPercent")
4848
}
49+
if d.HasChange("autoscaling_config.0.asymmetric_autoscaling_options") {
50+
updateMask = append(updateMask, "autoscalingConfig.asymmetricAutoscalingOptions")
51+
}
4952
}
5053
}
5154
newObj["fieldMask"] = strings.Join(updateMask, ",")
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "google_apphub_application" "{{$.PrimaryResourceId}}" {
2-
location = "us-east1"
2+
location = "{{index $.Vars "location"}}"
33
application_id = "{{index $.Vars "application_id"}}"
44
scope {
5-
type = "REGIONAL"
5+
type = "{{index $.Vars "scope_type"}}"
66
}
77
}

mmv1/third_party/terraform/.teamcity/components/builds/build_configuration_per_package.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package builds
99

10+
import ArtifactRules
1011
import DefaultBuildTimeoutDuration
1112
import DefaultParallelism
1213
import generated.ServiceParallelism
@@ -74,6 +75,7 @@ class PackageDetails(private val packageName: String, private val displayName: S
7475
downloadTerraformBinary()
7576
runAcceptanceTests()
7677
saveArtifactsToGCS()
78+
archiveArtifactsIfOverLimit() // Must be after push to GCS step, as this step impacts debug log files
7779
}
7880

7981
features {
@@ -98,7 +100,7 @@ class PackageDetails(private val packageName: String, private val displayName: S
98100
workingDirectory(path)
99101
}
100102

101-
artifactRules = "%teamcity.build.checkoutDir%/debug*.txt"
103+
artifactRules = ArtifactRules
102104

103105
failureConditions {
104106
errorMessage = true

mmv1/third_party/terraform/.teamcity/components/builds/build_configuration_sweepers.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package builds
99

10+
import ArtifactRules
1011
import DefaultBuildTimeoutDuration
1112
import DefaultParallelism
1213
import jetbrains.buildServer.configs.kotlin.BuildType
@@ -102,7 +103,7 @@ class SweeperDetails(private val sweeperName: String, private val parentProjectN
102103
workingDirectory(path)
103104
}
104105

105-
artifactRules = "%teamcity.build.checkoutDir%/debug*.txt"
106+
artifactRules = ArtifactRules
106107

107108
failureConditions {
108109
errorMessage = true

mmv1/third_party/terraform/.teamcity/components/builds/build_configuration_vcr_recording.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package builds
99

10+
import ArtifactRules
1011
import DefaultBuildTimeoutDuration
1112
import DefaultParallelism
1213
import jetbrains.buildServer.configs.kotlin.BuildType
@@ -77,7 +78,7 @@ class VcrDetails(private val providerName: String, private val buildId: String,
7778
workingDirectory(path)
7879
}
7980

80-
artifactRules = "%teamcity.build.checkoutDir%/debug*.txt"
81+
artifactRules = ArtifactRules
8182

8283
failureConditions {
8384
errorMessage = true

mmv1/third_party/terraform/.teamcity/components/builds/build_steps.kt

+54-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fun BuildSteps.saveArtifactsToGCS() {
137137
name = "Tasks after running nightly tests: push artifacts(debug logs) to GCS"
138138
scriptContent = """
139139
#!/bin/bash
140-
echo "Post-test step - storge artifacts(debug logs) to GCS"
140+
echo "Post-test step - storage artifacts(debug logs) to GCS"
141141
142142
# Authenticate gcloud CLI
143143
echo "${'$'}{GOOGLE_CREDENTIALS_GCS}" > google-account.json
@@ -173,4 +173,56 @@ fun BuildSteps.saveArtifactsToGCS() {
173173
// parts like ${GIT_HASH_SHORT} without having Kotlin syntax issues. For more info see:
174174
// https://youtrack.jetbrains.com/issue/KT-2425/Provide-a-way-for-escaping-the-dollar-sign-symbol-in-multiline-strings-and-string-templates
175175
})
176-
}
176+
}
177+
178+
// The S3 plugin we use to upload artifacts to S3 (enabling them to be accessed via the TeamCity UI later) has a limit of
179+
// 1000 artifacts to be uploaded at a time. To avoid a situation where no artifacts are uploaded as a result of exceeding this
180+
// limit we archive all the debug logs if they equal or exceed 1000 for a given build.
181+
fun BuildSteps.archiveArtifactsIfOverLimit() {
182+
step(ScriptBuildStep {
183+
name = "Tasks after running nightly tests: archive artifacts(debug logs) if there are >=1000 before S3 upload"
184+
scriptContent = """
185+
#!/bin/bash
186+
echo "Post-test step - archive artifacts(debug logs) if there are >=1000 before S3 upload"
187+
188+
# Get number of artifacts created
189+
ARTIFACT_COUNT=$(ls %teamcity.build.checkoutDir%/debug* | wc -l | grep -o -E '[0-9]+')
190+
191+
if test ${'$'}ARTIFACT_COUNT -lt "1000"; then
192+
echo "Found <1000 debug artifacts; we won't archive them before upload to S3"
193+
exit 0
194+
fi
195+
196+
echo "Found >=1000 debug artifacts; archiving before upload to S3"
197+
198+
# Make tarball of all debug logs
199+
# Name should look similar to: debug-google-d2503f7-253644-TerraformProviders_GoogleCloud_GOOGLE_NIGHTLYTESTS_GOOGLE_PACKAGE_ACCESSAPPROVAL.tar.gz
200+
cd %teamcity.build.checkoutDir%
201+
ARCHIVE_NAME=debug-%PROVIDER_NAME%-%env.BUILD_NUMBER%-%system.teamcity.buildType.id%-archive.tar.gz
202+
tar -cf ${'$'}ARCHIVE_NAME ./debug*
203+
204+
# Fail loudly if archive not made as expected
205+
if [ ! -f ${'$'}ARCHIVE_NAME ]; then
206+
echo "Archive file ${'$'}ARCHIVE_NAME not found!"
207+
208+
# Allow sanity checking
209+
echo "Listing contents of %teamcity.build.checkoutDir%"
210+
ls
211+
212+
exit 1
213+
fi
214+
215+
# Remove all debug logs. These are all .txt files due to the effects of TF_LOG_PATH_MASK.
216+
rm ./debug*.txt
217+
218+
# Allow sanity checking
219+
echo "Listing files matching the artifact rule value %teamcity.build.checkoutDir%/debug*"
220+
ls debug*
221+
222+
echo "Finished"
223+
""".trimIndent()
224+
// ${'$'} is required to allow creating a script in TeamCity that contains
225+
// parts like ${GIT_HASH_SHORT} without having Kotlin syntax issues. For more info see:
226+
// https://youtrack.jetbrains.com/issue/KT-2425/Provide-a-way-for-escaping-the-dollar-sign-symbol-in-multiline-strings-and-string-templates
227+
})
228+
}

mmv1/third_party/terraform/.teamcity/components/constants.kt

+5
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ const val ProjectSweeperName = "Project Sweeper"
4343
const val NightlyTestsProjectId = "NightlyTests"
4444
const val MMUpstreamProjectId = "MMUpstreamTests"
4545
const val VcrRecordingProjectId = "VCRRecording"
46+
47+
// Artifact rules controls which artifacts are uploaded to S3
48+
// https://www.jetbrains.com/help/teamcity/2024.07/configuring-general-settings.html#Artifact+Paths
49+
// The value below lacks a file extension, to allow upload of individual .txt files or a single .tar.gz file
50+
const val ArtifactRules = "%teamcity.build.checkoutDir%/debug*"

0 commit comments

Comments
 (0)