Skip to content

Commit

Permalink
s3_auth does not retry after a file read error (#11864)
Browse files Browse the repository at this point in the history
* Update origin_server_auth.cc

* Add cmath include

* Update documentation
  • Loading branch information
jasmine-nahrain authored Nov 18, 2024
1 parent a860656 commit 4b9d938
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions doc/admin-guide/plugins/origin_server_auth.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,10 @@ The ``gcp_auth.config`` config file could look like this::

session_token=<access_id>
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.
18 changes: 17 additions & 1 deletion plugins/origin_server_auth/origin_server_auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -568,6 +580,7 @@ class S3Config
long _expiration = 0;
char *_conf_fname = nullptr;
int _conf_reload_count = 0;
int _invalid_file_count = 0;
};

bool
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4b9d938

Please sign in to comment.