Skip to content

Commit

Permalink
Merge pull request #4 from yanet-platform/sync
Browse files Browse the repository at this point in the history
sync with 55.0 version
  • Loading branch information
taitov authored Aug 30, 2023
2 parents e6e7e89 + c0fe2bd commit 958a659
Show file tree
Hide file tree
Showing 17 changed files with 734 additions and 358 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ __pycache__
.settings/
.pydevproject
report/
.qtc_clangd
.vscode
47 changes: 47 additions & 0 deletions autotests/units/001_one_port/049_balancer_version/autotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
steps:
- ipv4Update: "0.0.0.0/0 -> 200.0.0.1"
- ipv6Update: "::/0 -> fe80::1"
- cli_check: |
balancer service any
module virtual_ip proto virtual_port scheduler connections packets bytes version
--------- ---------- ----- ------------ --------- ----------- ------- ----- ----------
balancer0 10.49.0.1 tcp 80 rr 0 0 0 10
balancer0 10.49.0.2 tcp 80 rr 0 0 0 0
balancer0 10.49.0.3 tcp 80 rr 0 0 0 Kukarekuuu
balancer0 10.49.0.4 tcp 80 rr 0 0 0 n/s
- cli_check: |
balancer real any
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes version
--------- ---------- ----- ------------ --------- ---------- --------- ------- ------ ----------- ------- ----- ----------
balancer0 10.49.0.1 tcp 80 rr 2000:49::1 80 false 1 0 0 0 10
balancer0 10.49.0.1 tcp 80 rr 2000:49::2 80 false 1 0 0 0 10
balancer0 10.49.0.2 tcp 80 rr 2001:49::1 80 false 1 0 0 0 0
balancer0 10.49.0.2 tcp 80 rr 2001:49::2 80 false 1 0 0 0 0
balancer0 10.49.0.3 tcp 80 rr 2002:49::1 80 false 1 0 0 0 Kukarekuuu
balancer0 10.49.0.3 tcp 80 rr 2002:49::2 80 false 1 0 0 0 Kukarekuuu
balancer0 10.49.0.4 tcp 80 rr 2003:49::1 80 false 1 0 0 0 n/s
balancer0 10.49.0.4 tcp 80 rr 2003:49::2 80 false 1 0 0 0 n/s
- reload: controlplane.2.conf
- cli_check: |
balancer service any
module virtual_ip proto virtual_port scheduler connections packets bytes version
--------- ---------- ----- ------------ --------- ----------- ------- ----- -------
balancer0 10.49.0.1 tcp 80 rr 0 0 0 11
balancer0 10.49.0.2 tcp 80 rr 0 0 0 0
balancer0 10.49.0.3 tcp 80 rr 0 0 0 Kukarek
balancer0 10.49.0.4 tcp 80 rr 0 0 0 n/s
- cli_check: |
balancer real any
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes version
--------- ---------- ----- ------------ --------- ---------- --------- ------- ------ ----------- ------- ----- -------
balancer0 10.49.0.1 tcp 80 rr 2000:49::1 80 false 1 0 0 0 11
balancer0 10.49.0.1 tcp 80 rr 2000:49::2 80 false 1 0 0 0 11
balancer0 10.49.0.2 tcp 80 rr 2001:49::1 80 false 1 0 0 0 0
balancer0 10.49.0.2 tcp 80 rr 2001:49::2 80 false 1 0 0 0 0
balancer0 10.49.0.3 tcp 80 rr 2002:49::1 80 false 1 0 0 0 Kukarek
balancer0 10.49.0.3 tcp 80 rr 2002:49::2 80 false 1 0 0 0 Kukarek
balancer0 10.49.0.4 tcp 80 rr 2003:49::1 80 false 1 0 0 0 n/s
balancer0 10.49.0.4 tcp 80 rr 2003:49::2 80 false 1 0 0 0 n/s
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"modules": {
"lp0.100": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"acl0": {
"type": "acl",
"nextModules": [
"balancer0",
"route0"
]
},
"balancer0": {
"type": "balancer",
"source": "2000:51b::1",
"services": "services.2.conf",
"nextModule": "route0"
},
"route0": {
"type": "route",
"interfaces": {
"kni0.100": {
"neighborIPv6Address": "fe80::1",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"modules": {
"lp0.100": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "acl0"
},
"acl0": {
"type": "acl",
"nextModules": [
"balancer0",
"route0"
]
},
"balancer0": {
"type": "balancer",
"source": "2000:51b::1",
"services": "services.conf",
"nextModule": "route0"
},
"route0": {
"type": "route",
"interfaces": {
"kni0.100": {
"neighborIPv6Address": "fe80::1",
"neighborMacAddress": "00:00:00:00:00:01",
"nextModule": "lp0.100"
},
"kni0.200": {
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:00:00:02",
"nextModule": "lp0.200"
}
}
}
}
}
69 changes: 69 additions & 0 deletions autotests/units/001_one_port/049_balancer_version/services.2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"vip": "10.49.0.1",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "11",
"reals": [
{
"ip": "2000:49::1",
"port": "80"
},
{
"ip": "2000:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.2",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "0",
"reals": [
{
"ip": "2001:49::1",
"port": "80"
},
{
"ip": "2001:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.3",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "Kukarek",
"reals": [
{
"ip": "2002:49::1",
"port": "80"
},
{
"ip": "2002:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.4",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"reals": [
{
"ip": "2003:49::1",
"port": "80"
},
{
"ip": "2003:49::2",
"port": "80"
}
]
}
]
69 changes: 69 additions & 0 deletions autotests/units/001_one_port/049_balancer_version/services.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"vip": "10.49.0.1",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "10",
"reals": [
{
"ip": "2000:49::1",
"port": "80"
},
{
"ip": "2000:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.2",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "0",
"reals": [
{
"ip": "2001:49::1",
"port": "80"
},
{
"ip": "2001:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.3",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"version": "Kukarekuuu",
"reals": [
{
"ip": "2002:49::1",
"port": "80"
},
{
"ip": "2002:49::2",
"port": "80"
}
]
},
{
"vip": "10.49.0.4",
"proto": "tcp",
"vport": "80",
"scheduler": "rr",
"reals": [
{
"ip": "2003:49::1",
"port": "80"
},
{
"ip": "2003:49::2",
"port": "80"
}
]
}
]
6 changes: 3 additions & 3 deletions autotests/units/001_one_port/056_balancer_ops/autotest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:
expect: 001-expect.pcap
# ops must be ignored by tcp service. connections>0
- cli_check: |
balancer real balancer0 10.0.0.6 tcp
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 10.0.0.6 tcp
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes
--------- ---------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- -----
balancer0 10.0.0.6 tcp 80 wrr 2056::1 80 true 1 2 2 196
Expand All @@ -27,7 +27,7 @@ steps:
expect: 002-expect.pcap
# ops service must not create connections
- cli_check: |
balancer real balancer0 10.0.0.6 udp
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 10.0.0.6 udp
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes
--------- ---------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- -----
balancer0 10.0.0.6 udp 80 wrr 2056::1 80 false 1 0 0 0
Expand All @@ -44,7 +44,7 @@ steps:
expect: 003-expect.pcap
# packets must get different scheduling after flush
- cli_check: |
balancer real balancer0 10.0.0.6 udp
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 10.0.0.6 udp
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes
--------- ---------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- -----
balancer0 10.0.0.6 udp 80 wrr 2056::1 80 true 1 0 1 86
Expand Down
14 changes: 9 additions & 5 deletions cli/src/balancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void service(std::string module_string,
"scheduler",
"connections",
"packets",
"bytes");
"bytes",
"version");

for (const auto& [module, services] : response)
{
Expand All @@ -84,7 +85,7 @@ void service(std::string module_string,
for (const auto& [service_key, service_value] : services)
{
const auto& [virtual_ip, proto, virtual_port] = service_key;
const auto& [scheduler, nap_connections, packets, bytes] = service_value;
const auto& [scheduler, version, nap_connections, packets, bytes] = service_value;
(void)nap_connections; ///< @todo: DELETE

auto proto_string = controlplane::balancer::from_proto(proto);
Expand All @@ -111,7 +112,8 @@ void service(std::string module_string,
scheduler,
connections,
packets,
bytes);
bytes,
version);
}
}

Expand Down Expand Up @@ -209,7 +211,8 @@ void real_find(std::string module_string,
"weight",
"connections",
"packets",
"bytes");
"bytes",
"version");

for (const auto& balancer : response.balancers())
{
Expand Down Expand Up @@ -253,7 +256,8 @@ void real_find(std::string module_string,
real.weight(),
connections,
real.packets(),
real.bytes());
real.bytes(),
service.has_version() ? std::make_optional(service.version()) : std::nullopt);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions common/controlplaneconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ using service_t = std::tuple<balancer_service_id_t,
common::ip_address_t, ///< vip
uint8_t, ///< proto
uint16_t, ///< vport
std::optional<std::string>, ///< version
::balancer::scheduler,
::balancer::scheduler_params,
uint8_t, ///< flags: mss_fix|ops
Expand Down
2 changes: 2 additions & 0 deletions common/icp.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ namespace balancer_summary
namespace balancer_service
{
using service = std::tuple<std::string, ///< scheduler
std::optional<std::string>, ///< version
uint64_t, ///< connections
uint64_t, ///< packets
uint64_t>; ///< bytes
Expand Down Expand Up @@ -387,6 +388,7 @@ namespace balancer_real_find
uint64_t>; ///< bytes

using service = std::tuple<std::string, ///< scheduler
std::optional<std::string>, ///< version
std::vector<real>>;

using request = std::tuple<std::optional<std::string>, ///< module
Expand Down
1 change: 1 addition & 0 deletions common/proto/controlplane.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ message BalancerRealFindResponse {
ServiceKey key = 1;
string scheduler = 2;
repeated Real reals = 3;
optional string version = 4;
}
message BalancerData {
uint32 balancer_id = 1;
Expand Down
Loading

0 comments on commit 958a659

Please sign in to comment.