Removed expiration_interval from LB proto

pull/12488/head
David Garcia Quintas 7 years ago
parent c0ec3ccda4
commit 8c5c654fa3
  1. 9
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
  2. 1
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
  3. 33
      src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
  4. 27
      src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
  5. 7
      src/proto/grpc/lb/v1/load_balancer.proto
  6. 8
      test/cpp/grpclb/grpclb_api_test.cc
  7. 20
      test/cpp/grpclb/grpclb_test.cc

@ -215,9 +215,6 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
return NULL; return NULL;
} }
} }
if (res.server_list.has_expiration_interval) {
sl->expiration_interval = res.server_list.expiration_interval;
}
return sl; return sl;
} }
@ -237,8 +234,6 @@ grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy(
grpc_grpclb_serverlist* copy = grpc_grpclb_serverlist* copy =
(grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist)); (grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
copy->num_servers = sl->num_servers; copy->num_servers = sl->num_servers;
memcpy(&copy->expiration_interval, &sl->expiration_interval,
sizeof(grpc_grpclb_duration));
copy->servers = (grpc_grpclb_server**)gpr_malloc(sizeof(grpc_grpclb_server*) * copy->servers = (grpc_grpclb_server**)gpr_malloc(sizeof(grpc_grpclb_server*) *
sl->num_servers); sl->num_servers);
for (size_t i = 0; i < sl->num_servers; i++) { for (size_t i = 0; i < sl->num_servers; i++) {
@ -257,10 +252,6 @@ bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist* lhs,
if (lhs->num_servers != rhs->num_servers) { if (lhs->num_servers != rhs->num_servers) {
return false; return false;
} }
if (grpc_grpclb_duration_compare(&lhs->expiration_interval,
&rhs->expiration_interval) != 0) {
return false;
}
for (size_t i = 0; i < lhs->num_servers; i++) { for (size_t i = 0; i < lhs->num_servers; i++) {
if (!grpc_grpclb_server_equals(lhs->servers[i], rhs->servers[i])) { if (!grpc_grpclb_server_equals(lhs->servers[i], rhs->servers[i])) {
return false; return false;

@ -39,7 +39,6 @@ typedef grpc_lb_v1_Duration grpc_grpclb_duration;
typedef struct { typedef struct {
grpc_grpclb_server** servers; grpc_grpclb_server** servers;
size_t num_servers; size_t num_servers;
grpc_grpclb_duration expiration_interval;
} grpc_grpclb_serverlist; } grpc_grpclb_serverlist;
/** Create a request for a gRPC LB service under \a lb_service_name */ /** Create a request for a gRPC LB service under \a lb_service_name */

@ -61,11 +61,10 @@ const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3] = {
PB_LAST_FIELD PB_LAST_FIELD
}; };
const pb_field_t grpc_lb_v1_ServerList_fields[3] = { const pb_field_t grpc_lb_v1_ServerList_fields[2] = {
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v1_ServerList, servers, servers, &grpc_lb_v1_Server_fields), PB_FIELD(1, MESSAGE, REPEATED, CALLBACK, FIRST, grpc_lb_v1_ServerList,
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ServerList, expiration_interval, servers, &grpc_lb_v1_Duration_fields), servers, servers, &grpc_lb_v1_Server_fields),
PB_LAST_FIELD PB_LAST_FIELD};
};
const pb_field_t grpc_lb_v1_Server_fields[5] = { const pb_field_t grpc_lb_v1_Server_fields[5] = {
PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, grpc_lb_v1_Server, ip_address, ip_address, 0), PB_FIELD( 1, BYTES , OPTIONAL, STATIC , FIRST, grpc_lb_v1_Server, ip_address, ip_address, 0),
@ -85,7 +84,17 @@ const pb_field_t grpc_lb_v1_Server_fields[5] = {
* numbers or field sizes that are larger than what can fit in 8 or 16 bit * numbers or field sizes that are larger than what can fit in 8 or 16 bit
* field descriptors. * field descriptors.
*/ */
PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 65536 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v1_ServerList, servers) < 65536 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server) PB_STATIC_ASSERT(
(pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 &&
pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 &&
pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 65536 &&
pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 65536 &&
pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 &&
pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 &&
pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse,
client_stats_report_interval) < 65536 &&
pb_membersize(grpc_lb_v1_ServerList, servers) < 65536),
YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
#endif #endif
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
@ -96,7 +105,17 @@ PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request)
* numbers or field sizes that are larger than what can fit in the default * numbers or field sizes that are larger than what can fit in the default
* 8 bit descriptors. * 8 bit descriptors.
*/ */
PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 256 && pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v1_ServerList, servers) < 256 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server) PB_STATIC_ASSERT(
(pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 &&
pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 &&
pb_membersize(grpc_lb_v1_ClientStats, timestamp) < 256 &&
pb_membersize(grpc_lb_v1_ClientStats, calls_finished_with_drop) < 256 &&
pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 &&
pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 &&
pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse,
client_stats_report_interval) < 256 &&
pb_membersize(grpc_lb_v1_ServerList, servers) < 256),
YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_Timestamp_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStatsPerToken_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
#endif #endif

@ -14,6 +14,11 @@ extern "C" {
#endif #endif
/* Struct definitions */ /* Struct definitions */
typedef struct _grpc_lb_v1_ServerList {
pb_callback_t servers;
/* @@protoc_insertion_point(struct:grpc_lb_v1_ServerList) */
} grpc_lb_v1_ServerList;
typedef struct _grpc_lb_v1_ClientStatsPerToken { typedef struct _grpc_lb_v1_ClientStatsPerToken {
pb_callback_t load_balance_token; pb_callback_t load_balance_token;
bool has_num_calls; bool has_num_calls;
@ -79,13 +84,6 @@ typedef struct _grpc_lb_v1_InitialLoadBalanceResponse {
/* @@protoc_insertion_point(struct:grpc_lb_v1_InitialLoadBalanceResponse) */ /* @@protoc_insertion_point(struct:grpc_lb_v1_InitialLoadBalanceResponse) */
} grpc_lb_v1_InitialLoadBalanceResponse; } grpc_lb_v1_InitialLoadBalanceResponse;
typedef struct _grpc_lb_v1_ServerList {
pb_callback_t servers;
bool has_expiration_interval;
grpc_lb_v1_Duration expiration_interval;
/* @@protoc_insertion_point(struct:grpc_lb_v1_ServerList) */
} grpc_lb_v1_ServerList;
typedef struct _grpc_lb_v1_LoadBalanceRequest { typedef struct _grpc_lb_v1_LoadBalanceRequest {
bool has_initial_request; bool has_initial_request;
grpc_lb_v1_InitialLoadBalanceRequest initial_request; grpc_lb_v1_InitialLoadBalanceRequest initial_request;
@ -113,7 +111,10 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_init_default {false, grpc_lb_v1_Timestamp_init_default, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}} #define grpc_lb_v1_ClientStats_init_default {false, grpc_lb_v1_Timestamp_init_default, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}}
#define grpc_lb_v1_LoadBalanceResponse_init_default {false, grpc_lb_v1_InitialLoadBalanceResponse_init_default, false, grpc_lb_v1_ServerList_init_default} #define grpc_lb_v1_LoadBalanceResponse_init_default {false, grpc_lb_v1_InitialLoadBalanceResponse_init_default, false, grpc_lb_v1_ServerList_init_default}
#define grpc_lb_v1_InitialLoadBalanceResponse_init_default {false, "", false, grpc_lb_v1_Duration_init_default} #define grpc_lb_v1_InitialLoadBalanceResponse_init_default {false, "", false, grpc_lb_v1_Duration_init_default}
#define grpc_lb_v1_ServerList_init_default {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_default} #define grpc_lb_v1_ServerList_init_default \
{ \
{ {NULL}, NULL } \
}
#define grpc_lb_v1_Server_init_default {false, {0, {0}}, false, 0, false, "", false, 0} #define grpc_lb_v1_Server_init_default {false, {0, {0}}, false, 0, false, "", false, 0}
#define grpc_lb_v1_Duration_init_zero {false, 0, false, 0} #define grpc_lb_v1_Duration_init_zero {false, 0, false, 0}
#define grpc_lb_v1_Timestamp_init_zero {false, 0, false, 0} #define grpc_lb_v1_Timestamp_init_zero {false, 0, false, 0}
@ -123,10 +124,14 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_init_zero {false, grpc_lb_v1_Timestamp_init_zero, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}} #define grpc_lb_v1_ClientStats_init_zero {false, grpc_lb_v1_Timestamp_init_zero, false, 0, false, 0, false, 0, false, 0, {{NULL}, NULL}}
#define grpc_lb_v1_LoadBalanceResponse_init_zero {false, grpc_lb_v1_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v1_ServerList_init_zero} #define grpc_lb_v1_LoadBalanceResponse_init_zero {false, grpc_lb_v1_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v1_ServerList_init_zero}
#define grpc_lb_v1_InitialLoadBalanceResponse_init_zero {false, "", false, grpc_lb_v1_Duration_init_zero} #define grpc_lb_v1_InitialLoadBalanceResponse_init_zero {false, "", false, grpc_lb_v1_Duration_init_zero}
#define grpc_lb_v1_ServerList_init_zero {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_zero} #define grpc_lb_v1_ServerList_init_zero \
{ \
{ {NULL}, NULL } \
}
#define grpc_lb_v1_Server_init_zero {false, {0, {0}}, false, 0, false, "", false, 0} #define grpc_lb_v1_Server_init_zero {false, {0, {0}}, false, 0, false, "", false, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define grpc_lb_v1_ServerList_servers_tag 1
#define grpc_lb_v1_ClientStatsPerToken_load_balance_token_tag 1 #define grpc_lb_v1_ClientStatsPerToken_load_balance_token_tag 1
#define grpc_lb_v1_ClientStatsPerToken_num_calls_tag 2 #define grpc_lb_v1_ClientStatsPerToken_num_calls_tag 2
#define grpc_lb_v1_Duration_seconds_tag 1 #define grpc_lb_v1_Duration_seconds_tag 1
@ -146,8 +151,6 @@ typedef struct _grpc_lb_v1_LoadBalanceResponse {
#define grpc_lb_v1_ClientStats_calls_finished_with_drop_tag 8 #define grpc_lb_v1_ClientStats_calls_finished_with_drop_tag 8
#define grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate_tag 1 #define grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate_tag 1
#define grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval_tag 2 #define grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval_tag 2
#define grpc_lb_v1_ServerList_servers_tag 1
#define grpc_lb_v1_ServerList_expiration_interval_tag 3
#define grpc_lb_v1_LoadBalanceRequest_initial_request_tag 1 #define grpc_lb_v1_LoadBalanceRequest_initial_request_tag 1
#define grpc_lb_v1_LoadBalanceRequest_client_stats_tag 2 #define grpc_lb_v1_LoadBalanceRequest_client_stats_tag 2
#define grpc_lb_v1_LoadBalanceResponse_initial_response_tag 1 #define grpc_lb_v1_LoadBalanceResponse_initial_response_tag 1
@ -162,7 +165,7 @@ extern const pb_field_t grpc_lb_v1_ClientStatsPerToken_fields[3];
extern const pb_field_t grpc_lb_v1_ClientStats_fields[7]; extern const pb_field_t grpc_lb_v1_ClientStats_fields[7];
extern const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3]; extern const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3];
extern const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3]; extern const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3];
extern const pb_field_t grpc_lb_v1_ServerList_fields[3]; extern const pb_field_t grpc_lb_v1_ServerList_fields[2];
extern const pb_field_t grpc_lb_v1_Server_fields[5]; extern const pb_field_t grpc_lb_v1_Server_fields[5];
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */

@ -133,11 +133,8 @@ message ServerList {
// unless instructed otherwise via the client_config. // unless instructed otherwise via the client_config.
repeated Server servers = 1; repeated Server servers = 1;
// Indicates the amount of time that the client should consider this server // Was google.protobuf.Duration expiration_interval.
// list as valid. It may be considered stale after waiting this interval of reserved 3;
// time after receiving the list. If the interval is not positive, the
// client can assume the list is valid until the next list is received.
Duration expiration_interval = 3;
} }
// Contains server information. When the drop field is not true, use the other // Contains server information. When the drop field is not true, use the other

@ -98,9 +98,6 @@ TEST_F(GrpclbTest, ParseResponseServerList) {
server->set_port(54321); server->set_port(54321);
server->set_load_balance_token("load_balancing"); server->set_load_balance_token("load_balancing");
server->set_drop(true); server->set_drop(true);
auto* expiration_interval = serverlist->mutable_expiration_interval();
expiration_interval->set_seconds(888);
expiration_interval->set_nanos(999);
const grpc::string encoded_response = response.SerializeAsString(); const grpc::string encoded_response = response.SerializeAsString();
const grpc_slice encoded_slice = grpc_slice_from_copied_buffer( const grpc_slice encoded_slice = grpc_slice_from_copied_buffer(
@ -121,11 +118,6 @@ TEST_F(GrpclbTest, ParseResponseServerList) {
EXPECT_STREQ(c_serverlist->servers[1]->load_balance_token, "load_balancing"); EXPECT_STREQ(c_serverlist->servers[1]->load_balance_token, "load_balancing");
EXPECT_TRUE(c_serverlist->servers[1]->drop); EXPECT_TRUE(c_serverlist->servers[1]->drop);
EXPECT_TRUE(c_serverlist->expiration_interval.has_seconds);
EXPECT_EQ(c_serverlist->expiration_interval.seconds, 888);
EXPECT_TRUE(c_serverlist->expiration_interval.has_nanos);
EXPECT_EQ(c_serverlist->expiration_interval.nanos, 999);
grpc_slice_unref(encoded_slice); grpc_slice_unref(encoded_slice);
grpc_grpclb_destroy_serverlist(c_serverlist); grpc_grpclb_destroy_serverlist(c_serverlist);
} }

@ -113,9 +113,8 @@ typedef struct test_fixture {
static void* tag(intptr_t t) { return (void*)t; } static void* tag(intptr_t t) { return (void*)t; }
static grpc_slice build_response_payload_slice( static grpc_slice build_response_payload_slice(const char* host, int* ports,
const char* host, int* ports, size_t nports, size_t nports,
int64_t expiration_interval_secs, int32_t expiration_interval_nanos,
const char* token_prefix) { const char* token_prefix) {
// server_list { // server_list {
// servers { // servers {
@ -128,15 +127,6 @@ static grpc_slice build_response_payload_slice(
grpc::lb::v1::LoadBalanceResponse response; grpc::lb::v1::LoadBalanceResponse response;
auto* serverlist = response.mutable_server_list(); auto* serverlist = response.mutable_server_list();
if (expiration_interval_secs > 0 || expiration_interval_nanos > 0) {
auto* expiration_interval = serverlist->mutable_expiration_interval();
if (expiration_interval_secs > 0) {
expiration_interval->set_seconds(expiration_interval_secs);
}
if (expiration_interval_nanos > 0) {
expiration_interval->set_nanos(expiration_interval_nanos);
}
}
for (size_t i = 0; i < nports; i++) { for (size_t i = 0; i < nports; i++) {
auto* server = serverlist->add_servers(); auto* server = serverlist->add_servers();
// TODO(dgq): test ipv6 // TODO(dgq): test ipv6
@ -248,13 +238,13 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
if (i == 0) { if (i == 0) {
// First half of the ports. // First half of the ports.
response_payload_slice = build_response_payload_slice( response_payload_slice = build_response_payload_slice(
"127.0.0.1", ports, nports / 2, -1, -1, sf->lb_token_prefix); "127.0.0.1", ports, nports / 2, sf->lb_token_prefix);
} else { } else {
// Second half of the ports. // Second half of the ports.
sleep_ms(update_delay_ms); sleep_ms(update_delay_ms);
response_payload_slice = build_response_payload_slice( response_payload_slice = build_response_payload_slice(
"127.0.0.1", ports + (nports / 2), (nports + 1) / 2 /* ceil */, -1, "127.0.0.1", ports + (nports / 2), (nports + 1) / 2 /* ceil */,
-1, "" /* this half doesn't get to receive an LB token */); "" /* this half doesn't get to receive an LB token */);
} }
response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);

Loading…
Cancel
Save