Skip to content

Refactor hot restart rpc stream - #29454

Merged
ravenblackx merged 5 commits into
envoyproxy:mainfrom
ravenblackx:hot_restart_rpc
Sep 12, 2023
Merged

ravenblackx merged 5 commits into
envoyproxy:mainfrom
ravenblackx:hot_restart_rpc

Conversation

@ravenblackx

@ravenblackx ravenblackx commented Sep 6, 2023 •

Copy link
Copy Markdown
Contributor

Commit Message: Refactor hot restart RPC stream
Additional Description: Before this PR, the RPC stream behavior is hardcoded into HotRestartingBase. This change breaks it out into a member class, as a precursor to udp forwarding during hot restart, which will require an additional channel for forwarded UDP. By unifying the RPC behavior into a separate class, we can have two instances of the class rather than duplicating a lot of code.
Risk Level: Very low, as this is essentially a no-op.
Testing: As covered as it was before. Coverage should be improved with the change that comes after this (#29328).
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Comment thread source/server/hot_restarting_base.h Outdated
void sendHotRestartMessage(sockaddr_un& address, const envoy::HotRestartMessage& proto);
HotRestartingBase(uint64_t base_id) : main_rpc_stream_(base_id) {}

enum class Blocking { Yes, No };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be moved to RpcStream?


// Returns a Gauge that tracks hot-restart generation, where every successive
// child increments this number.
static Stats::Gauge& hotRestartGeneration(Stats::Scope& scope);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the only method remaining in HotRestartingBase. Should we just rename HotRestartingBase to RpcStream and move this method to a util function?

On the other hand, the reason to extract RpcStream is because HotRestartingBase has code specific to TCP. But it seems that almost all the code will be reused.

@ravenblackx ravenblackx Sep 8, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not just the methods, it's the protected members too. After this change, that's just the one rpc_stream, but with the following change it's both rpc_streams. To some extent it might make sense to refactor that significantly and make the parent and child instances of rpc streams have totally distinct initializers, but I'm trying to make the minimum change to the existing structure that will allow the necessary functionality to be added - I'd rather not add massive cleanup time to my roster.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you do s/HotRestartingBase/RpcStream in the .h and .cc file and add a class definition somewhere?

class HotRestartingBase {
protected:
RpcStream main_rpc_stream_;
}

At the first glance, this will do what the same thing as the current PR does and have a smaller diff for code review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ravenblackx ravenblackx assigned ggreenway and unassigned danzh2010 Sep 8, 2023

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ravenblackx
ravenblackx merged commit 3596fd3 into envoyproxy:main Sep 12, 2023
@ravenblackx
ravenblackx deleted the hot_restart_rpc branch September 12, 2023 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants