This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 676cc72 Removes disable_configuration_modification, making it always on 676cc72 is described below commit 676cc72ba1028783570c2a23d9f73bf209a2f5e5 Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Fri May 17 09:58:06 2019 -0600 Removes disable_configuration_modification, making it always on This eliminates the possibility of writing out configurations to disk completely. We'll remove the Rollback feature after this lands as well. --- doc/admin-guide/files/records.config.en.rst | 14 -- .../admin-guide/files/records.config.en.po | 7 - lib/records/P_RecCore.cc | 212 --------------------- lib/records/P_RecCore.h | 3 - lib/records/RecLocal.cc | 33 +--- lib/records/RecProcess.cc | 7 - mgmt/RecordsConfig.cc | 2 - mgmt/api/TSControlMain.cc | 4 - 8 files changed, 1 insertion(+), 281 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index 124e5f9..04bc876 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -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.). @@ -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 =================== diff --git a/doc/locale/ja/LC_MESSAGES/admin-guide/files/records.config.en.po b/doc/locale/ja/LC_MESSAGES/admin-guide/files/records.config.en.po index 05e603e..e0c6b62 100644 --- a/doc/locale/ja/LC_MESSAGES/admin-guide/files/records.config.en.po +++ b/doc/locale/ja/LC_MESSAGES/admin-guide/files/records.config.en.po @@ -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 " diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc index e89ccb9..5b43866 100644 --- a/lib/records/P_RecCore.cc +++ b/lib/records/P_RecCore.cc @@ -651,142 +651,6 @@ RecReadConfigFile(bool inc_version) } //------------------------------------------------------------------------- -// 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 //------------------------------------------------------------------------- RecUpdateT @@ -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; -} diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h index 3d8bd35..7825ae0 100644 --- a/lib/records/P_RecCore.h +++ b/lib/records/P_RecCore.h @@ -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 diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc index 34c7215..8190feb 100644 --- a/lib/records/RecLocal.cc +++ b/lib/records/RecLocal.cc @@ -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()) { diff --git a/lib/records/RecProcess.cc b/lib/records/RecProcess.cc index 29fcb07..b425bd3 100644 --- a/lib/records/RecProcess.cc +++ b/lib/records/RecProcess.cc @@ -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; diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 212ad1c..777ccfa 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -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 diff --git a/mgmt/api/TSControlMain.cc b/mgmt/api/TSControlMain.cc index b9f49a1..8d346b5 100644 --- a/mgmt/api/TSControlMain.cc +++ b/mgmt/api/TSControlMain.cc @@ -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 * @@ -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--;