Exit if unable to restart watches

FIXME: It's probably not OK for the client to exit in this case
This commit is contained in:
Vitaliy Filippov
2021-11-28 01:43:31 +03:00
parent a8f5c71ae8
commit 7a0b5212fe
2 changed files with 33 additions and 6 deletions
+14
View File
@@ -209,6 +209,20 @@ void etcd_state_client_t::start_etcd_watcher()
{
etcd_watches_initialised++;
}
if (data["result"]["canceled"].bool_value())
{
// etcd watch canceled, maybe because the revision was compacted
if (data["result"]["compact_revision"].uint64_value())
{
// we may miss events if we proceed
// FIXME: reload state and continue when used inside cluster_client
fprintf(stderr, "Revisions before %lu were compacted by etcd, exiting\n",
data["result"]["compact_revision"].uint64_value());
exit(1);
}
fprintf(stderr, "Watch canceled by etcd, reason: %s, exiting\n", data["result"]["cancel_reason"].string_value().c_str());
exit(1);
}
if (etcd_watches_initialised == 4)
{
etcd_watch_revision = data["result"]["header"]["revision"].uint64_value();