Allow to specify etcd URLs for OSDs with http://, do not die with a strange error if -etcd option is missing for fio
parent
88671cf745
commit
9ac7e75178
|
@ -56,6 +56,23 @@ void etcd_state_client_t::etcd_call(std::string api, json11::Json payload, int t
|
||||||
http_request_json(tfd, etcd_address, req, timeout, callback);
|
http_request_json(tfd, etcd_address, req, timeout, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void etcd_state_client_t::add_etcd_url(std::string addr)
|
||||||
|
{
|
||||||
|
if (addr.length() > 0)
|
||||||
|
{
|
||||||
|
if (strtolower(addr.substr(0, 7)) == "http://")
|
||||||
|
addr = addr.substr(7);
|
||||||
|
else if (strtolower(addr.substr(0, 8)) == "https://")
|
||||||
|
{
|
||||||
|
printf("HTTPS is unsupported for etcd. Either use plain HTTP or setup a local proxy for etcd interaction\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (addr.find('/') < 0)
|
||||||
|
addr += "/v3";
|
||||||
|
this->etcd_addresses.push_back(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void etcd_state_client_t::parse_config(json11::Json & config)
|
void etcd_state_client_t::parse_config(json11::Json & config)
|
||||||
{
|
{
|
||||||
this->etcd_addresses.clear();
|
this->etcd_addresses.clear();
|
||||||
|
@ -65,13 +82,7 @@ void etcd_state_client_t::parse_config(json11::Json & config)
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int pos = ea.find(',');
|
int pos = ea.find(',');
|
||||||
std::string addr = pos >= 0 ? ea.substr(0, pos) : ea;
|
add_etcd_url(pos >= 0 ? ea.substr(0, pos) : ea);
|
||||||
if (addr.length() > 0)
|
|
||||||
{
|
|
||||||
if (addr.find('/') < 0)
|
|
||||||
addr += "/v3";
|
|
||||||
this->etcd_addresses.push_back(addr);
|
|
||||||
}
|
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
ea = ea.substr(pos+1);
|
ea = ea.substr(pos+1);
|
||||||
else
|
else
|
||||||
|
@ -82,13 +93,7 @@ void etcd_state_client_t::parse_config(json11::Json & config)
|
||||||
{
|
{
|
||||||
for (auto & ea: config["etcd_address"].array_items())
|
for (auto & ea: config["etcd_address"].array_items())
|
||||||
{
|
{
|
||||||
std::string addr = ea.string_value();
|
add_etcd_url(ea.string_value());
|
||||||
if (addr != "")
|
|
||||||
{
|
|
||||||
if (addr.find('/') < 0)
|
|
||||||
addr += "/v3";
|
|
||||||
this->etcd_addresses.push_back(addr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->etcd_prefix = config["etcd_prefix"].string_value();
|
this->etcd_prefix = config["etcd_prefix"].string_value();
|
||||||
|
|
|
@ -54,6 +54,9 @@ struct pool_config_t
|
||||||
|
|
||||||
struct etcd_state_client_t
|
struct etcd_state_client_t
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
void add_etcd_url(std::string);
|
||||||
|
public:
|
||||||
std::vector<std::string> etcd_addresses;
|
std::vector<std::string> etcd_addresses;
|
||||||
std::string etcd_prefix;
|
std::string etcd_prefix;
|
||||||
int log_level = 0;
|
int log_level = 0;
|
||||||
|
|
|
@ -117,8 +117,15 @@ static struct fio_option options[] = {
|
||||||
|
|
||||||
static int sec_setup(struct thread_data *td)
|
static int sec_setup(struct thread_data *td)
|
||||||
{
|
{
|
||||||
|
sec_options *o = (sec_options*)td->eo;
|
||||||
sec_data *bsd;
|
sec_data *bsd;
|
||||||
|
|
||||||
|
if (!o->etcd_host)
|
||||||
|
{
|
||||||
|
td_verror(td, EINVAL, "etcd address is missing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
bsd = new sec_data;
|
bsd = new sec_data;
|
||||||
if (!bsd)
|
if (!bsd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define READ_BUFFER_SIZE 9000
|
#define READ_BUFFER_SIZE 9000
|
||||||
|
|
||||||
static int extract_port(std::string & host);
|
static int extract_port(std::string & host);
|
||||||
static std::string strtolower(const std::string & in);
|
|
||||||
static std::string trim(const std::string & in);
|
static std::string trim(const std::string & in);
|
||||||
static std::string ws_format_frame(int type, uint64_t size);
|
static std::string ws_format_frame(int type, uint64_t size);
|
||||||
static bool ws_parse_frame(std::string & buf, int & type, std::string & res);
|
static bool ws_parse_frame(std::string & buf, int & type, std::string & res);
|
||||||
|
@ -673,7 +672,7 @@ static int extract_port(std::string & host)
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string strtolower(const std::string & in)
|
std::string strtolower(const std::string & in)
|
||||||
{
|
{
|
||||||
std::string s = in;
|
std::string s = in;
|
||||||
for (int i = 0; i < s.length(); i++)
|
for (int i = 0; i < s.length(); i++)
|
||||||
|
|
|
@ -49,6 +49,8 @@ std::vector<std::string> getifaddr_list(bool include_v6 = false);
|
||||||
|
|
||||||
uint64_t stoull_full(const std::string & str, int base = 10);
|
uint64_t stoull_full(const std::string & str, int base = 10);
|
||||||
|
|
||||||
|
std::string strtolower(const std::string & in);
|
||||||
|
|
||||||
void http_request(timerfd_manager_t *tfd, const std::string & host, const std::string & request,
|
void http_request(timerfd_manager_t *tfd, const std::string & host, const std::string & request,
|
||||||
const http_options_t & options, std::function<void(const http_response_t *response)> callback);
|
const http_options_t & options, std::function<void(const http_response_t *response)> callback);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue