Skip to content

Kmesh ads mode cluster add consistent hash lb #888

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

Merged
merged 18 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/cluster/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ message Cluster {
ROUND_ROBIN = 0;
LEAST_REQUEST = 1;
RANDOM = 3;
MAGLEV = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason why enum selects 5 can be commented here.

Copy link
Member Author

Choose a reason for hiding this comment

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

it is just keep same as upstream of envoy

}

core.ApiStatus api_status = 128;
Expand Down
16 changes: 16 additions & 0 deletions api/route/route_components.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,26 @@ message RouteAction {
// assigned to each cluster.
WeightedCluster weighted_clusters = 3;
}

message HashPolicy {
message Header {
// The name of the request header that will be used to obtain the hash
// key. If the request header is not present, no hash will be produced.
string header_name = 1;
}

oneof policy_specifier {

// Header hash policy.
Header header = 1;
}
}

// the matched prefix (or path) should be swapped with this value.
string prefix_rewrite = 5;
uint32 timeout = 8;
RetryPolicy retry_policy = 9;
repeated HashPolicy hash_policy = 15;
}

message RetryPolicy {
Expand Down
14 changes: 8 additions & 6 deletions api/v2-c/cluster/cluster.pb-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@ void cluster__cluster__free_unpacked
assert(message->base.descriptor == &cluster__cluster__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCEnumValue cluster__cluster__lb_policy__enum_values_by_number[3] =
static const ProtobufCEnumValue cluster__cluster__lb_policy__enum_values_by_number[4] =
{
{ "ROUND_ROBIN", "CLUSTER__CLUSTER__LB_POLICY__ROUND_ROBIN", 0 },
{ "LEAST_REQUEST", "CLUSTER__CLUSTER__LB_POLICY__LEAST_REQUEST", 1 },
{ "RANDOM", "CLUSTER__CLUSTER__LB_POLICY__RANDOM", 3 },
{ "MAGLEV", "CLUSTER__CLUSTER__LB_POLICY__MAGLEV", 5 },
};
static const ProtobufCIntRange cluster__cluster__lb_policy__value_ranges[] = {
{0, 0},{3, 2},{0, 3}
{0, 0},{3, 2},{5, 3},{0, 4}
};
static const ProtobufCEnumValueIndex cluster__cluster__lb_policy__enum_values_by_name[3] =
static const ProtobufCEnumValueIndex cluster__cluster__lb_policy__enum_values_by_name[4] =
{
{ "LEAST_REQUEST", 1 },
{ "MAGLEV", 3 },
{ "RANDOM", 2 },
{ "ROUND_ROBIN", 0 },
};
Expand All @@ -74,11 +76,11 @@ const ProtobufCEnumDescriptor cluster__cluster__lb_policy__descriptor =
"LbPolicy",
"Cluster__Cluster__LbPolicy",
"cluster",
3,
4,
cluster__cluster__lb_policy__enum_values_by_number,
3,
4,
cluster__cluster__lb_policy__enum_values_by_name,
2,
3,
cluster__cluster__lb_policy__value_ranges,
NULL,NULL,NULL,NULL /* reserved[1234] */
};
Expand Down
3 changes: 2 additions & 1 deletion api/v2-c/cluster/cluster.pb-c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 107 additions & 5 deletions api/v2-c/route/route_components.pb-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ void route__route_match__free_unpacked
assert(message->base.descriptor == &route__route_match__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void route__route_action__hash_policy__header__init
(Route__RouteAction__HashPolicy__Header *message)
{
static const Route__RouteAction__HashPolicy__Header init_value = ROUTE__ROUTE_ACTION__HASH_POLICY__HEADER__INIT;
*message = init_value;
}
void route__route_action__hash_policy__init
(Route__RouteAction__HashPolicy *message)
{
static const Route__RouteAction__HashPolicy init_value = ROUTE__ROUTE_ACTION__HASH_POLICY__INIT;
*message = init_value;
}
void route__route_action__init
(Route__RouteAction *message)
{
Expand Down Expand Up @@ -562,7 +574,83 @@ const ProtobufCMessageDescriptor route__route_match__descriptor =
(ProtobufCMessageInit) route__route_match__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor route__route_action__field_descriptors[5] =
static const ProtobufCFieldDescriptor route__route_action__hash_policy__header__field_descriptors[1] =
{
{
"header_name",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_STRING,
0, /* quantifier_offset */
offsetof(Route__RouteAction__HashPolicy__Header, header_name),
NULL,
&protobuf_c_empty_string,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned route__route_action__hash_policy__header__field_indices_by_name[] = {
0, /* field[0] = header_name */
};
static const ProtobufCIntRange route__route_action__hash_policy__header__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor route__route_action__hash_policy__header__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"route.RouteAction.HashPolicy.Header",
"Header",
"Route__RouteAction__HashPolicy__Header",
"route",
sizeof(Route__RouteAction__HashPolicy__Header),
1,
route__route_action__hash_policy__header__field_descriptors,
route__route_action__hash_policy__header__field_indices_by_name,
1, route__route_action__hash_policy__header__number_ranges,
(ProtobufCMessageInit) route__route_action__hash_policy__header__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor route__route_action__hash_policy__field_descriptors[1] =
{
{
"header",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Route__RouteAction__HashPolicy, policy_specifier_case),
offsetof(Route__RouteAction__HashPolicy, header),
&route__route_action__hash_policy__header__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned route__route_action__hash_policy__field_indices_by_name[] = {
0, /* field[0] = header */
};
static const ProtobufCIntRange route__route_action__hash_policy__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor route__route_action__hash_policy__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"route.RouteAction.HashPolicy",
"HashPolicy",
"Route__RouteAction__HashPolicy",
"route",
sizeof(Route__RouteAction__HashPolicy),
1,
route__route_action__hash_policy__field_descriptors,
route__route_action__hash_policy__field_indices_by_name,
1, route__route_action__hash_policy__number_ranges,
(ProtobufCMessageInit) route__route_action__hash_policy__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor route__route_action__field_descriptors[6] =
{
{
"cluster",
Expand Down Expand Up @@ -624,21 +712,35 @@ static const ProtobufCFieldDescriptor route__route_action__field_descriptors[5]
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"hash_policy",
15,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(Route__RouteAction, n_hash_policy),
offsetof(Route__RouteAction, hash_policy),
&route__route_action__hash_policy__descriptor,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned route__route_action__field_indices_by_name[] = {
0, /* field[0] = cluster */
5, /* field[5] = hash_policy */
2, /* field[2] = prefix_rewrite */
4, /* field[4] = retry_policy */
3, /* field[3] = timeout */
1, /* field[1] = weighted_clusters */
};
static const ProtobufCIntRange route__route_action__number_ranges[4 + 1] =
static const ProtobufCIntRange route__route_action__number_ranges[5 + 1] =
{
{ 1, 0 },
{ 3, 1 },
{ 5, 2 },
{ 8, 3 },
{ 0, 5 }
{ 15, 5 },
{ 0, 6 }
};
const ProtobufCMessageDescriptor route__route_action__descriptor =
{
Expand All @@ -648,10 +750,10 @@ const ProtobufCMessageDescriptor route__route_action__descriptor =
"Route__RouteAction",
"route",
sizeof(Route__RouteAction),
5,
6,
route__route_action__field_descriptors,
route__route_action__field_indices_by_name,
4, route__route_action__number_ranges,
5, route__route_action__number_ranges,
(ProtobufCMessageInit) route__route_action__init,
NULL,NULL,NULL /* reserved[123] */
};
Expand Down
56 changes: 55 additions & 1 deletion api/v2-c/route/route_components.pb-c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions api/v2/cluster/cluster.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading