You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2016/09/11 21:00:02 UTC
[trafficserver] branch master updated: TS-1882: Check for
unrecognized configuration values. This closes #971.
This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 4d004b2 TS-1882: Check for unrecognized configuration values. This closes #971.
4d004b2 is described below
commit 4d004b2ba8cf9f9591595ab6c58b486ae3bd0f56
Author: Alan M. Carroll <so...@yahoo-inc.com>
AuthorDate: Tue Sep 6 15:34:21 2016 -0500
TS-1882: Check for unrecognized configuration values.
This closes #971.
---
doc/developer-guide/api/functions/TSRecords.en.rst | 60 ++++++++++++++++++++++
.../api/types/TSRecordDataType.en.rst | 33 ++++++++----
doc/developer-guide/api/types/TSRecordType.en.rst | 3 ++
.../api/types/TSRecordUpdateType.en.rst | 10 ++++
...rdUpdateType.en.rst => TSStatPeristence.en.rst} | 19 ++++---
.../{TSRecordType.en.rst => TSStatSync.en.rst} | 25 ++++-----
lib/records/I_RecCore.h | 5 +-
lib/records/RecCore.cc | 15 ++++++
mgmt/LocalManager.cc | 2 +
proxy/Main.cc | 5 ++
10 files changed, 144 insertions(+), 33 deletions(-)
diff --git a/doc/developer-guide/api/functions/TSRecords.en.rst b/doc/developer-guide/api/functions/TSRecords.en.rst
new file mode 100644
index 0000000..e484881
--- /dev/null
+++ b/doc/developer-guide/api/functions/TSRecords.en.rst
@@ -0,0 +1,60 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+.. include:: ../../../common.defs
+
+.. default-domain:: c
+
+Traffic Server Records
+**********************
+
+|TS| maintains a set of records which cover both configuration values and statistics.
+
+Synopsis
+========
+
+`#include <ts/ts.h>`
+
+.. function:: TSReturnCode TSMgmtStringCreate(TSRecordType rec_type, const char* name, \
+ const TSMgmtString data_default, TSRecordUpdateType update_type, \
+ TSRecordCheckType check_type, \
+ const char* check_regex, TSRecordAccessType access_type)
+
+
+.. function:: TSReturnCode TSMgmtIntCreate(TSRecordType rec_type, const char* name, \
+ const TSMgmtInt data_default, TSRecordUpdateType update_type, \
+ TSRecordCheckType check_type, \
+ const char* check_regex, TSRecordAccessType access_type)
+
+.. function:: int TSStatCreate(const char* name, TSRecordDataType type, TSStatPersistence persistence, TSStatSync sync_style)
+
+Description
+===========
+
+:func:`TSMgmtStringCreate` registers :arg:`name` as a configuration name and sets its various properties. If :arg:`check_type` is :member:`TS_RECORDCHECK_STR` then :arg:`check_reg` must be point to a valid regular expression to use to check the string value.
+
+If a plugin uses a value from :file:`records.config` that is not built in to |TS| it must use this function or the value will be inaccessible and a warning for that name will be generated.
+
+Return Values
+=============
+
+:func:`TSMgmtStringCreate` and :func:`TSMgmtIntCreate` return :const:`TS_SUCCESS` if the management value was created and :const:`TS_ERROR` if not.
+
+
+See Also
+========
+
+:manpage:`TSAPI(3ts)`
diff --git a/doc/developer-guide/api/types/TSRecordDataType.en.rst b/doc/developer-guide/api/types/TSRecordDataType.en.rst
index 9bfdb8a..0eb0346 100644
--- a/doc/developer-guide/api/types/TSRecordDataType.en.rst
+++ b/doc/developer-guide/api/types/TSRecordDataType.en.rst
@@ -16,8 +16,8 @@
.. include:: ../../../common.defs
-TSRecordDataType
-****************
+TSRecordType
+************
Synopsis
========
@@ -31,22 +31,35 @@ Enum typedef.
Enumeration Members
===================
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_NULL
+.. c:member:: TSRecordType TS_RECORDDATATYPE_NULL
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_INT
+ No data type. Used to as an invalid initialization value.
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_FLOAT
+.. c:member:: TSRecordType TS_RECORDDATATYPE_INT
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_STRING
+ An integer.
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_COUNTER
+.. c:member:: TSRecordType TS_RECORDDATATYPE_FLOAT
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_STAT_CONST
+ Floating point.
+
+.. c:member:: TSRecordType TS_RECORDDATATYPE_STRING
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_STAT_FX
+ A string.
-.. c:member:: TSRecordDataType TS_RECORDDATATYPE_MAX
+.. c:member:: TSRecordType TS_RECORDDATATYPE_COUNTER
+
+ A counter which has a count and a sum.
+
+.. c:member:: TSRecordType TS_RECORDDATATYPE_STAT_CONST
+
+ A value that is unchangeable.
+
+.. c:member:: TSRecordType TS_RECORDDATATYPE_STAT_FX
+
+ Unknown.
Description
===========
+This data type describes the data stored in a management value such as a configuration value or a statistic value.
\ No newline at end of file
diff --git a/doc/developer-guide/api/types/TSRecordType.en.rst b/doc/developer-guide/api/types/TSRecordType.en.rst
index cb4a4f4..70e2480 100644
--- a/doc/developer-guide/api/types/TSRecordType.en.rst
+++ b/doc/developer-guide/api/types/TSRecordType.en.rst
@@ -35,6 +35,8 @@ Enumeration Members
.. c:member:: TSRecordType TS_RECORDTYPE_CONFIG
+ A configuration record.
+
.. c:member:: TSRecordType TS_RECORDTYPE_PROCESS
.. c:member:: TSRecordType TS_RECORDTYPE_NODE
@@ -50,3 +52,4 @@ Enumeration Members
Description
===========
+The management role for a management value. In practice only :c:member:`TS_RECORDTYPE_CONFIG` is usable.
\ No newline at end of file
diff --git a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst b/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
index e24d5dd..9a05c6a 100644
--- a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
+++ b/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
@@ -33,14 +33,24 @@ Enumeration Members
.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_NULL
+ The value cannot be updated. This is used primarily as a default value, actual instances should not use this.
+
.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_DYNAMIC
+ The value can be updated at runtime, including by using :program:`traffic_ctl`.
+
.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TS
+ The value is updated if the :program:`traffic_server` process is restarted.
+
.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TM
+ The value is updated if the :program:`traffic_manager` process is restarted.
+
.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TC
+ The value is updated if the :program:`traffic_cop` process is restarted. This is effect a complete restart of |TS|.
+
Description
===========
diff --git a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst b/doc/developer-guide/api/types/TSStatPeristence.en.rst
similarity index 70%
copy from doc/developer-guide/api/types/TSRecordUpdateType.en.rst
copy to doc/developer-guide/api/types/TSStatPeristence.en.rst
index e24d5dd..a8a7515 100644
--- a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
+++ b/doc/developer-guide/api/types/TSStatPeristence.en.rst
@@ -16,31 +16,30 @@
.. include:: ../../../common.defs
-TSRecordUpdateType
-******************
+TSStatPersistence
+*****************
Synopsis
========
-`#include <ts/apidefs.h>`
+`#include <ts/ts.h>`
-.. c:type:: TSRecordUpdateType
+.. c:type:: TSStatPersistence
Enum typedef.
Enumeration Members
===================
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_NULL
+.. c:member:: TSStatPersistence TS_STAT_PERSISTENT
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_DYNAMIC
+ The statistic value should be preserved across :program:`traffic_server` restarts.
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TS
+.. c:member:: TSStatPersistence TS_STAT_NON_PERSISTENT
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TM
-
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TC
+ The statistic value should not be preserved across process restarts.
Description
===========
+The level of persistence for a statistic value.
\ No newline at end of file
diff --git a/doc/developer-guide/api/types/TSRecordType.en.rst b/doc/developer-guide/api/types/TSStatSync.en.rst
similarity index 66%
copy from doc/developer-guide/api/types/TSRecordType.en.rst
copy to doc/developer-guide/api/types/TSStatSync.en.rst
index cb4a4f4..9b4b51e 100644
--- a/doc/developer-guide/api/types/TSRecordType.en.rst
+++ b/doc/developer-guide/api/types/TSStatSync.en.rst
@@ -16,37 +16,38 @@
.. include:: ../../../common.defs
-TSRecordType
-************
+TSStatSync
+*****************
Synopsis
========
-`#include <ts/apidefs.h>`
+`#include <ts/ts.h>`
-.. c:type:: TSRecordType
+.. c:type:: TSStatSync
Enum typedef.
Enumeration Members
===================
-.. c:member:: TSRecordType TS_RECORDTYPE_NULL
+.. c:member:: TSStatSync TS_STAT_SYNC_SUM
-.. c:member:: TSRecordType TS_RECORDTYPE_CONFIG
+ Values should add be summed.
-.. c:member:: TSRecordType TS_RECORDTYPE_PROCESS
+.. c:member:: TSStatSync TS_STAT_SYNC_COUNT
-.. c:member:: TSRecordType TS_RECORDTYPE_NODE
+ Values should be added together.
-.. c:member:: TSRecordType TS_RECORDTYPE_CLUSTER
+.. c:member:: TSStatSync TS_STAT_SYNC_AVG
-.. c:member:: TSRecordType TS_RECORDTYPE_LOCAL
+ Values should be arithmetically averaged.
-.. c:member:: TSRecordType TS_RECORDTYPE_PLUGIN
+.. c:member:: TSStatSync TS_STAT_SYNC_TIMEAVG
-.. c:member:: TSRecordType TS_RECORDTYPE_ALL
+ Values should be arithmetically averaged over a time period.
Description
===========
+The level of persistence for a statistic value.
\ No newline at end of file
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index d62524d..5e7d0ff 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -30,6 +30,7 @@
#include "I_RecAlarms.h"
#include "I_RecSignals.h"
#include "I_RecEvents.h"
+#include <functional>
struct RecRecord;
@@ -168,7 +169,6 @@ int RecGetRecordBool(const char *name, RecBool *rec_byte, bool lock = true);
//------------------------------------------------------------------------
// Record Attributes Reading
//------------------------------------------------------------------------
-
typedef void (*RecLookupCallback)(const RecRecord *, void *);
int RecLookupRecord(const char *name, RecLookupCallback callback, void *data, bool lock = true);
@@ -204,6 +204,9 @@ RecSignalManager(int id, const char *str)
// Format a message, and send it to the manager and to the Warning diagnostic.
void RecSignalWarning(int sig, const char *fmt, ...) TS_PRINTFLIKE(2, 3);
+/// Generate a warning if any configuration name/value is not registered.
+void RecConfigWarnIfUnregistered();
+
//-------------------------------------------------------------------------
// Backwards Compatibility Items (REC_ prefix)
//-------------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 28ca1ef..32cc46f 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -1249,3 +1249,18 @@ RecSignalWarning(int sig, const char *fmt, ...)
RecSignalManager(sig, msg);
va_end(args);
}
+
+//-------------------------------------------------------------------------
+// RecConfigWarnIfUnregistered
+//-------------------------------------------------------------------------
+/// Generate a warning if the record is a configuration name/value but is not registered.
+void
+RecConfigWarnIfUnregistered()
+{
+ RecDumpRecords(RECT_CONFIG,
+ [](RecT, void *, int registered_p, char const *name, int, RecData *) -> void {
+ if (!registered_p)
+ Warning("Unrecognized configuration value '%s'", name);
+ },
+ NULL);
+}
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index fd3c0e4..58c3e01 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -806,6 +806,8 @@ LocalManager::processEventQueue()
bool incVersion = mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE;
if (RecReadConfigFile(incVersion) != REC_ERR_OKAY) {
mgmt_elog(errno, "[fileUpdated] Config update failed for records.config\n");
+ } else {
+ RecConfigWarnIfUnregistered();
}
handled_by_mgmt = true;
}
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 4f4bf36..116ce1c 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1861,6 +1861,11 @@ main(int /* argc ATS_UNUSED */, const char **argv)
}
}
+ // Plugins can register their own configuration names so now after they've done that
+ // check for unexpected names. This is very late because remap plugins must be allowed to
+ // fire up as well.
+ RecConfigWarnIfUnregistered();
+
// "Task" processor, possibly with its own set of task threads
tasksProcessor.start(num_task_threads, stacksize);
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].