Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc75450f6d |
@@ -34,26 +34,22 @@ struct alloc_osd_t
|
||||
json11::Json::object {
|
||||
{ "target", "VERSION" },
|
||||
{ "version", 0 },
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
) },
|
||||
{ "key", "/osd/stats/"+std::to_string(new_id) }
|
||||
},
|
||||
} },
|
||||
{ "success", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(
|
||||
parent->cli->st_cli.etcd_prefix+"/osd/stats/"+std::to_string(new_id)
|
||||
) },
|
||||
{ "value", base64_encode("{}") },
|
||||
{ "key", "/osd/stats/"+std::to_string(new_id) }
|
||||
{ "value", "{}" },
|
||||
} },
|
||||
},
|
||||
} },
|
||||
{ "failure", json11::Json::array {
|
||||
json11::Json::object {
|
||||
{ "request_range", json11::Json::object {
|
||||
{ "key", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats/") },
|
||||
{ "range_end", base64_encode(parent->cli->st_cli.etcd_prefix+"/osd/stats0") },
|
||||
{ "key", "/osd/stats/" },
|
||||
{ "range_end", "/osd/stats0" },
|
||||
{ "keys_only", true },
|
||||
} },
|
||||
},
|
||||
|
||||
@@ -54,8 +54,55 @@ etcd_kv_t etcd_state_client_t::parse_etcd_kv(const json11::Json & kv_json)
|
||||
return kv;
|
||||
}
|
||||
|
||||
json11::Json etcd_state_client_t::etcd_encode_actions(const json11::Json & items)
|
||||
{
|
||||
json11::Json::array encoded;
|
||||
for (auto & v: items.array_items())
|
||||
{
|
||||
json11::Json::object act;
|
||||
for (auto & kv: v.object_items())
|
||||
{
|
||||
if (kv.first == "key" || kv.first == "range_end")
|
||||
act[kv.first] = base64_encode(etcd_prefix+kv.second.string_value());
|
||||
else if (kv.first == "value")
|
||||
act[kv.first] = base64_encode(kv.second.is_string() ? kv.second.string_value() : kv.second.dump());
|
||||
else
|
||||
act[kv.first] = kv.second;
|
||||
}
|
||||
encoded.push_back(act);
|
||||
}
|
||||
return encoded;
|
||||
}
|
||||
|
||||
void etcd_state_client_t::etcd_txn(json11::Json txn, int timeout, int retries, int interval, std::function<void(std::string, json11::Json)> callback)
|
||||
{
|
||||
// FIXME: json11 is immutable which is very inconvenient for such cases
|
||||
json11::Json::object encoded;
|
||||
if (txn["compare"].is_array())
|
||||
{
|
||||
json11::Json::array compare;
|
||||
for (auto & v: txn["compare"].array_items())
|
||||
{
|
||||
json11::Json::object cmp;
|
||||
for (auto & kv: v.object_items())
|
||||
{
|
||||
if (kv.first == "key")
|
||||
cmp[kv.first] = base64_encode(etcd_prefix+kv.second.string_value());
|
||||
else
|
||||
cmp[kv.first] = kv.second;
|
||||
}
|
||||
compare.push_back(cmp);
|
||||
}
|
||||
encoded["compare"] = compare;
|
||||
}
|
||||
if (txn["failure"].is_array())
|
||||
{
|
||||
encoded["failure"] = etcd_encode_actions(txn["failure"]);
|
||||
}
|
||||
if (txn["success"].is_array())
|
||||
{
|
||||
encoded["success"] = etcd_encode_actions(txn["success"]);
|
||||
}
|
||||
etcd_call("/kv/txn", txn, timeout, retries, interval, callback);
|
||||
}
|
||||
|
||||
@@ -867,7 +914,6 @@ void etcd_state_client_t::parse_state(const etcd_kv_t & kv)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "RECEIVED PG %u/%u HISTORY: %s\n", pool_id, pg_num, value.dump().c_str());
|
||||
auto & pg_cfg = this->pool_config[pool_id].pg_config[pg_num];
|
||||
pg_cfg.target_history.clear();
|
||||
pg_cfg.all_peers.clear();
|
||||
|
||||
@@ -93,6 +93,7 @@ protected:
|
||||
bool rand_initialized = false;
|
||||
void add_etcd_url(std::string);
|
||||
void pick_next_etcd();
|
||||
json11::Json etcd_encode_actions(const json11::Json & items);
|
||||
public:
|
||||
int etcd_keepalive_timeout = 30;
|
||||
int etcd_ws_keepalive_interval = 30;
|
||||
|
||||
@@ -694,20 +694,6 @@ void osd_t::apply_pg_config()
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(
|
||||
"Repeer %u/%u because of history: %s vs %s\n",
|
||||
pool_id, pg_num,
|
||||
json11::Json(json11::Json::object {
|
||||
{ "target_set", pg_cfg.target_set },
|
||||
{ "osd_sets", pg_cfg.target_history },
|
||||
{ "all_peers", vec_all_peers },
|
||||
}).dump().c_str(),
|
||||
json11::Json(json11::Json::object {
|
||||
{ "target_set", pg_it->second.target_set },
|
||||
{ "osd_sets", pg_it->second.target_history },
|
||||
{ "all_peers", pg_it->second.all_peers },
|
||||
}).dump().c_str()
|
||||
);
|
||||
// Stop PG, reapply change after stopping
|
||||
stop_pg(pg_it->second);
|
||||
all_applied = false;
|
||||
@@ -885,7 +871,6 @@ void osd_t::report_pg_states()
|
||||
{ "all_peers", pg.all_peers },
|
||||
{ "osd_sets", pg.target_history },
|
||||
};
|
||||
printf("PG %u/%u HISTORY -> %s\n", pg.pool_id, pg.pg_num, json11::Json(history_value).dump().c_str());
|
||||
checks.push_back(json11::Json::object {
|
||||
{ "target", "MOD" },
|
||||
{ "key", history_key },
|
||||
|
||||
Reference in New Issue
Block a user