Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于portal中设置判断条件中文转义造成hbs报错问题 #12

Closed
mdh67899 opened this issue Oct 9, 2017 · 0 comments
Closed

Comments

@mdh67899
Copy link

mdh67899 commented Oct 9, 2017

falcon portal里面设置报警条件的设置all(3) > 10, 但是输入value值的时候因为输入法的问题写成了中文的10

hbs读取strategy表记录的时候,hbs/db/strategy.go文件中的QueryStrategies函数执行sql获取所有的Strategy列表,执行sql得到结果时将得到的strategy表中right_value值转义成float64类型,这个时候就会产生转换类型报错,代码中对这条报警条件continue掉,造成报警策略不生效

我想问一下数据库的表结构和后台的结构体类型为什么没有设置成一致呢?
这个bug是忽略掉还是提个pull request修复掉?
谢谢

falcon_portal数据库中的strategy表结构

CREATE TABLE `strategy` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `metric` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `tags` varchar(256) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `max_step` int(11) NOT NULL DEFAULT '1',
  `priority` tinyint(4) NOT NULL DEFAULT '0',
  `func` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'all(#1)',
  `op` varchar(8) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `right_value` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `note` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `run_begin` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `run_end` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `tpl_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `idx_strategy_tpl_id` (`tpl_id`)
) ENGINE=InnoDB AUTO_INCREMENT=869 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

right_value为中文字符时hbs的报错信息

2017/08/08 13:29:32 strategy.go:41: ERROR: sql: Scan error on column index 5: converting string "10" to a float64: strconv.ParseFloat: parsing "10": invalid syntax
2017/08/08 13:29:32 strategy.go:41: ERROR: sql: Scan error on column index 5: converting string "10" to a float64: strconv.ParseFloat: parsing "10": invalid syntax
2017/08/08 13:30:32 strategy.go:41: ERROR: sql: Scan error on column index 5: converting string "10" to a float64: strconv.ParseFloat: parsing "10": invalid syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant