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

Remove the limit on the number of Endpoints in AntreaProxy #4167

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Aug 29, 2022

Fixes: #2092

Due to the message size of Openflow, the maximum number of Endpoints for
a Service in AntreaProxy is 800. Since Openflow 1.5 is used in Antrea,
the operation insert_buckets introduced in Openflow 1.5 can be used to
create a Service with more than 800 Endpoints. To sync Service with more
than 800 Endpoints to OVS, multiple Openflow messages will be sent to
OVS in a bundle (the first message uses add to sync the OVS group and
its corresponding buckets to OVS, other messages use insert_buckets to
sync other buckets to OVS).

Signed-off-by: Hongliang Liu [email protected]

@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

Merging #4167 (de2c2e0) into main (0f77529) will increase coverage by 3.99%.
The diff coverage is 70.58%.

❗ Current head de2c2e0 differs from pull request most recent head dab08c7. Consider uploading reports for the commit dab08c7 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4167      +/-   ##
==========================================
+ Coverage   62.26%   66.26%   +3.99%     
==========================================
  Files         385      304      -81     
  Lines       54501    46637    -7864     
==========================================
- Hits        33933    30902    -3031     
+ Misses      18069    13326    -4743     
+ Partials     2499     2409      -90     
Flag Coverage Δ
integration-tests 35.13% <56.86%> (+0.29%) ⬆️
kind-e2e-tests 49.08% <64.70%> (+0.92%) ⬆️
unit-tests 45.17% <10.78%> (+1.31%) ⬆️
Impacted Files Coverage Δ
pkg/agent/openflow/multicast.go 0.00% <0.00%> (-21.20%) ⬇️
pkg/agent/openflow/service.go 91.57% <40.00%> (+0.27%) ⬆️
pkg/ovs/openflow/ofctrl_bridge.go 77.21% <58.13%> (+1.08%) ⬆️
pkg/agent/openflow/client.go 69.31% <66.66%> (-2.55%) ⬇️
pkg/ovs/openflow/ofctrl_group.go 73.39% <96.55%> (+8.76%) ⬆️
pkg/agent/openflow/pipeline.go 82.59% <100.00%> (-0.96%) ⬇️
pkg/agent/proxy/proxier.go 69.93% <100.00%> (+4.92%) ⬆️
pkg/apis/controlplane/types.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/agent/apiserver/handlers/errors.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/antctl/transform/common/transform.go 0.00% <0.00%> (-78.95%) ⬇️
... and 189 more

@hongliangl hongliangl changed the title Remove Endpoint limit in AntreaProxy Remove Endpoint limitation in AntreaProxy Aug 30, 2022
@hongliangl hongliangl changed the title Remove Endpoint limitation in AntreaProxy Remove the limit on the number of Endpoints in AntreaProxy Aug 30, 2022
@hongliangl hongliangl force-pushed the 20220826-openflow1.5 branch 2 times, most recently from ce5d9d5 to 610a9b2 Compare August 30, 2022 07:04
pkg/ovs/openflow/ofctrl_group.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_bridge.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_group.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_bridge.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/multicast.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_bridge.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_bridge.go Outdated Show resolved Hide resolved
@hongliangl hongliangl force-pushed the 20220826-openflow1.5 branch 3 times, most recently from c6b43cb to 13085d9 Compare August 31, 2022 02:38
@hongliangl hongliangl added area/proxy Issues or PRs related to proxy functions in Antrea action/release-note Indicates a PR that should be included in release notes. labels Aug 31, 2022
@hongliangl hongliangl force-pushed the 20220826-openflow1.5 branch 3 times, most recently from 7efd76f to fc18daf Compare August 31, 2022 11:51
@hongliangl hongliangl marked this pull request as ready for review August 31, 2022 11:52
@hongliangl hongliangl force-pushed the 20220826-openflow1.5 branch 2 times, most recently from 6ff9140 to c524be5 Compare September 6, 2022 03:20
pkg/ovs/openflow/ofctrl_group.go Outdated Show resolved Hide resolved
}
return true
return b.ofSwitch.DeleteGroup(uint32(id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why needs this b.ofSwitch.DeleteGroup(uint32(id))?

g.Delete() should already delete the group on OVS, and ofGroup.Add() does not add any object into ofctrl cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need b.ofSwitch.DeleteGroup(uint32(id)) to delete the group id cache in OFSwitch. We can see that when creating a new group:

// Create a new group. return an error if it already exists
func (self *OFSwitch) NewGroup(groupId uint32, groupType GroupType) (*Group, error) {
	// check if the group already exists
	if self.groupDb[groupId] != nil {
		return nil, errors.New("group already exists")
	}

	// Create a new group
	group := newGroup(groupId, groupType, self)
	// Save it in the DB
	self.groupDb[groupId] = group

	return group, nil
}

g.Add() and g.Delete() don't change the group id cache in OFSwitch since they are sent to OVS by bundle:

func (g *ofGroup) Add() error {
	return g.bridge.AddOFEntriesInBundle([]OFEntry{g}, nil, nil)
}

func (g *ofGroup) Modify() error {
	return g.bridge.AddOFEntriesInBundle(nil, []OFEntry{g}, nil)
}

func (g *ofGroup) Delete() error {
	return g.bridge.AddOFEntriesInBundle(nil, nil, []OFEntry{g})
}

As a result, when deleting a group, we need also to delete the group id from OFSwitch cache.

pkg/ovs/openflow/ofctrl_bridge.go Outdated Show resolved Hide resolved
Comment on lines 92 to 104
for i, done := 0, false; done != true; i++ {
// Get the range of buckets to generate a temp group.
firstBucketIdx := i * MaxBucketsPerMessage
lastBucketIdx := (i + 1) * MaxBucketsPerMessage
if lastBucketIdx > len(g.ofctrl.Buckets) {
lastBucketIdx = len(g.ofctrl.Buckets)
done = true
}
// Generate a temp group to get an OVS message. Note that, the original group should not be modified since it is
// also stored in group cache, and the group cache is used when replying groups.
groupMessage := &ofctrl.Group{
ID: g.ofctrl.ID,
GroupType: g.ofctrl.GroupType,
Buckets: g.ofctrl.Buckets[firstBucketIdx:lastBucketIdx],
}
Copy link
Member

Choose a reason for hiding this comment

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

what if number of buckets equals MaxBucketsPerMessage? Is it legal to insert empty buckets?

I think the code could be simplified:

	for start := 0; start < len(g.ofctrl.Buckets); start += MaxBucketsPerMessage {
		// Get the range of buckets to generate a temp group.
		end := start + MaxBucketsPerMessage
		if end > len(g.ofctrl.Buckets) {
			end = len(g.ofctrl.Buckets)
		}
		// Generate a temp group to get an OVS message. Note that, the original group should not be modified since it is
		// also stored in group cache, and the group cache is used when replying groups.
		groupMessage := &ofctrl.Group{
			ID:        g.ofctrl.ID,
			GroupType: g.ofctrl.GroupType,
			Buckets:   g.ofctrl.Buckets[start:end],
		}
		// For the message which is not the first, insert_buckets is used to add buckets to the group on OVS.
		if start != 0 {
			operation = openflow15.OFPGC_INSERT_BUCKET
		}
		messages = append(messages, groupMessage.GetBundleMessage(operation))
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks better, and I changed a little to support a message when there is no bucket in the group.

pkg/ovs/openflow/ofctrl_group.go Outdated Show resolved Hide resolved
pkg/ovs/openflow/ofctrl_group.go Show resolved Hide resolved
test/integration/ovs/ofctrl_test.go Outdated Show resolved Hide resolved
@hongliangl
Copy link
Contributor Author

/test-all

tnqn
tnqn previously approved these changes Sep 13, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Sep 13, 2022

can we increase code coverage of the modified code?

@tnqn
Copy link
Member

tnqn commented Sep 13, 2022

can we increase code coverage of the modified code?

maybe the low coverage is because the commit's parent patch is not the latest, could you rebase on main?

@hongliangl
Copy link
Contributor Author

/test-all

@wenqiq
Copy link
Contributor

wenqiq commented Sep 15, 2022

The Codecov patch report seems inaccurate, and someone has reported the same issue.
https://community.codecov.com/t/codecov-comment-still-says-consider-uploading-reports-for-the-commit-to-get-more-accurate-results-after-reports-have-been-uploaded/3747
It seems that this issue has not been resolved yet.
However, I think we can reference the CodeCov report of the newest commit b65c3b4:
https://app.codecov.io/gh/antrea-io/antrea/commit/b65c3b47f2b78c801460b2ae47672aa041648072
This shows that the patch test coverage is 63.04%.
Also see the compare report: https://codecov.io/gh/antrea-io/antrea/compare/c5a52093833a841ff3a128cfc97f8224df325c62...b65c3b47f2b78c801460b2ae47672aa041648072/commits

@tnqn
Copy link
Member

tnqn commented Sep 16, 2022

However, I think we can reference the CodeCov report of the newest commit b65c3b4:
https://app.codecov.io/gh/antrea-io/antrea/commit/b65c3b47f2b78c801460b2ae47672aa041648072

The result still looks confusing. The patch doesn't touch packetin.go and clickhouse.go but their coverage change.

@wenqiq
Copy link
Contributor

wenqiq commented Sep 21, 2022

However, I think we can reference the CodeCov report of the newest commit b65c3b4:
https://app.codecov.io/gh/antrea-io/antrea/commit/b65c3b47f2b78c801460b2ae47672aa041648072

The result still looks confusing. The patch doesn't touch packetin.go and clickhouse.go but their coverage change.

The Change is related to project's coverage and the Patch is related to the diff lines in the patch. If we want to see Coverage concerning only lines adjusted in the commit diff we can reference the Patch column.
As the CI Failed(where I am confused, there’s not a failure in the CI pipelines) shown on the page, the Change diff may be caused by Different error handling paths.(https://docs.codecov.com/docs/unexpected-coverage-changes#reasons-for-unexpected-changes)
see also: https://docs.codecov.com/docs/codecov-delta

@hongliangl
Copy link
Contributor Author

/test-all

Fixes: antrea-io#2092

Due to the message size of Openflow, the maximum number of Endpoints for
a Service in AntreaProxy is 800. Since Openflow 1.5 is used in Antrea,
the operation `insert_buckets` introduced in Openflow 1.5 can be used to
create a Service with more than 800 Endpoints. To sync Service with more
than 800 Endpoints to OVS, multiple Openflow messages will be sent to
OVS in a bundle (the first message uses `add` to sync the OVS group and
its corresponding buckets to OVS, other messages use `insert_buckets` to
sync other buckets to OVS).

Signed-off-by: Hongliang Liu <[email protected]>
@hongliangl
Copy link
Contributor Author

/test-all

@hongliangl
Copy link
Contributor Author

Could we merge the PR now @tnqn ?

@tnqn tnqn merged commit e7486d5 into antrea-io:main Sep 27, 2022
@hongliangl hongliangl deleted the 20220826-openflow1.5 branch September 28, 2022 01:41
@hongliangl
Copy link
Contributor Author

Thanks for merging @tnqn

heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
…#4167)

Fixes: antrea-io#2092

Due to the message size of Openflow, the maximum number of Endpoints for
a Service in AntreaProxy is 800. Since Openflow 1.5 is used in Antrea,
the operation `insert_buckets` introduced in Openflow 1.5 can be used to
create a Service with more than 800 Endpoints. To sync Service with more
than 800 Endpoints to OVS, multiple Openflow messages will be sent to
OVS in a bundle (the first message uses `add` to sync the OVS group and
its corresponding buckets to OVS, other messages use `insert_buckets` to
sync other buckets to OVS).

Signed-off-by: Hongliang Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes. area/proxy Issues or PRs related to proxy functions in Antrea
Projects
None yet
4 participants