Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dns cluster api #36353

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Stevenjin8
Copy link
Contributor

@Stevenjin8 Stevenjin8 commented Sep 26, 2024

TODO:

  • Create new DnsConfig proto
  • Update deprecation docs
  • Update strict dns cluster to consume new dns config
  • Update logical dns cluster to consume new dns config
  • Test changes

Commit Message: Refactor DNS cluster configuration in its own extension
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #36353 was opened by Stevenjin8.

see: more, trace.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #36353 was opened by Stevenjin8.

see: more, trace.

@Stevenjin8
Copy link
Contributor Author

@markdroth @wbpcode Just wanted to check in that I'm going in the right direction

@Stevenjin8 Stevenjin8 force-pushed the refactor/dns-api branch 2 times, most recently from a305ccc to 928ef02 Compare October 1, 2024 16:46
@Stevenjin8 Stevenjin8 marked this pull request as ready for review October 1, 2024 16:47
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
@Stevenjin8 Stevenjin8 changed the title Refactor/dns api Refactor dns cluster api Oct 2, 2024
@Stevenjin8
Copy link
Contributor Author

@markdroth I would also appreciate some guidance on what you expect for testing.

@mattklein123
Copy link
Member

Sorry can you provide some context on this?

/wait

Copy link
Contributor

@markdroth markdroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattklein123 For context, see #35479 (comment).

@Stevenjin8, I'm not the right person to ask about testing for the Envoy implementation, so I'll let one of the Envoy maintainers do that. My feedback here is just on the xDS API changes.

Please let me know if you have any questions. Thanks!

api/envoy/config/cluster/v3/cluster.proto Outdated Show resolved Hide resolved
api/envoy/extensions/clusters/dns/v3/cluster.proto Outdated Show resolved Hide resolved
api/envoy/extensions/clusters/dns/v3/cluster.proto Outdated Show resolved Hide resolved
api/envoy/extensions/clusters/dns/v3/cluster.proto Outdated Show resolved Hide resolved
api/envoy/config/cluster/v3/cluster.proto Outdated Show resolved Hide resolved
@@ -944,6 +920,9 @@ message Cluster {
// [#next-major-version: make this a list of typed extensions.]
map<string, google.protobuf.Any> typed_extension_protocol_options = 36;

// [#extension-category: envoy.clusters.dns]
envoy.extensions.clusters.dns.v3.DnsConfig dns_config = 59;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a new extension point here. The DNS cluster config should instead be loaded via the existing cluster_type field:

CustomClusterType cluster_type = 38;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markdroth Oh I see, so we are adding relevant DNS fields to the cluster config types of each cluster type. So I would add a api/envoy/extensions/clusters/strict_dns/v3/cluster.proto file with the corresponding fields. and same for logical_dns, etc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work. But it may also be the case that there's enough in common (config-wise and/or implementation-wise) between STRICT_DNS and LOGICAL_DNS that we can combine them into a single DNS cluster type, and the config for that DNS cluster type can have a field that says whether it uses STRICT or LOGICAL behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markdroth wait... So would I add an extension point to the typed config. So the configuration would like

  clusters:
  - name: my_cluster
    ...
    cluster_type:
      name: envoy.clusters.strict_dns
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.clusters.strict_dns.v3.ClusterConfig
      dns_config:
         dns_jitter: false
         ... the rest of the dns_* fields

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new DNS cluster type should not use any of the existing dns_* fields in the Cluster message; those fields should all be copied into the new envoy.extensions.clusters.dns_cluster.v3.DnsCluster message.

The existing dns_* fields in the Cluster message should be used only for backward-compatibility reasons, for existing Cluster resources that use STRICT_DNS or LOGICAL_DNS and configure these existing fields. However, Envoy should internally convert such a config into the corresponding new-style config that uses the new envoy.extensions.clusters.dns_cluster.v3.DnsCluster message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the above example, I just worry that we are forcing both strict and logical dns to share the same typed_cofig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I messed up the indentation in the first example. Sorry! I meant

  clusters:
  - name: my_cluster
    ...
    cluster_type:
      name: envoy.clusters.strict_dns
      typed_config:
        "@type": type.googleapis.com/envoy.extensions.clusters.strict_dns.v3.ClusterConfig
        dns_config:
           dns_jitter: false
           ... the rest of the dns_* fields

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the above example, I just worry that we are forcing both strict and logical dns to share the same typed_cofig

Why would that a problem, as long as there's still a way to configure the behavior for each? My suspicion is that if we had separate config messages for STRICT_DNS and LOGICAL_DNS, then both messages would have almost identical sets of fields. If that's the case, then the duplication doesn't really make sense, which is why I suggested having a single message that can be used for both with a knob that controls which behavior is used.

The type present in the type_url field dictates which cluster implementation gets used, so if we have two different implementations for STRICT_DNS and LOGICAL_DNS, then we would need probably-identical config messages, like this:

message StrictDnsCluster {
  // ...a bunch of DNS fields...
}

message LogicalDnsCluster {
  // ...exactly the same set of DNS fields...
}

In contrast, if we have a single cluster implementation for both DNS types with a knob to control the behavior, we can have a single config proto, like this:

message DnsCluster {
  // if true, STRICT_DNS semantics; otherwise, LOGICAL_DNS semantics
  // (could also be an enum or whatever)
  bool strict = N;

  // ...the set of DNS fields...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markdroth I agree that most fields are Dns-related and would thus be duplicated, but I was thinking something along the lines of

message DnsConfig {
   // ... DNS fields
}

message StrictDnsCluster {
  DnsConfig dns_config = N
}

message LogicalDnsCluster {
  DnsConfig dns_config = N
}

This way we don't have duplicate code and

  1. In the future, if we want to add a logical dns-specific field, it won't appear in the strict dns configuration (same for strict dns).
  2. It follows the general pattern (AFAIK) of each cluster type having its own config type. We see this pattern for filters too.

Let me know what you think. I'm still new to envoy so if you feel that having a shared config type is the way to go, I'm happy to implement it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My inclination is that we're unlikely to have too many fields that are specific to either STRICT_DNS or LOGICAL_DNS, so combining them makes the most sense. But I'd be open to input from @wbpcode or other Envoy maintainers.

Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
@repokitteh-read-only repokitteh-read-only bot added deps Approval required for changes to Envoy's external dependencies and removed waiting labels Oct 10, 2024
Copy link

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @mattklein123

🐱

Caused by: #36353 was synchronize by Stevenjin8.

see: more, trace.

Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
* Also tests for strict dns

Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
@Stevenjin8
Copy link
Contributor Author

Stevenjin8 commented Oct 10, 2024

Sorry everybody I messed up my git history

Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
@Stevenjin8
Copy link
Contributor Author

@markdroth I think I'm ready for another review. I'm hoping CI is passing now.

Signed-off-by: Steven Jin Xuan <sjinxuan@microsoft.com>
@Stevenjin8
Copy link
Contributor Author

/help

@Stevenjin8
Copy link
Contributor Author

/retest

@Stevenjin8
Copy link
Contributor Author

/assign @Stevenjin8

dns_cluster.mutable_dns_refresh_rate()->CopyFrom(cluster.dns_refresh_rate());
}

// FIXME: tests this
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api deps Approval required for changes to Envoy's external dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants