influxdata / influxdata/kapacitor
[bug] can not add new templates after one deleted previously
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
When trying to fix a mistake in one template I've deleted first.
Now I'm trying to define again with the same name and this is the error.
````
> kapacitor define-template UMBRAL_2EX_CC_UA_FMEAN_TST -tick ./tpl/UMBRAL_2EX_CC_UA_FMEAN_TST.tick.tpl
template UMBRAL_2EX_CC_UA_FMEAN_TST already exists
````
with this output trace
````
log messages must have 'L!' prefix where L is one of 'D', 'I', 'W', 'E'[log] 2017/09/22 14:44:15 http: panic serving 127.0.0.1:45919: runtime error: invalid memory address or nil pointer dereference
goroutine 331 [running]:
net/http.(*conn).serve.func1(0xc420bee780)
/usr/local/go/src/net/http/server.go:1491 +0x12a
panic(0x1cd80a0, 0xc4200120f0)
/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/influxdata/kapacitor/services/task_store.(*Service).convertTemplate(0xc420358a00, 0xc422af58e0, 0x1a, 0x0, 0xc4205f8000, 0x1cf2, 0x0, 0x0, 0xed15430cf, 0x254af1ea, ...)
/root/go/src/github.com/influxdata/kapacitor/services/task_store/service.go:1368 +0x157
github.com/influxdata/kapacitor/services/task_store.(*Service).handleTemplate(0xc420358a00, 0x2e340e0, 0xc422af51e0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/task_store/service.go:1409 +0x1d4
github.com/influxdata/kapacitor/services/task_store.(*Service).(github.com/influxdata/kapacitor/services/task_store.handleTemplate)-fm(0x2e340e0, 0xc422af51e0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/task_store/service.go:135 +0x48
github.com/influxdata/kapacitor/services/httpd.authorize.func1(0x2e340e0, 0xc422af51e0, 0xc420804c30, 0x1fba4d3, 0xa, 0x1, 0x2ea8360, 0x0, 0x0, 0xc420376570)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:714 +0xe9
github.com/influxdata/kapacitor/services/httpd.authenticate.func1(0x2e340e0, 0xc422af51e0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:579 +0xa6d
net/http.HandlerFunc.ServeHTTP(0xc4203ec820, 0x2e340e0, 0xc422af51e0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.jsonContent.func1(0x2e340e0, 0xc422af51e0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:818 +0xb1
net/http.HandlerFunc.ServeHTTP(0xc4203ec8c0, 0x2e340e0, 0xc422af51e0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.gzipFilter.func1(0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:811 +0x1e3
net/http.HandlerFunc.ServeHTTP(0xc4203ec920, 0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.versionHeader.func1(0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:827 +0xbc
net/http.HandlerFunc.ServeHTTP(0xc4203eca00, 0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.cors.func1(0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:860 +0xee
net/http.HandlerFunc.ServeHTTP(0xc4203eca60, 0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.requestID.func1(0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:870 +0x138
net/http.HandlerFunc.ServeHTTP(0xc4203ecb40, 0x2e2bd60, 0xc422af51a0, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.logHandler.func1(0x2e2bd60, 0xc422af5180, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:878 +0xfa
net/http.HandlerFunc.ServeHTTP(0xc4203ecba0, 0x2e2bd60, 0xc422af5180, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.recovery.func1(0x2e33e20, 0xc421306410, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:887 +0xfa
net/http.HandlerFunc.ServeHTTP(0xc4203ecc40, 0x2e33e20, 0xc421306410, 0xc420804c30)
/usr/local/go/src/net/http/server.go:1726 +0x44
github.com/influxdata/kapacitor/services/httpd.(*ServeMux).ServeHTTP(0xc42035b110, 0x2e33e20, 0xc421306410, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/mux.go:163 +0x7f
github.com/influxdata/kapacitor/services/httpd.(*Handler).ServeHTTP(0xc420123b80, 0x2e33e20, 0xc421306410, 0xc420804c30)
/root/go/src/github.com/influxdata/kapacitor/services/httpd/handler.go:365 +0xcf
net/http.serverHandler.ServeHTTP(0xc421442900, 0x2e33e20, 0xc421306410, 0xc420804c30)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc420bee780, 0x2e360a0, 0xc42007d3c0)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2293 +0x44d
````
I've tried to create again with other name, with this result:
````
> kapacitor define-template UMBRAL_2EX_CC_UA_FMEAN_TST2 -tick ./tpl/UMBRAL_2EX_CC_UA_FMEAN_TST.tick.tpl
unknown type "unknown TaskType 0"
````
I'm working with Kapacitor 1.3.1 (git: master 3b5512f7276483326577907803167e4bb213c613)
Contributor guide
Research direction
Start by reproducing the two `kapacitor define-template` commands, then inspect `services/task_store/service.go` at `convertTemplate` (line 1368) and `handleTemplate` (line 1409). Trace the deleted-template and alternate-name paths; done means the request no longer panics and template creation reports the correct result for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100