Repository navigation
dynamic_forward_proxy: fix sub_cluster_confg stuck with warm up due to DFPCluster removed - #35848
Conversation
Signed-off-by: nbn01 <[email protected]>
|
Hi @itsLucario, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
284cf40 to
04b55d2
Compare
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
|
@adisuissa Can you please help with review? |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for contributing.
Left a high-level question.
| bool connection_pool_per_downstream_connection = 51; | ||
|
|
||
| // If ``ignore_removal`` is true, the cluster manager will ignore the cluster while removing during CDS event. | ||
| // This is useful when cluster is created and managed by custom implementation. For example, Dynamic Forward Proxy. |
There was a problem hiding this comment.
I'm not sure this is the right place to make this change.
Shouldn't this be part of the dynamic-forward-proxy config, and not per-cluster?
The risk is that clusters are will linger for a long time, and it is unclear why would one want to keep them around with no way to remove.
There was a problem hiding this comment.
Thanks. That's a valid question. Yes, this can be part of dynamic-forward-proxy, and we can instruct it to recreate the DFP cluster if it's not found (in case it was removed by the cluster manager).
However, in environments like service-mesh or configurations where CDS can be a very frequent event, the cluster manager will end up removing it very frequently. Also, when used as an egress, DFPClusters can be high in number, and removing and recreating them on CDS after the cluster manager removes them can affect performance.
In use cases like dynamic-forward-proxy, where clusters are created and managed by a custom implementation (create/update/remove), CDS should not impact them. dynamic-forward-proxy has TTL which does remove cluster if not used for the TTL duration.
We can hide the field from docs and let this to be used for clusters managed by custom implementations.
So the idea was to make the cluster manager know that these DFP clusters shouldn't be removed.
Open for feedback and thoughts.
There was a problem hiding this comment.
hide the field from docs
Personally, I think it could be a choice, and note clearly in comment: it's just for internal usage, not for users.
Another choice is: we add one more argument, ignore_removal, in ClusterManagerImpl::addOrUpdateCluster and ClusterManagerImpl::loadCluster.
It should works too, but with more code base changes.
There was a problem hiding this comment.
Right! @doujiang24 The later one needs more changes. Leaving note and hide from docs is simpler.
Made changes: Note in the comment and hide it from docs.
Open for thoughts
There was a problem hiding this comment.
Hiding from the docs should not be considered, IMHO, as it should be used for API that needs more testing (not to be hidden from some use-cases).
I think the question is whether it makes sense for DFP to have both clusters that are removed and clusters that are kept all the time. From your comments I gather that in DFP one would want to ignore the CDS removal, so it seems that a single knob (on the DFP config) makes more sense, no?
There was a problem hiding this comment.
On CDS event when clusters are being removed, the cluster manager cannot differentiate whether it is a DFP cluster or a normal cluster.
There is nothing to differentiate and prevent these DFP clusters from getting removed by cluster manager.
Please correct me if I'm wrong or not making sense.
There was a problem hiding this comment.
The lifecycle of the sub clusters are managed by the DFP cluster, both creation and deletion.
So, we want to add a flag for the sub clusters to not be removed by other events.
The flag do not have to be a configuration, just a internal flag.
If hidding from docs is not be considered, maybe we can try the option 2? #35848 (comment) cc @itsLucario
There was a problem hiding this comment.
Right! Summarizing the other approach.
We'll remove the ignore_removal attribute from Cluster API Spec.
Introduce an optional argument ignore_removal default set to false (optional param to ensure existing flow won't break) in ClusterManagerImpl:: addOrUpdateCluster and ClusterManagerImpl::loadCluster so that ClusterData can set this value and can check while removing.
Does this sound right! If people are fine, I'll proceed with working on changes.
There was a problem hiding this comment.
FWIW, I didn't say that removing the API field is required, I just suggested moving it to the DFP config instead of having it in a per-Cluster config.
Taking a step back, there are a few things to clarify:
- Changing the API should be done in a considerate manner, as it impacts not only Envoy users, but also xDS-server maintainers. Moreover, removing fields essentially cannot be done, so we prefer to get it mostly right now. That is why we are discussing if a field should be added, and if so where.
- If a PR suggests changing the way Envoy behaves right now (breaking behavior change), this can either be done by adding a field or a runtime-flag. The former is a long-term support, say a filter that needs to support 2 modes of operation. The latter is when a bug is observed, and the fix causes a user-facing change. Runtime-flags allow Envoy users ~6 months to gradually ensure that the other systems behave correctly with the new change.
In the context of this PR, it is unclear to me whether it should be a config-enabled feature or a runtime-flag guarded change. I'm leaning towards the runtime guarded change according to your description (but could be persuaded towards an API feature if there are use-cases where the clusters that are added by DFP need to removed upon a CDS update).
There was a problem hiding this comment.
Thanks for the thoughts!
- Totally agreed. Chaging API should be done in considerate manner. After your thoughts it makes more sense to follow different approach. I feel the approach mentioned by @doujiang24 is fiesible and easy to use even in future usecases.
- The PR is not going to change any current behaviour and doesn't break any current behaviour as well. This should be straight enough that we want to avoid removal of cluster by cluster manager whose lifecycle is managed by custom implementation.
As this PR doesn't change/break any current behaviour, I think runtime-flag guard is not required. I have updated the description aaccordingly
|
Ping @adisuissa I think this is waiting for opinion from you. |
|
Pinged @adisuissa again, and also in slack. |
Signed-off-by: nbn01 <[email protected]>
adisuissa
left a comment
There was a problem hiding this comment.
Apologies, I was under the weather, and just got back to this.
| bool connection_pool_per_downstream_connection = 51; | ||
|
|
||
| // If ``ignore_removal`` is true, the cluster manager will ignore the cluster while removing during CDS event. | ||
| // This is useful when cluster is created and managed by custom implementation. For example, Dynamic Forward Proxy. |
There was a problem hiding this comment.
Hiding from the docs should not be considered, IMHO, as it should be used for API that needs more testing (not to be hidden from some use-cases).
I think the question is whether it makes sense for DFP to have both clusters that are removed and clusters that are kept all the time. From your comments I gather that in DFP one would want to ignore the CDS removal, so it seems that a single knob (on the DFP config) makes more sense, no?
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
| if (existing_active_cluster != active_clusters_.end() && | ||
| existing_active_cluster->second->added_via_api_) { | ||
| existing_active_cluster->second->added_via_api_ && | ||
| existing_active_cluster->second->ignore_removal_ == remove_ignored) { |
There was a problem hiding this comment.
| existing_active_cluster->second->ignore_removal_ == remove_ignored) { | |
| (!existing_active_cluster->second->ignore_removal_ || remove_ignored)) { |
does this could be better?
There was a problem hiding this comment.
This will make cluster to remove when remove_ignored set to true and cluster data has ignore_removal set to false.
This should fine as well. removeCluster will behave as current for cluster with ignore_removal false irrespective of remove_ignored value. And remove_ignored will only take effect for cluster with ignore_removal set to true.
Signed-off-by: nbn01 <[email protected]>
|
/retest |
|
also this needs a main merge |
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
|
I'm trying to rerun the job, but it may need another main merge (due to a recent CI upgrade) |
Signed-off-by: nbn01 <[email protected]>
|
Seems that CI complains about coverage. Please follow link at https://github.com/envoyproxy/envoy/actions/runs/11157572663/job/31012169240#step:12:6358 to see the code that is not covered. |
Signed-off-by: nbn01 <[email protected]>
Signed-off-by: nbn01 <[email protected]>
|
/retest |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks!
LGTM, and left some minor nits.
Good to merge IMHO.
Signed-off-by: nbn01 <[email protected]>
|
/retest |
| auto existing_active_cluster = active_clusters_.find(cluster_name); | ||
| if (existing_active_cluster != active_clusters_.end() && | ||
| existing_active_cluster->second->added_via_api_) { | ||
| existing_active_cluster->second->added_via_api_ && |
There was a problem hiding this comment.
Thanks for picking up this change, and sorry coming in late with a possibly naive question.
So the problem is we add a DFP cluster via CDS, the DFP cluster adds each host as a sub-cluster, and subsequently the DFP sub-clusters are removed by CDS updates right?
Would it be cleaner rather than adding the ignore tags, to simply have the sub-clusters not tagged as added via API? Or would that then cause problems for removal?
If it complicates removal WDYT of instead of having an "added by API" bool and a "ignore" bool, if we change both addOrUpdateCluster to include a enum Type (Static, Cds, DFP) where each cluster retains its type and we ignore CDS removals for DFP?
/wait-any for comments
There was a problem hiding this comment.
Thanks for your inputs.
Like you said, tagging clusters with not added_via_api would make the changes more complex and could impact existing behavior.
The cluster api spec already has type and cluster_type fields, but the DFP sub-cluster sets type to STRICT_DNS. Having another enum in API spec or having enum as addOrUpdateCluster param will abstract the resulting behavior, i.e., avoiding cds removal.
I feel avoid_cds_removal parameter makes it clear & clean for the caller and easy to manage, not just for DFP sub-clusters, but for any other use cases in future where custom implementations will manage the cluster lifecycle (similar to DFP).
Open for thoughts :)
…o DFPCluster removed (envoyproxy#35848) Commit Message: - Add an optional argument called `ignore_removal` to `ClusterManagerImpl::addOrUpdateCluster` and `ClusterManagerImpl::loadCluster`. This argument defaults to `false`, so it won't affect any existing flows. We'll be setting this in Cluster Data. - If the `ignore_removal` value is `true`, then the cluster won't be removed when `ClusterManagerImpl::removeCluster` is called. - To remove a cluster that has been added with `ignore_removal` set to `true`, the `remove_ignored` argument must be set to `true` when `ClusterManagerImpl::removeCluster` is called. This helps to manage clusters whose lifecycle is managed by custom implementations similar to DFP clusters. Additional Description: - Currently clusters that are dynamically added with custom implementations from filters, etc. are removed when a CDS event is triggered. This is because these dynamically created clusters will come in diff of CDS and will be removed by the cluster manager. Risk Level: low Testing: unit test Docs Changes: no Release Notes: no Signed-off-by: Gustavo <[email protected]>
Commit Message:
ignore_removaltoClusterManagerImpl::addOrUpdateClusterandClusterManagerImpl::loadCluster. This argument defaults tofalse, so it won't affect any existing flows. We'll be setting this in Cluster Data.ignore_removalvalue istrue, then the cluster won't be removed whenClusterManagerImpl::removeClusteris called.ignore_removalset totrue, theremove_ignoredargument must be set totruewhenClusterManagerImpl::removeClusteris called.This helps to manage clusters whose lifecycle is managed by custom implementations similar to DFP clusters.
Additional Description:
Risk Level: low
Testing: unit test
Docs Changes: no
Release Notes: no
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]
Fixes: #35171