diff options
author | Mihails Prihodko <mihails.prihodko@zabbix.com> | 2022-04-20 17:54:12 +0300 |
---|---|---|
committer | Mihails Prihodko <mihails.prihodko@zabbix.com> | 2022-04-20 17:54:12 +0300 |
commit | fa21fb9f274214e07fb85664a2ff6e32a330716c (patch) | |
tree | 0276c2a74af2ed332821b0757e3ae1c5607548e3 | |
parent | b67f1e96e64eb359493e32daf19caa019a2e5000 (diff) | |
parent | 14c835c81825af57fbb9d70a643802ee6811e9c1 (diff) |
.......... [ZBX-20743] merged branch feature/ZBX-20638-5.5 into feature/ZBX-20743-6.0
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-20638 | 1 | ||||
-rw-r--r-- | include/zbxdb.h | 7 | ||||
-rw-r--r-- | include/zbxhistory.h | 2 | ||||
-rw-r--r-- | src/libs/zbxhistory/history.c | 6 | ||||
-rw-r--r-- | src/libs/zbxhistory/history.h | 2 | ||||
-rw-r--r-- | src/libs/zbxhistory/history_elastic.c | 46 | ||||
-rw-r--r-- | src/zabbix_proxy/proxy.c | 36 | ||||
-rw-r--r-- | src/zabbix_server/server.c | 41 | ||||
-rw-r--r-- | tests/zbxmocktest.c | 2 | ||||
-rw-r--r-- | ui/app/partials/administration.system.info.php | 26 | ||||
-rw-r--r-- | ui/include/defines.inc.php | 14 |
11 files changed, 143 insertions, 40 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-20638 b/ChangeLog.d/bugfix/ZBX-20638 new file mode 100644 index 00000000000..e304073e81e --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-20638 @@ -0,0 +1 @@ +..F....PS. [ZBX-20638] fixed handling of db version higher than supported (agriscenko, dgoloscapov) diff --git a/include/zbxdb.h b/include/zbxdb.h index d8300ab64dd..98e7ccec272 100644 --- a/include/zbxdb.h +++ b/include/zbxdb.h @@ -178,7 +178,8 @@ int zbx_db_strlen_n(const char *text_loc, size_t maxlen); #define ZBX_ORACLE_MAX_VERSION_FRIENDLY "Database 21c Release 21.x.x" #define ZBX_ELASTIC_MIN_VERSION 70000 -#define ZBX_ELASTIC_MIN_VERSION_FRIENDLY "7.x" +#define ZBX_ELASTIC_SUPPORTED_VERSION_FRIENDLY "7.x" +#define ZBX_ELASTIC_MAX_VERSION 79999 #define ZBX_DBVERSION_UNDEFINED 0 @@ -207,7 +208,9 @@ typedef enum DB_VERSION_HIGHER_THAN_MAXIMUM, DB_VERSION_FAILED_TO_RETRIEVE, DB_VERSION_NOT_SUPPORTED_ERROR, - DB_VERSION_NOT_SUPPORTED_WARNING + DB_VERSION_NOT_SUPPORTED_WARNING, + DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR, + DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING, } zbx_db_version_status_t; diff --git a/include/zbxhistory.h b/include/zbxhistory.h index 8f3e85cfb0b..d0fdaa7d157 100644 --- a/include/zbxhistory.h +++ b/include/zbxhistory.h @@ -61,7 +61,7 @@ int zbx_history_get_values(zbx_uint64_t itemid, int value_type, int start, int c zbx_vector_history_record_t *values); int zbx_history_requires_trends(int value_type); -void zbx_history_check_version(struct zbx_json *json); +void zbx_history_check_version(struct zbx_json *json, int *result); #define FLUSH_SUCCEED 0 #define FLUSH_FAIL -1 diff --git a/src/libs/zbxhistory/history.c b/src/libs/zbxhistory/history.c index 4b364e88202..3bac7c9d184 100644 --- a/src/libs/zbxhistory/history.c +++ b/src/libs/zbxhistory/history.c @@ -435,8 +435,10 @@ void zbx_history_value2variant(const history_value_t *value, unsigned char value * functions * * * ******************************************************************************/ -void zbx_history_check_version(struct zbx_json *json) +void zbx_history_check_version(struct zbx_json *json, int *result) { if (NULL != CONFIG_HISTORY_STORAGE_URL) - zbx_elastic_version_extract(json); + { + zbx_elastic_version_extract(json, result); + } } diff --git a/src/libs/zbxhistory/history.h b/src/libs/zbxhistory/history.h index 948e81e0e01..7d84a98fe17 100644 --- a/src/libs/zbxhistory/history.h +++ b/src/libs/zbxhistory/history.h @@ -57,7 +57,7 @@ int zbx_history_sql_init(zbx_history_iface_t *hist, unsigned char value_type, ch /* elastic hist */ int zbx_history_elastic_init(zbx_history_iface_t *hist, unsigned char value_type, char **error); -void zbx_elastic_version_extract(struct zbx_json *json); +void zbx_elastic_version_extract(struct zbx_json *json, int *result); zbx_uint32_t zbx_elastic_version_get(void); #endif diff --git a/src/libs/zbxhistory/history_elastic.c b/src/libs/zbxhistory/history_elastic.c index 85fd5390359..1cb2888e485 100644 --- a/src/libs/zbxhistory/history_elastic.c +++ b/src/libs/zbxhistory/history_elastic.c @@ -37,6 +37,7 @@ const char *value_type_str[] = {"dbl", "str", "log", "uint", "text"}; extern char *CONFIG_HISTORY_STORAGE_URL; extern int CONFIG_HISTORY_STORAGE_PIPELINES; +extern int CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS; static zbx_uint32_t ZBX_ELASTIC_SVERSION = ZBX_DBVERSION_UNDEFINED; @@ -997,7 +998,7 @@ int zbx_history_elastic_init(zbx_history_iface_t *hist, unsigned char value_type * the response string * * * ************************************************************************************/ -void zbx_elastic_version_extract(struct zbx_json *json) +void zbx_elastic_version_extract(struct zbx_json *json, int *result) { #define RIGHT2(x) ((int)((zbx_uint32_t)(x) - ((zbx_uint32_t)((x)/100))*100)) zbx_httppage_t page; @@ -1089,11 +1090,45 @@ out: db_version_info.database = "ElasticDB"; db_version_info.friendly_current_version = version_friendly; - db_version_info.friendly_min_version = ZBX_ELASTIC_MIN_VERSION_FRIENDLY; - db_version_info.friendly_max_version = ""; + db_version_info.friendly_min_version = ZBX_ELASTIC_SUPPORTED_VERSION_FRIENDLY; + db_version_info.friendly_max_version = ZBX_ELASTIC_SUPPORTED_VERSION_FRIENDLY; db_version_info.friendly_min_supported_version = NULL; + db_version_info.flag = zbx_db_version_check(db_version_info.database, version, ZBX_ELASTIC_MIN_VERSION, - ZBX_DBVERSION_UNDEFINED, ZBX_DBVERSION_UNDEFINED); + ZBX_ELASTIC_MAX_VERSION, ZBX_DBVERSION_UNDEFINED); + + if (DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) + { + if (0 == CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS) + { + zabbix_log(LOG_LEVEL_ERR, " "); + zabbix_log(LOG_LEVEL_ERR, "Unable to start Zabbix server due to unsupported %s database server" + " version (%s).", db_version_info.database, + db_version_info.friendly_current_version); + + zabbix_log(LOG_LEVEL_ERR, "Must be up to (%s).", + db_version_info.friendly_max_version); + + zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); + zabbix_log(LOG_LEVEL_ERR, "Override by setting AllowUnsupportedDBVersions=1" + " in Zabbix server configuration file at your own risk."); + zabbix_log(LOG_LEVEL_ERR, " "); + + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR; + *result = FAIL; + } + else + { + zabbix_log(LOG_LEVEL_ERR, " "); + zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database server version (%s).", + db_version_info.database, db_version_info.friendly_current_version); + zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); + zabbix_log(LOG_LEVEL_ERR, " "); + + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING; + } + } + db_version_info.history_pk = 0; zbx_db_version_json_create(json, &db_version_info); @@ -1120,9 +1155,10 @@ int zbx_history_elastic_init(zbx_history_iface_t *hist, unsigned char value_type return FAIL; } -void zbx_elastic_version_extract(struct zbx_json *json) +void zbx_elastic_version_extract(struct zbx_json *json, int *result) { ZBX_UNUSED(json); + ZBX_UNUSED(result); } zbx_uint32_t zbx_elastic_version_get(void) diff --git a/src/zabbix_proxy/proxy.c b/src/zabbix_proxy/proxy.c index 1cc1e191c0b..c9ab5dbdc1c 100644 --- a/src/zabbix_proxy/proxy.c +++ b/src/zabbix_proxy/proxy.c @@ -1042,16 +1042,27 @@ static void zbx_check_db(void) DBextract_version_info(&db_version_info); - if (DB_VERSION_NOT_SUPPORTED_ERROR == db_version_info.flag) + if (DB_VERSION_NOT_SUPPORTED_ERROR == db_version_info.flag || + DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) { if (0 == CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS) { zabbix_log(LOG_LEVEL_ERR, " "); zabbix_log(LOG_LEVEL_ERR, "Unable to start Zabbix proxy due to unsupported %s database server" - " version (%s)", db_version_info.database, + " version (%s).", db_version_info.database, db_version_info.friendly_current_version); - zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s)", - db_version_info.friendly_min_supported_version); + + if (DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) + { + zabbix_log(LOG_LEVEL_ERR, "Must not be higher than (%s).", + db_version_info.friendly_max_version); + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR; + } + else + { + zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s).", + db_version_info.friendly_min_supported_version); + } zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); zabbix_log(LOG_LEVEL_ERR, "Override by setting AllowUnsupportedDBVersions=1" " in Zabbix proxy configuration file at your own risk."); @@ -1061,10 +1072,21 @@ static void zbx_check_db(void) else { zabbix_log(LOG_LEVEL_ERR, " "); - zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database server version (%s)", + zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database server version (%s).", db_version_info.database, db_version_info.friendly_current_version); - zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s)", - db_version_info.friendly_min_supported_version); + + if (DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) + { + zabbix_log(LOG_LEVEL_ERR, "Should not be higher than (%s).", + db_version_info.friendly_max_version); + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING; + } + else + { + zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s).", + db_version_info.friendly_min_supported_version); + } + zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); zabbix_log(LOG_LEVEL_ERR, " "); } diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index f45820b2dfb..f4840d767cf 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -1105,16 +1105,28 @@ static void zbx_check_db(void) zabbix_log(LOG_LEVEL_ERR, "Must be a least %s", db_version_info.friendly_min_version); result = FAIL; } - else if (DB_VERSION_NOT_SUPPORTED_ERROR == db_version_info.flag) + else if (DB_VERSION_NOT_SUPPORTED_ERROR == db_version_info.flag || + DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) { if (0 == CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS) { zabbix_log(LOG_LEVEL_ERR, " "); zabbix_log(LOG_LEVEL_ERR, "Unable to start Zabbix server due to unsupported %s database server" - " version (%s)", db_version_info.database, + " version (%s).", db_version_info.database, db_version_info.friendly_current_version); - zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s)", - db_version_info.friendly_min_supported_version); + + if (DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) + { + zabbix_log(LOG_LEVEL_ERR, "Must not be higher than (%s).", + db_version_info.friendly_max_version); + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR; + } + else + { + zabbix_log(LOG_LEVEL_ERR, "Must be at least (%s).", + db_version_info.friendly_min_supported_version); + } + zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); zabbix_log(LOG_LEVEL_ERR, "Override by setting AllowUnsupportedDBVersions=1" " in Zabbix server configuration file at your own risk."); @@ -1124,13 +1136,24 @@ static void zbx_check_db(void) else { zabbix_log(LOG_LEVEL_ERR, " "); - zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database server version (%s)", + zabbix_log(LOG_LEVEL_ERR, "Warning! Unsupported %s database server version (%s).", db_version_info.database, db_version_info.friendly_current_version); - zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s)", - db_version_info.friendly_min_supported_version); + + if (DB_VERSION_HIGHER_THAN_MAXIMUM == db_version_info.flag) + { + zabbix_log(LOG_LEVEL_ERR, "Should not be higher than (%s).", + db_version_info.friendly_max_version); + db_version_info.flag = DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING; + } + else + { + zabbix_log(LOG_LEVEL_ERR, "Should be at least (%s).", + db_version_info.friendly_min_supported_version); + db_version_info.flag = DB_VERSION_NOT_SUPPORTED_WARNING; + } + zabbix_log(LOG_LEVEL_ERR, "Use of supported database version is highly recommended."); zabbix_log(LOG_LEVEL_ERR, " "); - db_version_info.flag = DB_VERSION_NOT_SUPPORTED_WARNING; } } @@ -1174,7 +1197,7 @@ static void zbx_check_db(void) zbx_db_version_json_create(&db_version_json, &db_version_info); if (SUCCEED == result) - zbx_history_check_version(&db_version_json); + zbx_history_check_version(&db_version_json, &result); DBflush_version_requirements(db_version_json.buffer); zbx_json_free(&db_version_json); diff --git a/tests/zbxmocktest.c b/tests/zbxmocktest.c index bc42f2fc478..59dd2f8cc88 100644 --- a/tests/zbxmocktest.c +++ b/tests/zbxmocktest.c @@ -135,6 +135,8 @@ int CONFIG_PROXYPOLLER_FORKS = 1; /* parameters for passive proxies */ int CONFIG_PROXYCONFIG_FREQUENCY = 0; int CONFIG_PROXYDATA_FREQUENCY = 1; /* 1s */ +int CONFIG_ALLOW_UNSUPPORTED_DB_VERSIONS = 0; + char *CONFIG_LOAD_MODULE_PATH = NULL; char **CONFIG_LOAD_MODULE = NULL; diff --git a/ui/app/partials/administration.system.info.php b/ui/app/partials/administration.system.info.php index 57edd77da06..48ccea6157c 100644 --- a/ui/app/partials/administration.system.info.php +++ b/ui/app/partials/administration.system.info.php @@ -141,33 +141,45 @@ if ($data['user_type'] == USER_TYPE_SUPER_ADMIN) { switch ($dbversion['flag']) { case DB_VERSION_LOWER_THAN_MINIMUM: - $error = _s('Minimum required %1$s database version is %2$s.', $dbversion['database'], - $dbversion['min_version'] + $error = _s('Error! Unable to start Zabbix server. Minimum required %1$s database version is %2$s.', + $dbversion['database'], $dbversion['min_version'] ); break; case DB_VERSION_HIGHER_THAN_MAXIMUM: - $error = _s('Maximum required %1$s database version is %2$s.', $dbversion['database'], - $dbversion['max_version'] + $error = _s('Error! Unable to start Zabbix server. Maximum required %1$s database version is %2$s.', + $dbversion['database'], $dbversion['max_version'] ); break; case DB_VERSION_FAILED_TO_RETRIEVE: - $error = _('Unable to retrieve database version.'); + $error = _('Warning! Unable to retrieve database version.'); $dbversion['current_version'] = ''; break; case DB_VERSION_NOT_SUPPORTED_ERROR: - $error = _s('Error! Unable to start Zabbix server due to unsupported %1$s database server version. Must be at least (%2$s)', + $error = _s('Error! Unable to start Zabbix server due to unsupported %1$s database server version. Must be at least (%2$s).', $dbversion['database'], $dbversion['min_supported_version'] ); break; case DB_VERSION_NOT_SUPPORTED_WARNING: - $error = _s('Warning! Unsupported %1$s database server version. Should be at least (%2$s)', + $error = _s('Warning! Unsupported %1$s database server version. Should be at least (%2$s).', $dbversion['database'], $dbversion['min_supported_version'] ); break; + + case DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR: + $error = _s('Error! Unable to start Zabbix server due to unsupported %1$s database server version. Must not be higher than (%2$s).', + $dbversion['database'], $dbversion['max_version'] + ); + break; + + case DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING: + $error = _s('Warning! Unsupported %1$s database server version. Should not be higher than (%2$s).', + $dbversion['database'], $dbversion['max_version'] + ); + break; } $info_table->addRow( diff --git a/ui/include/defines.inc.php b/ui/include/defines.inc.php index f6c273f4772..2e41a1eca51 100644 --- a/ui/include/defines.inc.php +++ b/ui/include/defines.inc.php @@ -24,12 +24,14 @@ define('ZABBIX_EXPORT_VERSION', '6.0'); define('ZABBIX_DB_VERSION', 6000000); -define('DB_VERSION_SUPPORTED', 0); -define('DB_VERSION_LOWER_THAN_MINIMUM', 1); -define('DB_VERSION_HIGHER_THAN_MAXIMUM', 2); -define('DB_VERSION_FAILED_TO_RETRIEVE', 3); -define('DB_VERSION_NOT_SUPPORTED_ERROR', 4); -define('DB_VERSION_NOT_SUPPORTED_WARNING', 5); +define('DB_VERSION_SUPPORTED', 0); +define('DB_VERSION_LOWER_THAN_MINIMUM', 1); +define('DB_VERSION_HIGHER_THAN_MAXIMUM', 2); +define('DB_VERSION_FAILED_TO_RETRIEVE', 3); +define('DB_VERSION_NOT_SUPPORTED_ERROR', 4); +define('DB_VERSION_NOT_SUPPORTED_WARNING', 5); +define('DB_VERSION_HIGHER_THAN_MAXIMUM_ERROR', 6); +define('DB_VERSION_HIGHER_THAN_MAXIMUM_WARNING', 7); define('ZABBIX_COPYRIGHT_FROM', '2001'); define('ZABBIX_COPYRIGHT_TO', '2022'); |