Skip to content

Commit 9596391

Browse files
committed
Reserve tag names our code reads from cloud resources
(future-proofing) - NLB ownership check: tenant, tenantName, app, clusterid - VPC endpoint service filters: system, application, cluster, generation, auth-method - Preprovisioned LB branching: preprovisioned
1 parent 77ec85b commit 9596391

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

config-provisioning/src/main/java/com/yahoo/config/provision/CloudResourceTags.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ public class CloudResourceTags {
2828

2929
private static final Pattern TEMPLATE_VARIABLE = Pattern.compile("\\$\\{[^}]+\\}");
3030

31-
/** System tag names reserved by the platform. Compared case-insensitively against customer keys. */
31+
/**
32+
* System tag names reserved by the platform. Compared case-insensitively against customer keys.
33+
* Add a key here when our code reads it from a tag on a Vespa-managed resource, so a customer
34+
* override cannot break our lookups or ownership checks.
35+
*/
3236
private static final List<String> RESERVED_TAG_NAMES = List.of(
33-
"applicationid", "athenz", "athenz-domain", "athenzservice", "fqdn", "name", "owner", "zone");
37+
// EC2 instance and EBS volume identification
38+
"applicationid", "athenz", "athenz-domain", "athenzservice", "fqdn", "name", "owner", "zone",
39+
// NLB and target group ownership check
40+
"tenant", "tenantName", "app", "clusterid",
41+
// VPC endpoint service identification
42+
"system", "application", "cluster", "generation", "auth-method",
43+
// Load balancer preprovisioning
44+
"preprovisioned");
3445

3546
/** Key prefixes reserved by the platform. Compared case-insensitively against customer keys. */
3647
private static final List<String> RESERVED_KEY_PREFIXES = List.of("vai_", "corp_", "bastion_");

config-provisioning/src/test/java/com/yahoo/config/provision/CloudResourceTagsTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ void vai_prefix_rejected() {
160160

161161
@Test
162162
void reserved_tag_names_rejected() {
163+
// EC2 instance / EBS volume
163164
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("applicationid", "value")));
164165
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("athenz", "value")));
165166
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("athenz-domain", "value")));
@@ -168,6 +169,19 @@ void reserved_tag_names_rejected() {
168169
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("name", "value")));
169170
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("owner", "value")));
170171
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("zone", "value")));
172+
// NLB / target group
173+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("tenant", "value")));
174+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("tenantName", "value")));
175+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("app", "value")));
176+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("clusterid", "value")));
177+
// VPC endpoint service
178+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("system", "value")));
179+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("application", "value")));
180+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("cluster", "value")));
181+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("generation", "value")));
182+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("auth-method", "value")));
183+
// Load balancer preprovisioning
184+
assertThrows(IllegalArgumentException.class, () -> CloudResourceTags.from(Map.of("preprovisioned", "value")));
171185
}
172186

173187
@Test
@@ -462,15 +476,15 @@ void resolve_substitutes_all_placeholders() {
462476
"env", "${environment}",
463477
"loc", "${region}",
464478
"team", "${tenant}-${application}-${instance}",
465-
"cluster", "${clustername}",
479+
"cluster_name", "${clustername}",
466480
"type", "${clustertype}",
467481
"combined", "${environment}-${clustername}-${clustertype}"));
468482
var resolved = tags.resolve(testApp, testEnv, testRegion,
469483
ClusterSpec.Id.from("my-search"), ClusterSpec.Type.content);
470484
assertEquals("prod", resolved.asMap().get("env"));
471485
assertEquals("aws-us-east-1c", resolved.asMap().get("loc"));
472486
assertEquals("tenant1-app1-default", resolved.asMap().get("team"));
473-
assertEquals("my-search", resolved.asMap().get("cluster"));
487+
assertEquals("my-search", resolved.asMap().get("cluster_name"));
474488
assertEquals("content", resolved.asMap().get("type"));
475489
assertEquals("prod-my-search-content", resolved.asMap().get("combined"));
476490
}

0 commit comments

Comments
 (0)