TS-3231: track when process restarts are required Start checking the record update type when we process reconfiguration events so that we can publish metrics to tell the operator when a restart is required. Note that is is only as accurate as the RecordsConfig definitions, so YYMV.
Add the following new metrics: proxy.node.config.restart_required.proxy proxy.node.config.restart_required.manager proxy.node.config.restart_required.cop Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f8be3681 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f8be3681 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f8be3681 Branch: refs/heads/master Commit: f8be3681a0831d842b934628f2a9b31416ddb873 Parents: 52c9e32 Author: James Peach <[email protected]> Authored: Mon Nov 17 16:44:06 2014 -0800 Committer: James Peach <[email protected]> Committed: Tue Dec 9 13:48:37 2014 -0800 ---------------------------------------------------------------------- cmd/traffic_manager/traffic_manager.cc | 4 ++++ lib/records/P_RecCore.cc | 13 +++++++++++-- lib/records/P_RecCore.h | 2 +- lib/records/RecLocal.cc | 20 +++++++++++++++++++- mgmt/LocalManager.cc | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f8be3681/cmd/traffic_manager/traffic_manager.cc ---------------------------------------------------------------------- diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc index 31576c0..d7a37b5 100644 --- a/cmd/traffic_manager/traffic_manager.cc +++ b/cmd/traffic_manager/traffic_manager.cc @@ -688,6 +688,10 @@ main(int argc, char **argv) RecRegisterStatInt(RECT_NODE, "proxy.node.config.reconfigure_time", time(NULL), RECP_NON_PERSISTENT); RecRegisterStatInt(RECT_NODE, "proxy.node.config.reconfigure_required", 0, RECP_NON_PERSISTENT); + RecRegisterStatInt(RECT_NODE, "proxy.node.config.restart_required.proxy", 0, RECP_NON_PERSISTENT); + RecRegisterStatInt(RECT_NODE, "proxy.node.config.restart_required.manager", 0, RECP_NON_PERSISTENT); + RecRegisterStatInt(RECT_NODE, "proxy.node.config.restart_required.cop", 0, RECP_NON_PERSISTENT); + for (;;) { lmgmt->processEventQueue(); lmgmt->pollMgmtProcessServer(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f8be3681/lib/records/P_RecCore.cc ---------------------------------------------------------------------- diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc index 1296fe0..3bcda8c 100644 --- a/lib/records/P_RecCore.cc +++ b/lib/records/P_RecCore.cc @@ -798,11 +798,12 @@ RecSyncConfigToTB(textBuffer * tb, bool *inc_version) //------------------------------------------------------------------------- // RecExecConfigUpdateCbs //------------------------------------------------------------------------- -int +RecUpdateT RecExecConfigUpdateCbs(unsigned int update_required_type) { RecRecord *r; int i, num_records; + RecUpdateT update_type = RECU_NULL; num_records = g_num_records; for (i = 0; i < num_records; i++) { @@ -819,6 +820,14 @@ RecExecConfigUpdateCbs(unsigned int update_required_type) } */ + if (r->config_meta.update_required) { + printf("update (type %#x) required on %s\n", r->config_meta.update_required, r->name); + + if (r->config_meta.update_type > update_type) { + update_type = r->config_meta.update_type; + } + } + if ((r->config_meta.update_required & update_required_type) && (r->config_meta.update_cb_list)) { RecConfigUpdateCbList *cur_callback = NULL; for (cur_callback = r->config_meta.update_cb_list; cur_callback; cur_callback = cur_callback->next) { @@ -830,7 +839,7 @@ RecExecConfigUpdateCbs(unsigned int update_required_type) rec_mutex_release(&(r->lock)); } - return REC_ERR_OKAY; + return update_type; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f8be3681/lib/records/P_RecCore.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h index bda0103..0f3e16d 100644 --- a/lib/records/P_RecCore.h +++ b/lib/records/P_RecCore.h @@ -95,7 +95,7 @@ int send_push_message(); int send_pull_message(RecMessageT msg_type); int send_register_message(RecRecord * record); int recv_message_cb(RecMessage * msg, RecMessageT msg_type, void *cookie); -int RecExecConfigUpdateCbs(unsigned int update_required_type); +RecUpdateT RecExecConfigUpdateCbs(unsigned int update_required_type); int RecExecStatUpdateFuncs(); int RecExecRawStatUpdateFuncs(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f8be3681/lib/records/RecLocal.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc index 0245f08..10aca66 100644 --- a/lib/records/RecLocal.cc +++ b/lib/records/RecLocal.cc @@ -112,8 +112,26 @@ sync_thr(void * data) static void * config_update_thr(void * /* data */) { + while (true) { - RecExecConfigUpdateCbs(REC_LOCAL_UPDATE_REQUIRED); + switch (RecExecConfigUpdateCbs(REC_LOCAL_UPDATE_REQUIRED)) { + case RECU_RESTART_TS: + RecSetRecordInt("proxy.node.config.restart_required.proxy", 1); + break; + case RECU_RESTART_TM: + RecSetRecordInt("proxy.node.config.restart_required.proxy", 1); + RecSetRecordInt("proxy.node.config.restart_required.manager", 1); + break; + case RECU_RESTART_TC: + RecSetRecordInt("proxy.node.config.restart_required.proxy", 1); + RecSetRecordInt("proxy.node.config.restart_required.manager", 1); + RecSetRecordInt("proxy.node.config.restart_required.cop", 1); + break; + case RECU_NULL: + case RECU_DYNAMIC: + break; + } + usleep(REC_CONFIG_UPDATE_INTERVAL_MS * 1000); } return NULL; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f8be3681/mgmt/LocalManager.cc ---------------------------------------------------------------------- diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc index 4fbbc2b..fc9f148 100644 --- a/mgmt/LocalManager.cc +++ b/mgmt/LocalManager.cc @@ -860,7 +860,7 @@ LocalManager::processEventQueue() // check if we have a local file update if (mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE || mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE_NO_INC_VERSION) { // records.config - if (!(strcmp(data_raw, "records.config"))) { + if (!(strcmp(data_raw, REC_CONFIG_FILE))) { bool incVersion = mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE; if (RecReadConfigFile(incVersion) != REC_ERR_OKAY) { mgmt_elog(stderr, errno, "[fileUpdated] Config update failed for records.config\n");
