Skip to content

Commit 2bf1b5e

Browse files
authored
remove include-directpath-authority-experimental (#56)
1 parent a09721c commit 2bf1b5e

File tree

2 files changed

+141
-128
lines changed

2 files changed

+141
-128
lines changed

main.go

Lines changed: 56 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,22 @@ import (
3636
)
3737

3838
var (
39-
xdsServerUri = flag.String("xds-server-uri", "trafficdirector.googleapis.com:443", "override of server uri, for testing")
40-
outputName = flag.String("output", "-", "output file name")
41-
gcpProjectNumber = flag.Int64("gcp-project-number", 0, "the gcp project number. If unknown, can be found via 'gcloud projects list'")
42-
vpcNetworkName = flag.String("vpc-network-name", "default", "VPC network name")
43-
localityZone = flag.String("locality-zone", "", "the locality zone to use, instead of retrieving it from the metadata server. Useful when not running on GCP and/or for testing")
44-
ignoreResourceDeletion = flag.Bool("ignore-resource-deletion-experimental", false, "assume missing resources notify operators when using Traffic Director, as in gRFC A53. This is not currently the case. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
45-
secretsDir = flag.String("secrets-dir", "/var/run/secrets/workload-spiffe-credentials", "path to a directory containing TLS certificates and keys required for PSM security")
46-
includeDeploymentInfo = flag.Bool("include-deployment-info-experimental", false, "whether or not to generate config which contains deployment related information. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
47-
gkeClusterName = flag.String("gke-cluster-name", "", "GKE cluster name to use, instead of retrieving it from the metadata server.")
48-
gkePodName = flag.String("gke-pod-name-experimental", "", "GKE pod name to use, instead of reading it from $HOSTNAME or /etc/hostname file. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
49-
gkeNamespace = flag.String("gke-namespace-experimental", "", "GKE namespace to use. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
50-
gkeLocation = flag.String("gke-location-experimental", "", "the location (region/zone) of the cluster from which to pull configuration, instead of retrieving it from the metadata server. This value is used to generate the mesh ID. Ignored if not used with --generate-mesh-id. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
51-
gceVM = flag.String("gce-vm-experimental", "", "GCE VM name to use, instead of reading it from the metadata server. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
52-
configMesh = flag.String("config-mesh", "", "Dictates which Mesh resource to use.")
53-
generateMeshId = flag.Bool("generate-mesh-id", false, "When enabled, the CSM MeshID is generated. If config-mesh flag is specified, this flag would be ignored. Location and Cluster Name would be retrieved from the metadata server unless specified via gke-location and gke-cluster-name flags respectively.")
54-
includeDirectPathAuthority = flag.Bool("include-directpath-authority-experimental", true, "whether or not to include DirectPath TD authority for xDS Federation. Ignored if not used with include-federation-support-experimental flag. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
55-
includeXDSTPNameInLDS = flag.Bool("include-xdstp-name-in-lds-experimental", false, "whether or not to use xdstp style name for listener resource name template. Ignored if not used with include-federation-support-experimental flag. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
39+
xdsServerUri = flag.String("xds-server-uri", "trafficdirector.googleapis.com:443", "override of server uri, for testing")
40+
outputName = flag.String("output", "-", "output file name")
41+
gcpProjectNumber = flag.Int64("gcp-project-number", 0, "the gcp project number. If unknown, can be found via 'gcloud projects list'")
42+
vpcNetworkName = flag.String("vpc-network-name", "default", "VPC network name")
43+
localityZone = flag.String("locality-zone", "", "the locality zone to use, instead of retrieving it from the metadata server. Useful when not running on GCP and/or for testing")
44+
ignoreResourceDeletion = flag.Bool("ignore-resource-deletion-experimental", false, "assume missing resources notify operators when using Traffic Director, as in gRFC A53. This is not currently the case. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
45+
secretsDir = flag.String("secrets-dir", "/var/run/secrets/workload-spiffe-credentials", "path to a directory containing TLS certificates and keys required for PSM security")
46+
includeDeploymentInfo = flag.Bool("include-deployment-info-experimental", false, "whether or not to generate config which contains deployment related information. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
47+
gkeClusterName = flag.String("gke-cluster-name", "", "GKE cluster name to use, instead of retrieving it from the metadata server.")
48+
gkePodName = flag.String("gke-pod-name-experimental", "", "GKE pod name to use, instead of reading it from $HOSTNAME or /etc/hostname file. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
49+
gkeNamespace = flag.String("gke-namespace-experimental", "", "GKE namespace to use. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
50+
gkeLocation = flag.String("gke-location-experimental", "", "the location (region/zone) of the cluster from which to pull configuration, instead of retrieving it from the metadata server. This value is used to generate the mesh ID. Ignored if not used with --generate-mesh-id. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
51+
gceVM = flag.String("gce-vm-experimental", "", "GCE VM name to use, instead of reading it from the metadata server. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
52+
configMesh = flag.String("config-mesh", "", "Dictates which Mesh resource to use.")
53+
generateMeshId = flag.Bool("generate-mesh-id", false, "When enabled, the CSM MeshID is generated. If config-mesh flag is specified, this flag would be ignored. Location and Cluster Name would be retrieved from the metadata server unless specified via gke-location and gke-cluster-name flags respectively.")
54+
includeXDSTPNameInLDS = flag.Bool("include-xdstp-name-in-lds-experimental", false, "whether or not to use xdstp style name for listener resource name template. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
5655
)
5756

5857
func main() {
@@ -177,20 +176,19 @@ func main() {
177176
}
178177

179178
input := configInput{
180-
xdsServerUri: *xdsServerUri,
181-
gcpProjectNumber: *gcpProjectNumber,
182-
vpcNetworkName: *vpcNetworkName,
183-
ip: ip,
184-
zone: zone,
185-
ignoreResourceDeletion: *ignoreResourceDeletion,
186-
secretsDir: *secretsDir,
187-
metadataLabels: nodeMetadata,
188-
deploymentInfo: deploymentInfo,
189-
configMesh: meshId,
190-
includeDirectPathAuthority: *includeDirectPathAuthority,
191-
ipv6Capable: isIPv6Capable(),
192-
includeXDSTPNameInLDS: *includeXDSTPNameInLDS,
193-
gitCommitHash: gitCommitHash,
179+
xdsServerUri: *xdsServerUri,
180+
gcpProjectNumber: *gcpProjectNumber,
181+
vpcNetworkName: *vpcNetworkName,
182+
ip: ip,
183+
zone: zone,
184+
ignoreResourceDeletion: *ignoreResourceDeletion,
185+
secretsDir: *secretsDir,
186+
metadataLabels: nodeMetadata,
187+
deploymentInfo: deploymentInfo,
188+
configMesh: meshId,
189+
ipv6Capable: isIPv6Capable(),
190+
includeXDSTPNameInLDS: *includeXDSTPNameInLDS,
191+
gitCommitHash: gitCommitHash,
194192
}
195193

196194
if err := validate(input); err != nil {
@@ -231,20 +229,19 @@ func main() {
231229
}
232230

233231
type configInput struct {
234-
xdsServerUri string
235-
gcpProjectNumber int64
236-
vpcNetworkName string
237-
ip string
238-
zone string
239-
ignoreResourceDeletion bool
240-
secretsDir string
241-
metadataLabels map[string]string
242-
deploymentInfo map[string]string
243-
configMesh string
244-
includeDirectPathAuthority bool
245-
ipv6Capable bool
246-
includeXDSTPNameInLDS bool
247-
gitCommitHash string
232+
xdsServerUri string
233+
gcpProjectNumber int64
234+
vpcNetworkName string
235+
ip string
236+
zone string
237+
ignoreResourceDeletion bool
238+
secretsDir string
239+
metadataLabels map[string]string
240+
deploymentInfo map[string]string
241+
configMesh string
242+
ipv6Capable bool
243+
includeXDSTPNameInLDS bool
244+
gitCommitHash string
248245
}
249246

250247
func validate(in configInput) error {
@@ -288,6 +285,7 @@ func generate(in configInput) ([]byte, error) {
288285
"TRAFFICDIRECTOR_GRPC_BOOTSTRAP_GENERATOR_SHA": in.gitCommitHash,
289286
},
290287
},
288+
Authorities: make(map[string]Authority),
291289
}
292290

293291
for k, v := range in.metadataLabels {
@@ -315,9 +313,6 @@ func generate(in configInput) ([]byte, error) {
315313
}
316314

317315
if in.includeXDSTPNameInLDS {
318-
if c.Authorities == nil {
319-
c.Authorities = make(map[string]Authority)
320-
}
321316
tdAuthority := "traffic-director-global.xds.googleapis.com"
322317
c.Authorities[tdAuthority] = Authority{
323318
// Listener Resource Name format for normal TD usecases looks like:
@@ -326,24 +321,19 @@ func generate(in configInput) ([]byte, error) {
326321
}
327322
}
328323

329-
if in.includeDirectPathAuthority {
330-
if c.Authorities == nil {
331-
c.Authorities = make(map[string]Authority)
332-
}
333-
c2pAuthority := "traffic-director-c2p.xds.googleapis.com"
334-
c.Authorities[c2pAuthority] = Authority{
335-
// In the case of DirectPath, it is safe to assume that the operator is notified of missing resources.
336-
// In other words, "ignore_resource_deletion" server_features is always set.
337-
XdsServers: []server{{
338-
ServerUri: "dns:///directpath-pa.googleapis.com",
339-
ChannelCreds: []creds{{Type: "google_default"}},
340-
ServerFeatures: []string{"xds_v3", "ignore_resource_deletion"},
341-
}},
342-
ClientListenerResourceNameTemplate: fmt.Sprintf("xdstp://%s/envoy.config.listener.v3.Listener/%%s", c2pAuthority),
343-
}
344-
if in.ipv6Capable {
345-
c.Node.Metadata["TRAFFICDIRECTOR_DIRECTPATH_C2P_IPV6_CAPABLE"] = true
346-
}
324+
c2pAuthority := "traffic-director-c2p.xds.googleapis.com"
325+
c.Authorities[c2pAuthority] = Authority{
326+
// In the case of DirectPath, it is safe to assume that the operator is notified of missing resources.
327+
// In other words, "ignore_resource_deletion" server_features is always set.
328+
XdsServers: []server{{
329+
ServerUri: "dns:///directpath-pa.googleapis.com",
330+
ChannelCreds: []creds{{Type: "google_default"}},
331+
ServerFeatures: []string{"xds_v3", "ignore_resource_deletion"},
332+
}},
333+
ClientListenerResourceNameTemplate: fmt.Sprintf("xdstp://%s/envoy.config.listener.v3.Listener/%%s", c2pAuthority),
334+
}
335+
if in.ipv6Capable {
336+
c.Node.Metadata["TRAFFICDIRECTOR_DIRECTPATH_C2P_IPV6_CAPABLE"] = true
347337
}
348338

349339
return json.MarshalIndent(c, "", " ")

main_test.go

Lines changed: 85 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,25 @@ func TestGenerate(t *testing.T) {
128128
]
129129
}
130130
],
131+
"authorities": {
132+
"traffic-director-c2p.xds.googleapis.com": {
133+
"xds_servers": [
134+
{
135+
"server_uri": "dns:///directpath-pa.googleapis.com",
136+
"channel_creds": [
137+
{
138+
"type": "google_default"
139+
}
140+
],
141+
"server_features": [
142+
"xds_v3",
143+
"ignore_resource_deletion"
144+
]
145+
}
146+
],
147+
"client_listener_resource_name_template": "xdstp://traffic-director-c2p.xds.googleapis.com/envoy.config.listener.v3.Listener/%s"
148+
}
149+
},
131150
"node": {
132151
"id": "projects/123456789012345/networks/thedefault/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
133152
"cluster": "cluster",
@@ -180,6 +199,25 @@ func TestGenerate(t *testing.T) {
180199
]
181200
}
182201
],
202+
"authorities": {
203+
"traffic-director-c2p.xds.googleapis.com": {
204+
"xds_servers": [
205+
{
206+
"server_uri": "dns:///directpath-pa.googleapis.com",
207+
"channel_creds": [
208+
{
209+
"type": "google_default"
210+
}
211+
],
212+
"server_features": [
213+
"xds_v3",
214+
"ignore_resource_deletion"
215+
]
216+
}
217+
],
218+
"client_listener_resource_name_template": "xdstp://traffic-director-c2p.xds.googleapis.com/envoy.config.listener.v3.Listener/%s"
219+
}
220+
},
183221
"node": {
184222
"id": "projects/123456789012345/networks/thedefault/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
185223
"cluster": "cluster",
@@ -237,6 +275,25 @@ func TestGenerate(t *testing.T) {
237275
]
238276
}
239277
],
278+
"authorities": {
279+
"traffic-director-c2p.xds.googleapis.com": {
280+
"xds_servers": [
281+
{
282+
"server_uri": "dns:///directpath-pa.googleapis.com",
283+
"channel_creds": [
284+
{
285+
"type": "google_default"
286+
}
287+
],
288+
"server_features": [
289+
"xds_v3",
290+
"ignore_resource_deletion"
291+
]
292+
}
293+
],
294+
"client_listener_resource_name_template": "xdstp://traffic-director-c2p.xds.googleapis.com/envoy.config.listener.v3.Listener/%s"
295+
}
296+
},
240297
"node": {
241298
"id": "projects/123456789012345/networks/thedefault/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
242299
"cluster": "cluster",
@@ -303,6 +360,25 @@ func TestGenerate(t *testing.T) {
303360
]
304361
}
305362
],
363+
"authorities": {
364+
"traffic-director-c2p.xds.googleapis.com": {
365+
"xds_servers": [
366+
{
367+
"server_uri": "dns:///directpath-pa.googleapis.com",
368+
"channel_creds": [
369+
{
370+
"type": "google_default"
371+
}
372+
],
373+
"server_features": [
374+
"xds_v3",
375+
"ignore_resource_deletion"
376+
]
377+
}
378+
],
379+
"client_listener_resource_name_template": "xdstp://traffic-director-c2p.xds.googleapis.com/envoy.config.listener.v3.Listener/%s"
380+
}
381+
},
306382
"node": {
307383
"id": "projects/123456789012345/networks/mesh:testmesh/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
308384
"cluster": "cluster",
@@ -362,57 +438,6 @@ func TestGenerate(t *testing.T) {
362438
]
363439
}
364440
],
365-
"node": {
366-
"id": "projects/123456789012345/networks/thedefault/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
367-
"cluster": "cluster",
368-
"metadata": {
369-
"INSTANCE_IP": "10.9.8.7",
370-
"TRAFFICDIRECTOR_GRPC_BOOTSTRAP_GENERATOR_SHA": "7202b7c611ebd6d382b7b0240f50e9824200bffd"
371-
},
372-
"locality": {
373-
"zone": "uscentral-5"
374-
}
375-
},
376-
"certificate_providers": {
377-
"google_cloud_private_spiffe": {
378-
"plugin_name": "file_watcher",
379-
"config": {
380-
"certificate_file": "certificates.pem",
381-
"private_key_file": "private_key.pem",
382-
"ca_certificate_file": "ca_certificates.pem",
383-
"refresh_interval": "600s"
384-
}
385-
}
386-
},
387-
"server_listener_resource_name_template": "grpc/server?xds.resource.listening_address=%s"
388-
}`,
389-
},
390-
{
391-
desc: "happy case with federation support of c2p authority included",
392-
input: configInput{
393-
xdsServerUri: "example.com:443",
394-
gcpProjectNumber: 123456789012345,
395-
vpcNetworkName: "thedefault",
396-
ip: "10.9.8.7",
397-
zone: "uscentral-5",
398-
includeDirectPathAuthority: true,
399-
ipv6Capable: true,
400-
gitCommitHash: "7202b7c611ebd6d382b7b0240f50e9824200bffd",
401-
},
402-
wantOutput: `{
403-
"xds_servers": [
404-
{
405-
"server_uri": "example.com:443",
406-
"channel_creds": [
407-
{
408-
"type": "google_default"
409-
}
410-
],
411-
"server_features": [
412-
"xds_v3"
413-
]
414-
}
415-
],
416441
"authorities": {
417442
"traffic-director-c2p.xds.googleapis.com": {
418443
"xds_servers": [
@@ -437,7 +462,6 @@ func TestGenerate(t *testing.T) {
437462
"cluster": "cluster",
438463
"metadata": {
439464
"INSTANCE_IP": "10.9.8.7",
440-
"TRAFFICDIRECTOR_DIRECTPATH_C2P_IPV6_CAPABLE": true,
441465
"TRAFFICDIRECTOR_GRPC_BOOTSTRAP_GENERATOR_SHA": "7202b7c611ebd6d382b7b0240f50e9824200bffd"
442466
},
443467
"locality": {
@@ -459,17 +483,16 @@ func TestGenerate(t *testing.T) {
459483
}`,
460484
},
461485
{
462-
desc: "happy case with federation support of c2p along with regular TD using xdstp style name",
486+
desc: "happy case with federation support with TDOM using xdstp style name",
463487
input: configInput{
464-
xdsServerUri: "trafficdirector.googleapis.com:443",
465-
gcpProjectNumber: 123456789012345,
466-
vpcNetworkName: "thedefault",
467-
ip: "10.9.8.7",
468-
zone: "uscentral-5",
469-
includeDirectPathAuthority: true,
470-
ipv6Capable: true,
471-
includeXDSTPNameInLDS: true,
472-
gitCommitHash: "7202b7c611ebd6d382b7b0240f50e9824200bffd",
488+
xdsServerUri: "trafficdirector.googleapis.com:443",
489+
gcpProjectNumber: 123456789012345,
490+
vpcNetworkName: "thedefault",
491+
ip: "10.9.8.7",
492+
zone: "uscentral-5",
493+
ipv6Capable: true,
494+
includeXDSTPNameInLDS: true,
495+
gitCommitHash: "7202b7c611ebd6d382b7b0240f50e9824200bffd",
473496
},
474497
wantOutput: `{
475498
"xds_servers": [

0 commit comments

Comments
 (0)