Repository navigation
klient: rework logging - #8947
Conversation
fc8476d to
0b0acb3
Compare
| userPublicKey: credentials.kloud.userPublicKey | ||
| userPrivateKey: credentials.kloud.userPrivateKey | ||
|
|
||
| keygenAccessKey: credentials.kloud.gatewayAccessKey |
There was a problem hiding this comment.
we could change the var name in configs too for the sake of consistency
0b0acb3 to
8b1c968
Compare
| var req *UploadRequest | ||
|
|
||
| switch n, v, _ := reflect.Select(cases); n { | ||
| case 0: |
There was a problem hiding this comment.
why we need to select our cases with a reflected channel selection?
There was a problem hiding this comment.
Do be able to select on dynamic number of channels.
Alternative would be something like:
tickers := []*time.Ticker{}
...
loop:
for {
for _, i := range rand.Perm(len(tickers)) {
switch {
case <-tickers[i].C:
// ...
// handling here
// ...
continue loop
default:
continue
}
}
}I find the reflect more readable & simpler (and more performant, the above will busy wait instead of yielding to gosched, as reflect.Select does).
There was a problem hiding this comment.
i think another way to do that could be
for {
select {
case <-up.close:
return
case req := <-up.req:
go func() {
t := time.NewTicker(req.Interval)
for {
select {
case <-up.close:
t.Stop()
return
case <-t.C:
// do your magic here
}
}
}()
// do your magic here, for the first time
}
}
There was a problem hiding this comment.
Also please check if the files are already listened/watched by another ticker, multiple requests to kite.upload logs could result in multiple tickers
There was a problem hiding this comment.
Also would work, but I don't like starting additional goroutines for something, that could be done in one. In my opinion it's easier to reason about concurrency and do not worry about leaking goroutines.
Your call, if you find it easier to read I can rework reflect.Select to multiple goroutines. :-)
There was a problem hiding this comment.
Also please check if the files are already listened/watched by another ticker
done in ee06999
There was a problem hiding this comment.
I think we have different takes on readability :)
Since you said "your call" lets change it to non-reflected version not to fiddle with the runtime memory 🙋
71eef54 to
ee06999
Compare
|
LGTM |
854f83c to
d378695
Compare
d933368 to
09bdb7f
Compare
|
👍, LGTM |
Since the final key is generated by logrotate depending on the part sequence number, we need to pass the effective url down from logrotate. This PR reworks whole call chain to get the url in uploader package.
In debug mode the are a lot of lines like: 2016-09-10T07:39:07.65Z DEBUG [tunnelclient ][PID:69307][logging/context.go:53] [transport] Opening a new stream from server session Which are >128 characters. This makes logrotate errornously no rotating log files. Increasing the checksum size 256 fixes the problem.
8289166 to
11addde
Compare
deps: #8904This PR reworks logging in klient, making it possible to upload arbitrary log files from remote machines using keygen and logrotate packages. Please take a look.
This PR also adds "log.upload" method to klient kite, which allows for adding e.g.
kd uploadcommand if needed. /cc @leeola