Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions doc/admin-guide/files/records.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ Prefix Description Equivalent in Bytes
``T`` Terabytes 1,099,511,627,776 bytes (1024\ :sup:`4`)
====== ============ ===========================================================

.. important::

Unless :ts:cv:`proxy.config.disable_configuration_modification` is enabled,
|TS| writes configurations back to disk periodically. When doing so, the
unit prefixes are not preserved.

Floating point variables (``FLOAT``) must be expressed as a regular decimal
number. Unit prefixes are not supported, nor are alternate notations (scientific,
exponent, etc.).
Expand Down Expand Up @@ -540,14 +534,6 @@ Local Manager
This setting is not reloadable, since it is must be applied when
program:`traffic_manager` initializes.

.. ts:cv:: CONFIG proxy.config.disable_configuration_modification INT 0
:reloadable:

This setting prevents |TS| from rewriting the :file:`records.config`
configuration file. Dynamic configuration changes can still be made using
:program:`traffic_ctl config set`, but these changes will not be persisted
on service restarts or when :option:`traffic_ctl config reload` is run.

Alarm Configuration
===================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,6 @@ msgstr ""
msgid "1,099,511,627,776 bytes (1024\\ :sup:`4`)"
msgstr ""

#: ../../../admin-guide/files/records.config.en.rst:91
msgid ""
"Unless :ts:cv:`proxy.config.disable_configuration_modification` is enabled, "
"|TS| writes configurations back to disk periodically. When doing so, the "
"unit prefixes are not preserved."
msgstr ""

#: ../../../admin-guide/files/records.config.en.rst:95
msgid ""
"Floating point variables (``FLOAT``) must be expressed as a regular decimal "
Expand Down
212 changes: 0 additions & 212 deletions lib/records/P_RecCore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,142 +650,6 @@ RecReadConfigFile(bool inc_version)
return REC_ERR_OKAY;
}

//-------------------------------------------------------------------------
// RecSyncConfigFile
//-------------------------------------------------------------------------
RecErrT
RecSyncConfigToTB(TextBuffer *tb, bool *inc_version)
{
RecErrT err = REC_ERR_FAIL;

if (inc_version != nullptr) {
*inc_version = false;
}

/*
* g_mode_type should be initialized by
* RecLocalInit() or RecProcessInit() earlier.
*/
ink_assert(g_mode_type != RECM_NULL);

if (g_mode_type == RECM_SERVER || g_mode_type == RECM_STAND_ALONE) {
RecRecord *r;
int i, num_records;
RecConfigFileEntry *cfe;
bool sync_to_disk;

ink_mutex_acquire(&g_rec_config_lock);

num_records = g_num_records;
sync_to_disk = false;
for (i = 0; i < num_records; i++) {
r = &(g_records[i]);
rec_mutex_acquire(&(r->lock));
if (REC_TYPE_IS_CONFIG(r->rec_type)) {
if (r->sync_required & REC_DISK_SYNC_REQUIRED) {
if (g_rec_config_contents_ht.find(r->name) == g_rec_config_contents_ht.end()) {
cfe = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry));
cfe->entry_type = RECE_RECORD;
cfe->entry = ats_strdup(r->name);
enqueue(g_rec_config_contents_llq, (void *)cfe);
g_rec_config_contents_ht.emplace(r->name);
}
r->sync_required = r->sync_required & ~REC_DISK_SYNC_REQUIRED;
sync_to_disk = true;
if (r->sync_required & REC_INC_CONFIG_VERSION) {
r->sync_required = r->sync_required & ~REC_INC_CONFIG_VERSION;
if (r->rec_type != RECT_LOCAL && inc_version != nullptr) {
*inc_version = true;
}
}
}
}
rec_mutex_release(&(r->lock));
}

if (sync_to_disk) {
char b[1024];

// okay, we're going to write into our TextBuffer
err = REC_ERR_OKAY;
tb->reUse();

ink_rwlock_rdlock(&g_records_rwlock);

LLQrec *llq_rec = g_rec_config_contents_llq->head;
while (llq_rec != nullptr) {
cfe = (RecConfigFileEntry *)llq_rec->data;
if (cfe->entry_type == RECE_COMMENT) {
tb->copyFrom(cfe->entry, strlen(cfe->entry));
tb->copyFrom("\n", 1);
} else {
if (auto it = g_records_ht.find(cfe->entry); it != g_records_ht.end()) {
r = it->second;
rec_mutex_acquire(&(r->lock));
// rec_type
switch (r->rec_type) {
case RECT_CONFIG:
tb->copyFrom("CONFIG ", 7);
break;
case RECT_PROCESS:
tb->copyFrom("PROCESS ", 8);
break;
case RECT_NODE:
tb->copyFrom("NODE ", 5);
break;
case RECT_LOCAL:
tb->copyFrom("LOCAL ", 6);
break;
default:
ink_assert(!"Unexpected RecT type");
break;
}
// name
tb->copyFrom(cfe->entry, strlen(cfe->entry));
tb->copyFrom(" ", 1);
// data_type and value
switch (r->data_type) {
case RECD_INT:
tb->copyFrom("INT ", 4);
snprintf(b, 1023, "%" PRId64 "", r->data.rec_int);
tb->copyFrom(b, strlen(b));
break;
case RECD_FLOAT:
tb->copyFrom("FLOAT ", 6);
snprintf(b, 1023, "%f", r->data.rec_float);
tb->copyFrom(b, strlen(b));
break;
case RECD_STRING:
tb->copyFrom("STRING ", 7);
if (r->data.rec_string) {
tb->copyFrom(r->data.rec_string, strlen(r->data.rec_string));
} else {
tb->copyFrom("NULL", strlen("NULL"));
}
break;
case RECD_COUNTER:
tb->copyFrom("COUNTER ", 8);
snprintf(b, 1023, "%" PRId64 "", r->data.rec_counter);
tb->copyFrom(b, strlen(b));
break;
default:
ink_assert(!"Unexpected RecD type");
break;
}
tb->copyFrom("\n", 1);
rec_mutex_release(&(r->lock));
}
}
llq_rec = llq_rec->next;
}
ink_rwlock_unlock(&g_records_rwlock);
}
ink_mutex_release(&g_rec_config_lock);
}

return err;
}

//-------------------------------------------------------------------------
// RecExecConfigUpdateCbs
//-------------------------------------------------------------------------
Expand Down Expand Up @@ -953,79 +817,3 @@ RecSetSyncRequired(char *name, bool lock)

return err;
}

RecErrT
RecWriteConfigFile(TextBuffer *tb)
{
#define TMP_FILENAME_EXT_STR ".tmp"
#define TMP_FILENAME_EXT_LEN (sizeof(TMP_FILENAME_EXT_STR) - 1)

int nbytes;
int filename_len;
int tmp_filename_len;
RecErrT result;
char buff[1024];
char *tmp_filename;

filename_len = strlen(g_rec_config_fpath);
tmp_filename_len = filename_len + TMP_FILENAME_EXT_LEN;
if (tmp_filename_len < (int)sizeof(buff)) {
tmp_filename = buff;
} else {
tmp_filename = (char *)ats_malloc(tmp_filename_len + 1);
}
sprintf(tmp_filename, "%s%s", g_rec_config_fpath, TMP_FILENAME_EXT_STR);

RecDebug(DL_Note, "Writing '%s'", g_rec_config_fpath);

RecHandle h_file = RecFileOpenW(tmp_filename);
do {
if (h_file == REC_HANDLE_INVALID) {
RecLog(DL_Warning, "open file: %s to write fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno));
result = REC_ERR_FAIL;
break;
}

if (RecFileWrite(h_file, tb->bufPtr(), tb->spaceUsed(), &nbytes) != REC_ERR_OKAY) {
RecLog(DL_Warning, "write to file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno));
result = REC_ERR_FAIL;
break;
}

if (nbytes != (int)tb->spaceUsed()) {
RecLog(DL_Warning, "write to file: %s fail, disk maybe full", tmp_filename);
result = REC_ERR_FAIL;
break;
}

if (RecFileSync(h_file) != REC_ERR_OKAY) {
RecLog(DL_Warning, "fsync file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno));
result = REC_ERR_FAIL;
break;
}
if (RecFileClose(h_file) != REC_ERR_OKAY) {
RecLog(DL_Warning, "close file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno));
result = REC_ERR_FAIL;
break;
}
h_file = REC_HANDLE_INVALID;

if (rename(tmp_filename, g_rec_config_fpath) != 0) {
RecLog(DL_Warning, "rename file %s to %s fail, errno: %d, error info: %s", tmp_filename, g_rec_config_fpath, errno,
strerror(errno));
result = REC_ERR_FAIL;
break;
}

result = REC_ERR_OKAY;
} while (false);

if (h_file != REC_HANDLE_INVALID) {
RecFileClose(h_file);
}
if (tmp_filename != buff) {
ats_free(tmp_filename);
}

return result;
}
3 changes: 0 additions & 3 deletions lib/records/P_RecCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ RecErrT RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data
//-------------------------------------------------------------------------
// Read/Sync to Disk
//-------------------------------------------------------------------------

RecErrT RecReadStatsFile();
RecErrT RecSyncStatsFile();
RecErrT RecReadConfigFile(bool inc_version);
RecErrT RecWriteConfigFile(TextBuffer *tb);
RecErrT RecSyncConfigToTB(TextBuffer *tb, bool *inc_version = nullptr);

//-------------------------------------------------------------------------
// Misc
Expand Down
33 changes: 1 addition & 32 deletions lib/records/RecLocal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,45 +61,14 @@ i_am_the_record_owner(RecT rec_type)
static void *
sync_thr(void *data)
{
TextBuffer *tb = new TextBuffer(65536);
FileManager *configFiles = (FileManager *)data;

while (true) {
bool inc_version;
RecBool disabled = false;
RecBool check = true;

RecGetRecordBool("proxy.config.disable_configuration_modification", &disabled);
if (disabled) {
RecDebug(DL_Debug, "configuration modification is disabled, skipping it");
}
RecBool check = true;

send_push_message();
RecSyncStatsFile();

if (!disabled && RecSyncConfigToTB(tb, &inc_version) == REC_ERR_OKAY) {
bool written = false;
Rollback *rb = nullptr;

if (configFiles->getRollbackObj(REC_CONFIG_FILE, &rb)) {
if (inc_version) {
RecDebug(DL_Note, "Rollback: '%s'", REC_CONFIG_FILE);
version_t ver = rb->getCurrentVersion();
if ((rb->updateVersion(tb, ver, -1, false)) != OK_ROLLBACK) {
RecDebug(DL_Note, "Rollback failed: '%s'", REC_CONFIG_FILE);
}
written = true;
}
}

if (!written) {
if (RecWriteConfigFile(tb) == REC_ERR_OKAY) {
rb->setLastModifiedTime();
check = false;
}
}
}

// If we didn't successfully sync to disk, check whether we need to update ....
if (check) {
if (configFiles->isConfigStale()) {
Expand Down
7 changes: 0 additions & 7 deletions lib/records/RecProcess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,9 @@ struct sync_cont : public Continuation {
int
sync(int /* event */, Event * /* e */)
{
RecBool disabled = false;
RecGetRecordBool("proxy.config.disable_configuration_modification", &disabled);

send_push_message();
RecSyncStatsFile();

if (!disabled && RecSyncConfigToTB(m_tb) == REC_ERR_OKAY) {
RecWriteConfigFile(m_tb);
}

Debug("statsproc", "sync_cont() processed");

return EVENT_CONT;
Expand Down
2 changes: 0 additions & 2 deletions mgmt/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,6 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.hostdb.host_file.interval", RECD_INT, "86400", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.disable_configuration_modification", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, "[0-1]", RECA_NULL}
,
//##########################################################################
//#
//# HTTP
Expand Down
4 changes: 0 additions & 4 deletions mgmt/api/TSControlMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ static std::unordered_map<int, ClientT *> accepted_con; // a list of all accepte

static TSMgmtError handle_control_message(int fd, void *msg, size_t msglen);

static RecBool disable_modification = false;

/*********************************************************************
* create_client
*
Expand Down Expand Up @@ -161,8 +159,6 @@ ts_ctrl_main(void *arg)

// check if have any connections or requests
if (fds_ready > 0) {
RecGetRecordBool("proxy.config.disable_configuration_modification", &disable_modification);

// first check for connections!
if (con_socket_fd >= 0 && FD_ISSET(con_socket_fd, &selectFDs)) {
fds_ready--;
Expand Down