Skip to content

Init manager checking unready targets with target-aware watchers#12035

Merged
lizan merged 48 commits intoenvoyproxy:masterfrom
ping-sun:init-manager-query-unready-targets
Aug 7, 2020
Merged

Init manager checking unready targets with target-aware watchers#12035
lizan merged 48 commits intoenvoyproxy:masterfrom
ping-sun:init-manager-query-unready-targets

Conversation

@ping-sun
Copy link
Contributor

@ping-sun ping-sun commented Jul 10, 2020

Linked Issue: #11963

Description: The current init manager only knows how many registered targets are not ready via its count_ field. This pull request mainly helps init manager to check which specific targets are not ready.

Key idea: Init manager stores the unready_target_name:count key-value pair in a hash map to check which registered targets are not ready. Enable passing target name into watcher's callback function.

  1. When a new target is added into the targets list, increase the occurrence of the target's name in the hash map ++target_name_count_[target_name].

  2. When a target is ready, it informs the manager's watcher and finally, the watcher notifies the manager(that's why we need to pass a string_view name parameter to the manager's callback). And decrease the count of the target's name by 1.
    --target_name_count_[target_name].

Most recent update:
[Latest Implementation] Wrapped the old ReadyFn type function into the new TargetAwareReadyFn. Now WatcherImpl can take both types of function in its Ctor.

[Outdated Implementation] Split WatcherImpl into two classes, the old one and a new TargetAwareWatcherImpl. As we now limit the watcher_ inside ManagerImpl to receive a string_view parameter, we declare it to be of TargetAwareWatcherImpl.

In the current code base, watchers are basically constructed with std::function<void()>. In order to adopt the new feature(pass a string_view parameter to the manager's callback, I wrote a new constructor for WatcherImpl with std::function<void(absl::string_view)> parameter. In addition, I added a onTargetReadySendTargetName(string_view) adopted from the original callback onTargetReady(). So now both types of callbacks are supported. I've also updated code in the constructor of ManagerImpl, and now the watcher_ of a manager is constructed with the new type of function(with string_view parameter). Therefore, the manager will always get target_name from the watcher's callback.

Followup: Unready targets config dumps #12554

Risk Level: Low

The diagram below illustrates the outline of this PR
envoy_init

ping-sun added 2 commits July 9, 2020 23:50
Signed-off-by: ping sun <pingsun@google.com>
Signed-off-by: ping sun <pingsun@google.com>
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Great start!

@lambdai
Copy link
Contributor

lambdai commented Jul 10, 2020

CC @jplevyak

Signed-off-by: ping sun <pingsun@google.com>
…view; targetHandle->name(); remove target_names_ vector

Signed-off-by: pingsun <pingsun@google.com>
@ping-sun
Copy link
Contributor Author

Thank you guys for the great reviews~ 'checkUnreadyTargets()' is just a basic function to check if the method could work. I am working on dumping the info to protobuf message and finally be used by admin handler.

ping-sun added 2 commits July 10, 2020 16:45
Signed-off-by: ping sun <pingsun@google.com>
Signed-off-by: ping sun <pingsun@google.com>
@junr03
Copy link
Member

junr03 commented Jul 13, 2020

/wait

lambdai
lambdai previously approved these changes Jul 13, 2020
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

LGTM

Could you link the issue or address the follow up in description?

ping-sun added 2 commits July 14, 2020 19:13
Signed-off-by: pingsun <pingsun@google.com>
Signed-off-by: pingsun <pingsun@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #12035 was synchronize by ASOPVII.

see: more, trace.

@ping-sun
Copy link
Contributor Author

LGTM

Could you link the issue or address the follow up in description?

Sure, updated.

ping-sun added 2 commits July 14, 2020 20:25
Signed-off-by: pingsun <pingsun@google.com>
Signed-off-by: pingsun <pingsun@google.com>
@ping-sun
Copy link
Contributor Author

ping-sun commented Jul 14, 2020

New Design:
Most recent update:
In the current code base, watchers are basically constructed with std::function<void()>. In order to adopt the new feature(pass a string_view parameter to the manager's callback, I wrote a new constructor for WatcherImpl with std::function<void(absl::string_view)> parameter. In addition, I added a onTargetReadySendTargetName(string_view) adopted from the original callback onTargetReady(). So now both types of callbacks are supported. I've also updated code in the constructor of ManagerImpl, and now the watcher_ of a manager is constructed with the new type of function(with string_view parameter).

ping-sun added 4 commits July 14, 2020 23:37
Signed-off-by: pingsun <pingsun@google.com>
Signed-off-by: pingsun <pingsun@google.com>
Signed-off-by: pingsun <pingsun@google.com>
lambdai
lambdai previously approved these changes Aug 5, 2020
Copy link
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

This LGTM now. WDYT @lizan ?

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Thanks, this is on the right track.

…alize unreadyTargetsConfigDump

Signed-off-by: pingsun <pingsun@google.com>
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Can we split the init manager refactoring part to another PR?

@ping-sun
Copy link
Contributor Author

ping-sun commented Aug 5, 2020

Can we split the init manager refactoring part to another PR?

But I don't think init manager's watcher

Can we split the init manager refactoring part to another PR?

You mean 1 PR for TargetAwareWatcher and 1 PR for manager's onTargetReady? SGTM

@lizan
Copy link
Member

lizan commented Aug 5, 2020

You can put both of Init manager / target to a single PR, I meant splitting this PR to the following two:

  • refactoring init manager / target / handler to optionally take names
  • dump unready targets in admin endpoint

@ping-sun
Copy link
Contributor Author

ping-sun commented Aug 5, 2020

@lizan I've updated this PR and separated the config dump into another branch, please review the recent commit.

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Thanks

@lizan
Copy link
Member

lizan commented Aug 6, 2020

Can you also update PR title and description?

@ping-sun ping-sun changed the title Init manager query unready targets init managers check unready targets with target-aware watchers Aug 6, 2020
@ping-sun ping-sun changed the title init managers check unready targets with target-aware watchers Init manager checking unready targets with target-aware watchers Aug 6, 2020
Signed-off-by: pingsun <pingsun@google.com>
@ping-sun
Copy link
Contributor Author

ping-sun commented Aug 6, 2020

Can you also update PR title and description?

Sure, updated. @lizan Please help review, and I will move on to the "unready target config dump" part.

@ping-sun ping-sun requested review from lambdai and lizan August 6, 2020 03:16
Signed-off-by: pingsun <pingsun@google.com>
@ping-sun
Copy link
Contributor Author

ping-sun commented Aug 7, 2020

Can you also update PR title and description?

I think everything is completed now~

@lizan
Copy link
Member

lizan commented Aug 7, 2020

Thanks!

@lizan lizan merged commit 739f484 into envoyproxy:master Aug 7, 2020
lizan pushed a commit that referenced this pull request Sep 10, 2020
Description: Taking advantage of the new feature introduced in [#12035](#12035), which introduced quick visibility for init managers to check unready targets, this pull request adds protobuf message for unready targets and enables admin to dump configs of unready targets. An example of config dump for listeners’ unready targets is given in this pull request.

Introduce ```InitDumpHandler``` with ```handlerInitDump``` method to help dump information of unready targets.
Add ```dumpUnreadyTargets``` function for ```init::manager```.

Risk Level: Low
Docs Changes: protodoc
Release Notes: Added

Signed-off-by: pingsun <pingsun@google.com>
mattklein123 pushed a commit to envoyproxy/data-plane-api that referenced this pull request Sep 10, 2020
Description: Taking advantage of the new feature introduced in [#12035](envoyproxy/envoy#12035), which introduced quick visibility for init managers to check unready targets, this pull request adds protobuf message for unready targets and enables admin to dump configs of unready targets. An example of config dump for listeners’ unready targets is given in this pull request.

Introduce ```InitDumpHandler``` with ```handlerInitDump``` method to help dump information of unready targets.
Add ```dumpUnreadyTargets``` function for ```init::manager```.

Risk Level: Low
Docs Changes: protodoc
Release Notes: Added

Signed-off-by: pingsun <pingsun@google.com>

Mirrored from https://github.com/envoyproxy/envoy @ 8aef76370877c66b09f7791f0577ca83aad7d608
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants