diff --git a/doc/admin-guide/plugins/origin_server_auth.en.rst b/doc/admin-guide/plugins/origin_server_auth.en.rst index 959f463786a..0278c625e89 100644 --- a/doc/admin-guide/plugins/origin_server_auth.en.rst +++ b/doc/admin-guide/plugins/origin_server_auth.en.rst @@ -198,3 +198,10 @@ The ``gcp_auth.config`` config file could look like this:: session_token= version=gcpv1 + +Retrying config loading +======================= + +If the specified configuration file cannot be opened or is missing required options, ATS will attempt to reload the file repeatedly with exponential backoff. + +If the configuration file includes an `expiration` parameter and the file has exceeded its expiration time, ATS will retry loading the file every minute for a duration of 10 minutes. After 10 minutes, the file must be manually reloaded. diff --git a/plugins/origin_server_auth/origin_server_auth.cc b/plugins/origin_server_auth/origin_server_auth.cc index 55350b082c5..ec9b28cb422 100644 --- a/plugins/origin_server_auth/origin_server_auth.cc +++ b/plugins/origin_server_auth/origin_server_auth.cc @@ -420,6 +420,12 @@ class S3Config return _conf_reload_count++; } + int + incr_invalid_file_count() + { + return _invalid_file_count++; + } + // Setters void set_secret(const char *s) @@ -510,6 +516,12 @@ class S3Config _conf_reload_count = 0; } + void + reset_invalid_file_count() + { + _invalid_file_count = 0; + } + // Parse configs from an external file bool parse_config(const std::string &filename); @@ -568,6 +580,7 @@ class S3Config long _expiration = 0; char *_conf_fname = nullptr; int _conf_reload_count = 0; + int _invalid_file_count = 0; }; bool @@ -1087,9 +1100,12 @@ config_reloader(TSCont cont, TSEvent /* event ATS_UNUSED */, void *edata) S3Config *file_config = gConfCache.get(s3->conf_fname()); if (!file_config || !file_config->valid()) { - TSError("[%s] invalid configuration. Check mandatory fields.", PLUGIN_NAME); + TSError("[%s] invalid configuration. Check mandatory fields. Scheduling reload", PLUGIN_NAME); + long delay = 1 << s3->incr_invalid_file_count(); + s3->schedule_conf_reload(delay); return TS_ERROR; } + s3->reset_invalid_file_count(); { std::unique_lock lock(s3->reload_mutex);