-
Notifications
You must be signed in to change notification settings - Fork 132
maintain cluster active connection counter for circuit breaker #570
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
maintain cluster active connection counter for circuit breaker #570
Conversation
|
how should i get the cluster id? Using cluster name will exceed the stack size limit? |
|
Some files need to be updated, please run 'make gen' and include any changed files in your PR |
3fc8d0f to
53ab706
Compare
|
/unhold |
e4a76b0 to
86004b1
Compare
0119ade to
a9e3c58
Compare
|
I use a special way to reject connection, plz check Tested in oe23.03. |
9138cef to
1eb8103
Compare
hzxuzhonghu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly LGTM
Defer to @nlgwcy for the connection reset
|
|
||
| core.ApiStatus api_status = 128; | ||
| string name = 1; | ||
| uint32 id = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weired, seems the tag number is random
| stats = kmesh_map_lookup_elem(&map_of_cluster_stats, key); | ||
| if (!stats) { | ||
| struct cluster_stats new_stats = {0}; | ||
| new_stats.active_connections = delta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it happen delta = -1 here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, need a check here.
| "Current active connections %d exceeded max connections %d, reject connection\n", | ||
| stats->active_connections, | ||
| cbs->max_connections); | ||
| return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always use 0 as success and negative number as error code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| (ctx)->user_ip4 = (address)->ipv4; \ | ||
| (ctx)->user_port = (address)->port | ||
|
|
||
| #define MARK_REJECTED(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what is this for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cgroups/connect4 and sockops both use cluster_manager, without it will compile fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In kernel-native mode, if the running environment is not enhanced kernel(that is, L7 kernel traffic management is not supported), Kmesh completes L4 traffic management in the connect hook.
// cgroup_sock.c
cgroup_connect4_prog -> sock4_traffic_control -> listener_manager -> SEC_TAIL(KMESH_TAIL_CALL_FILTER_CHAIN) -> SEC_TAIL(KMESH_TAIL_CALL_FILTER) -> tcp_proxy_manager -> SEC_TAIL(KMESH_TAIL_CALL_CLUSTER) -> on_cluster_sock_bindSo, on this path, if circuit breaker is triggered, the service also needs to be rejected.
bpf/kmesh/ads/sockops.c
Outdated
| } | ||
| break; | ||
| case BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: | ||
| if (bpf_sock_ops_cb_flags_set(skops, BPF_SOCK_OPS_STATE_CB_FLAG) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why set cb for inbound
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will delete it
| if (daddr == 0 && dport == 0) { | ||
| tcp_set_state(sk, TCP_CLOSE); | ||
| sk->sk_route_caps = 0; | ||
| inet_sk(sk)->inet_dport = 0; | ||
| err = -1; | ||
| goto out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nlgwcy to review
| stats->active_connections, | ||
| cbs->max_connections); | ||
| return 0; | ||
| return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
Signed-off-by: 923048992@qq.com <923048992@qq.com>
Signed-off-by: Okabe-Rintarou-0 <923048992@qq.com>
abfa7ab to
8615e75
Compare
b9585ec to
2510d8f
Compare
pkg/bpf/bpf_kmesh.go
Outdated
| * limitations under the License. | ||
| * Author: nlgwcy | ||
| * Create: 2022-02-26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
pkg/bpf/bpf_kmesh.go
Outdated
| "kmesh.net/kmesh/daemon/options" | ||
| ) | ||
|
|
||
| type BpfTracePoint struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have split bpf progs, should not revert
| // resourceHash[0]:cds resourceHash[1]:eds | ||
| resourceHash map[string][2]uint64 | ||
| resourceHash map[string][2]uint64 | ||
| hashName *utils.HashName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is persisting in hashName, do we need it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, i would think we can pkg github.com/google/uuid to generate uuid
pkg/cache/v2/cluster.go
Outdated
|
|
||
| for it.Next(&key, &value) { | ||
| if key.ClusterId == clusterId { | ||
| log.Debugf("remove cluster stats with key %v", key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
5345d93 to
0941b43
Compare
Signed-off-by: 923048992@qq.com <923048992@qq.com>
0941b43 to
e9af645
Compare
hzxuzhonghu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#570 (comment) can be done later
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |

What type of PR is this?
feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Proposal here #397
Special notes for your reviewer:
Does this PR introduce a user-facing change?: