caas-team / sparrow

A monitoring tool to gather infrastructure network information
Apache License 2.0
6 stars 4 forks source link

Targetmanager doesn't need timer reset #114

Closed puffitos closed 4 months ago

puffitos commented 4 months ago

Motivation

The reset timers are unnecessary. The timers carry on automatically and there is no need to reset them.

Changes

Removed the reset call from the timers.

TODO

lvlcn-t commented 4 months ago

@puffitos Are you sure this was correct? We have timers here, not tickers.

Each operation (refreshing targets, registering, and updating) now only executes once after startup. After that, the select statement blocks indefinitely because none of the channels (checkTimer.C, registrationTimer.C, updateTimer.C) receive any more values because of the expired timer.

As you can see in these logs, each operation is now only triggered once:

$ go run main.go run --config .tmp/sparrow.yaml 
Using config file: .tmp/sparrow.yaml
{"time":"2024-02-29T23:53:22.176459468+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/cmd.NewCmdRun.run.func1","file":"/home/tom/dev/sparrow/cmd/run.go","line":81},"msg":"Running sparrow"}
{"time":"2024-02-29T23:53:22.176503872+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/targets.(*manager).Reconcile","file":"/home/tom/dev/sparrow/pkg/sparrow/targets/manager.go","line":82},"msg":"Starting target manager reconciliation"}
{"time":"2024-02-29T23:53:22.176571169+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/api.(*api).Run.func1","file":"/home/tom/dev/sparrow/pkg/api/api.go","line":76},"msg":"Serving Api","addr":":8080"}
{"time":"2024-02-29T23:53:33.501372239+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/git.(*Client).CommitFile","file":"/home/tom/dev/sparrow/pkg/sparrow/git/git.go","line":121},"msg":"File committed and pushed","file":"tom.dev.sparrow.com.json"}
{"time":"2024-02-29T23:53:52.194231807+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:54:22.194857223+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:54:22.424555542+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/git.(*Client).FetchFiles","file":"/home/tom/dev/sparrow/pkg/sparrow/git/git.go","line":82},"msg":"Successfully fetched all target files","files":1}
{"time":"2024-02-29T23:54:23.437925861+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/sparrow/git.(*Client).CommitFile","file":"/home/tom/dev/sparrow/pkg/sparrow/git/git.go","line":121},"msg":"File committed and pushed","file":"tom.dev.sparrow.com.json"}
{"time":"2024-02-29T23:54:52.195589687+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:55:22.21459645+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:55:52.225627703+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:56:22.242718584+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:56:52.243342933+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
{"time":"2024-02-29T23:57:22.264238966+01:00","level":"INFO","source":{"function":"github.com/caas-team/sparrow/pkg/config.(*FileLoader).Run","file":"/home/tom/dev/sparrow/pkg/config/file.go","line":91},"msg":"Successfully got local runtime configuration"}
puffitos commented 4 months ago

Thanks, I'll change those to tickers. This is the price of trusting your tests too much...