ircd: Remove write_avoid mode replaced by maintenance mode.

This commit is contained in:
Jason Volk 2023-03-19 12:35:39 -07:00
parent 96b1d68933
commit 19462b5fae
9 changed files with 19 additions and 50 deletions

View File

@ -38,7 +38,6 @@ bool yes6;
bool norun; bool norun;
bool nomain; bool nomain;
bool read_only; bool read_only;
bool write_avoid;
bool slave; bool slave;
std::array<bool, 6> smoketest; std::array<bool, 6> smoketest;
bool megatest; bool megatest;
@ -76,7 +75,6 @@ lgetopt opts[]
{ "norun", &norun, lgetopt::BOOL, "[debug] Initialize but never run the event loop" }, { "norun", &norun, lgetopt::BOOL, "[debug] Initialize but never run the event loop" },
{ "nomain", &nomain, lgetopt::BOOL, "[debug] Initialize and run without entering ircd::main()" }, { "nomain", &nomain, lgetopt::BOOL, "[debug] Initialize and run without entering ircd::main()" },
{ "ro", &read_only, lgetopt::BOOL, "Read-only mode. No writes to database allowed" }, { "ro", &read_only, lgetopt::BOOL, "Read-only mode. No writes to database allowed" },
{ "wa", &write_avoid, lgetopt::BOOL, "Like read-only mode, but writes permitted if triggered" },
{ "slave", &slave, lgetopt::BOOL, "Like read-only mode; allows multiple instances of server" }, { "slave", &slave, lgetopt::BOOL, "Like read-only mode; allows multiple instances of server" },
{ "smoketest", &smoketest[0], lgetopt::BOOL, "Starts and stops the daemon to return success" }, { "smoketest", &smoketest[0], lgetopt::BOOL, "Starts and stops the daemon to return success" },
{ "megatest", &megatest, lgetopt::BOOL, "Trap execution every millionth tick for diagnostic and statistics." }, { "megatest", &megatest, lgetopt::BOOL, "Trap execution every millionth tick for diagnostic and statistics." },
@ -558,10 +556,11 @@ applyargs()
ircd::db::auto_deletion.set("false"); ircd::db::auto_deletion.set("false");
} }
if(single && !bootstrap) if(single)
{ {
ircd::write_avoid.set("true"); ircd::maintenance.set("true");
cmdline = !debugmode; cmdline = !debugmode;
nobackfill = true;
} }
if(bootstrap) if(bootstrap)
@ -577,16 +576,7 @@ applyargs()
} }
if(read_only) if(read_only)
{
ircd::read_only.set("true"); ircd::read_only.set("true");
write_avoid = true; // read_only implies write_avoid.
}
if(write_avoid)
{
ircd::write_avoid.set("true");
nobackfill = true;
}
if(debugmode) if(debugmode)
ircd::debugmode.set("true"); ircd::debugmode.set("true");

View File

@ -131,7 +131,6 @@ namespace ircd
extern conf::item<bool> debugmode; extern conf::item<bool> debugmode;
extern conf::item<bool> maintenance; extern conf::item<bool> maintenance;
extern conf::item<bool> soft_assert; extern conf::item<bool> soft_assert;
extern conf::item<bool> write_avoid; // implies maintenance
extern conf::item<bool> read_only; // implies write_avoid extern conf::item<bool> read_only; // implies write_avoid
extern conf::item<bool> defaults; extern conf::item<bool> defaults;
} }

View File

@ -179,10 +179,10 @@ try
fs::base::db fs::base::db
}; };
if(!fs::is_dir(dbdir) && (ircd::read_only || ircd::write_avoid)) if(!fs::is_dir(dbdir) && (ircd::read_only || ircd::maintenance))
log::warning log::warning
{ {
log, "Not creating database directory `%s' in read-only/write-avoid mode.", dbdir log, "Not creating database directory `%s' in read-only/maintenance mode.", dbdir
}; };
else if(fs::mkdir(dbdir)) else if(fs::mkdir(dbdir))
log::notice log::notice

View File

@ -1297,7 +1297,7 @@ try
// If the directory does not exist, though rocksdb will create it, we can // If the directory does not exist, though rocksdb will create it, we can
// avoid scaring the user with an error log message if we just do that.. // avoid scaring the user with an error log message if we just do that..
if(opts->create_if_missing && !fs::is_dir(path) && !ircd::write_avoid) if(opts->create_if_missing && !fs::is_dir(path) && !ircd::maintenance && !ircd::read_only)
fs::mkdir(path); fs::mkdir(path);
// Announce attempt before usual point where exceptions are thrown // Announce attempt before usual point where exceptions are thrown

View File

@ -107,26 +107,6 @@ ircd::maintenance
} }
}; };
/// Coarse mode indicator for degraded operation known as "write-avoid" which
/// is similar to read_only but not hard-enforced. Writes may still occur,
/// such as those manually triggered by an admin. All subsystems and background
/// tasks otherwise depart from normal operation to avoid writes.
decltype(ircd::write_avoid)
ircd::write_avoid
{
{
{ "name", "ircd.write_avoid" },
{ "default", false },
{ "persist", false },
},
[](conf::item<void> &)
{
if(!write_avoid)
return;
maintenance.set("true");
}
};
/// Coarse mode declaration for read-only behavior. All subsystems and feature /// Coarse mode declaration for read-only behavior. All subsystems and feature
/// modules respect this indicator by preventing any writes and persistence /// modules respect this indicator by preventing any writes and persistence
@ -145,7 +125,7 @@ ircd::read_only
if(!read_only) if(!read_only)
return; return;
write_avoid.set("true"); maintenance.set("true");
} }
}; };

View File

@ -138,7 +138,7 @@ ircd::log::init()
console_disable(level::DWARNING); console_disable(level::DWARNING);
} }
if(!ircd::write_avoid) if(!ircd::read_only && !ircd::maintenance)
{ {
mkdir(); mkdir();
open(); open();

View File

@ -354,7 +354,7 @@ ircd::m::app::handle_stdout()
const auto message_id const auto message_id
{ {
!ircd::write_avoid? !ircd::read_only && !ircd::maintenance?
m::msghtml(room_id, user_id, content, string_view{alt}, "m.notice"): m::msghtml(room_id, user_id, content, string_view{alt}, "m.notice"):
m::event::id::buf{} m::event::id::buf{}
}; };

View File

@ -283,17 +283,17 @@ try
if(ircd::mods::autoload) if(ircd::mods::autoload)
mods::imports.emplace("net_dns_cache"s, "net_dns_cache"); mods::imports.emplace("net_dns_cache"s, "net_dns_cache");
if(!ircd::write_avoid) if(!ircd::read_only && !ircd::maintenance)
if(key && !key->verify_keys.empty()) if(key && !key->verify_keys.empty())
m::keys::cache::set(key->verify_keys); m::keys::cache::set(key->verify_keys);
if(opts->autoapps) if(opts->autoapps)
m::app::init(); m::app::init();
if(!ircd::maintenance) if(!ircd::read_only && !ircd::maintenance)
signon(*this); signon(*this);
if(!ircd::maintenance && opts->backfill) if(!ircd::read_only && !ircd::maintenance && opts->backfill)
m::init::backfill::init(); m::init::backfill::init();
} }
catch(const std::exception &e) catch(const std::exception &e)
@ -321,7 +321,7 @@ noexcept try
server::wait(); server::wait();
m::sync::pool.join(); m::sync::pool.join();
if(!ircd::maintenance && _vm) if(!ircd::read_only && !ircd::maintenance && _vm)
signoff(*this); signoff(*this);
///TODO: XXX primary ///TODO: XXX primary
@ -394,7 +394,7 @@ ircd::m::homeserver::key::key(const struct opts &opts)
}) })
}; };
if(!fs::exists(sk_file) && !ircd::write_avoid) if(!fs::exists(sk_file) && !ircd::read_only && !ircd::maintenance)
log::notice log::notice
{ {
m::log, "Creating ed25519 secret key @ `%s'", sk_file m::log, "Creating ed25519 secret key @ `%s'", sk_file
@ -404,7 +404,7 @@ ircd::m::homeserver::key::key(const struct opts &opts)
}()} }()}
,secret_key ,secret_key
{ {
secret_key_path, &public_key, !ircd::write_avoid secret_key_path, &public_key, !ircd::read_only && !ircd::maintenance
} }
,public_key_b64 ,public_key_b64
{ {

View File

@ -52,8 +52,8 @@ IRCD_MODULE
decltype(ircd::m::bridge::enable) decltype(ircd::m::bridge::enable)
ircd::m::bridge::enable ircd::m::bridge::enable
{ {
{ "name", "ircd.m.bridge.enable" }, { "name", "ircd.m.bridge.enable" },
{ "default", true }, { "default", true && !ircd::maintenance },
}; };
decltype(ircd::m::bridge::backoff) decltype(ircd::m::bridge::backoff)
@ -139,7 +139,7 @@ ircd::m::bridge::init()
string_view{event.event_id}, string_view{event.event_id},
}; };
if(!enable) if(!enable || ircd::read_only)
return true; return true;
start(event, config); start(event, config);
@ -169,7 +169,7 @@ ircd::m::bridge::handle_config(const m::event &event,
vm::eval &eval) vm::eval &eval)
try try
{ {
if(!enable) if(!enable || ircd::read_only)
return; return;
const config config const config config