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

Install all Endpoint flows belong to a Service via single bundle #2476

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Jul 27, 2021

It was observed that installing a bundle took around 1~3ms. In
InstallEndpointFlows, agent created a bundle for each Endpoint and
installed them sequentially. If there are many Services and Endpoints,
it could take long time to install flows in this fashion when agent
restarts. For instance, it took ~78s to install all flows for 4K
Services and 28K Endpoints.

This patch uses single bundle for all Endpoint flows belong to a Service
to reduce the number of bundles. In the above scale, the execution time
was reduced from ~78s to ~30s.

Signed-off-by: Quan Tian qtian@vmware.com

@tnqn
Copy link
Member Author

tnqn commented Jul 27, 2021

/test-all

@tnqn
Copy link
Member Author

tnqn commented Jul 29, 2021

/test-integration
/test-conformance
/test-e2e
/test-networkpolicy

hongliangl
hongliangl previously approved these changes Jul 29, 2021
pkg/agent/openflow/client.go Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2021

Codecov Report

Merging #2476 (383d7c0) into main (cdc8453) will increase coverage by 4.94%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2476      +/-   ##
==========================================
+ Coverage   59.82%   64.77%   +4.94%     
==========================================
  Files         284      284              
  Lines       22168    25583    +3415     
==========================================
+ Hits        13263    16572    +3309     
+ Misses       7483     7456      -27     
- Partials     1422     1555     +133     
Flag Coverage Δ
e2e-tests 55.77% <100.00%> (?)
kind-e2e-tests 46.87% <100.00%> (-0.21%) ⬇️
unit-tests 42.24% <82.35%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/openflow/client.go 70.88% <100.00%> (+13.25%) ⬆️
pkg/agent/agent_linux.go 80.00% <0.00%> (-20.00%) ⬇️
pkg/controller/egress/ipallocator/allocator.go 67.82% <0.00%> (-15.16%) ⬇️
pkg/controller/networkpolicy/endpoint_querier.go 77.64% <0.00%> (-13.79%) ⬇️
pkg/apis/controlplane/v1beta1/conversion.go 72.44% <0.00%> (-11.89%) ⬇️
pkg/util/ip/ip.go 68.67% <0.00%> (-11.63%) ⬇️
pkg/legacyapis/core/v1alpha2/register.go 69.23% <0.00%> (-10.77%) ⬇️
pkg/controller/egress/controller.go 76.76% <0.00%> (-10.44%) ⬇️
pkg/apis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
pkg/legacyapis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
... and 269 more

_, ok := cache.Load(flowCacheKey)
// If a flow cache entry already exists for the key, skip it.
if ok {
klog.V(2).Infof("Flows with cache key %s are already installed", flowCacheKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

structured logging

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -313,6 +313,41 @@ func (c *client) addFlows(cache *flowCategoryCache, flowCacheKey string, flows [
return nil
}

// addFlowsWithMultipleKeys installs the flows with different flowCache keys and adds them into the cache on success.
// Same as addFlows, it will skip flows whose cache already exists. All flows will be installed via a bundle.
func (c *client) addFlowsWithMultipleKeys(cache *flowCategoryCache, keyToFlows map[string][]binding.Flow) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

it kinds of feels like this function should either call addFlows and re-use the code, or should replace it altogether. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, addFlows can leverage addFlowsWithMultipleKeys. I have made the change to reduce code redundancy.

It was observed that installing a bundle took around 1~3ms. In
InstallEndpointFlows, agent created a bundle for each Endpoint and
installed them sequentially. If there are many Services and Endpoints,
it could take long time to install flows in this fashion when agent
restarts. For instance, it took ~78s to install all flows for 4K
Services and 28K Endpoints.

This patch uses single bundle for all Endpoint flows belong to a Service
to reduce the number of bundles. In the above scale, the execution time
was reduced from ~78s to ~30s.

Signed-off-by: Quan Tian <qtian@vmware.com>
@antoninbas
Copy link
Contributor

/test-all
/test-ipv6-all
/test-ipv6-only-all

@tnqn tnqn merged commit 6280438 into antrea-io:main Aug 2, 2021
@tnqn tnqn deleted the improve-endpoint-flow branch August 2, 2021 02:17
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.

4 participants