-
Notifications
You must be signed in to change notification settings - Fork 77
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
add agent sidecar flame for implementation #404
Conversation
Signed-off-by: kpango <[email protected]>
Best reviewed: commit by commit
|
[WARNING] Changes in |
Codecov Report
@@ Coverage Diff @@
## master #404 +/- ##
=========================================
- Coverage 7.88% 7.71% -0.18%
=========================================
Files 356 372 +16
Lines 18380 18850 +470
=========================================
+ Hits 1450 1454 +4
- Misses 16721 17183 +462
- Partials 209 213 +4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good. Please revise several lines i pointed out. 👍
err = w.onChmod(ctx, event.Name) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fsnotify recommend to watch event and error in a different goroutine.
howeyc/fsnotify#7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read it but i couldn't found a recommendation about that.
i think it's just about "not to create a fsnotify Watcher and monitor channels in a same goroutine".
I'm considering about the race condition about init()
func when the w.w.Errors
and w.w.Events
closed simultaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry they recommend this thing in README.md
Do I have to watch the Error and Event channels in a separate goroutine?
As of now, yes. Looking into making this single-thread friendly (see howeyc #7)
and I agree with init race condition, I'll fix race condition problem about it but I think it's okay to run in different goroutine that mentioned in howeyc/fsnotify#7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as described in README.md of fsnotify, it is only needed "a separate goroutine".
we don't have to have two goroutines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a separate goroutine doesn't mean using different goroutine?
[WARNING] Changes in |
return w, nil | ||
} | ||
|
||
func (w *watch) Start(ctx context.Context) (<-chan error, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
Function 'Start' is too long (81 > 60) (funlen)
so service.StorageObserver | ||
} | ||
|
||
func New(cfg *config.Data) (r runner.Runner, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
Function 'New' is too long (76 > 60) (funlen)
"reflect" | ||
"testing" | ||
|
||
"github.com/vdaas/vald/internal/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
File is not goimports
-ed (goimports)
} | ||
|
||
func (r *run) Start(ctx context.Context) (<-chan error, error) { | ||
ech := make(chan error, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
mnd: Magic number: 5, in detected (gomnd)
pkg/agent/sidecar/service/option.go
Outdated
return nil | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
File is not goimports
-ed (goimports)
"reflect" | ||
"testing" | ||
|
||
"github.com/vdaas/vald/internal/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
File is not goimports
-ed (goimports)
2c18b64
to
6787380
Compare
[WARNING] Changes in |
} | ||
|
||
func (w *watch) Start(ctx context.Context) (<-chan error, error) { | ||
ech := make(chan error, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
mnd: Magic number: 10, in detected (gomnd)
internal/file/watch/watch.go
Outdated
handleErr(ctx, err) | ||
} | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
unreachable: unreachable code (govet)
internal/file/watch/watch.go
Outdated
} | ||
} | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
unreachable: unreachable code (govet)
"reflect" | ||
"testing" | ||
|
||
"github.com/vdaas/vald/internal/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
File is not goimports
-ed (goimports)
} | ||
d, err := timeutil.Parse(dur) | ||
if err != nil { | ||
d = time.Minute * 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
mnd: Magic number: 5, in detected (gomnd)
Signed-off-by: kpango <[email protected]>
6787380
to
d3bcfb8
Compare
[WARNING] Changes in |
func TestWithOnChmod(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
f func(ctx context.Context, name string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field f
is unused (unused)
func TestWithOnError(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
f func(ctx context.Context, err error) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field f
is unused (unused)
func TestWithOnWrite(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
f func(ctx context.Context, name string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field f
is unused (unused)
func TestWithDirs(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
dirs []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field dirs
is unused (unused)
func TestWithErrGroup(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
eg errgroup.Group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field eg
is unused (unused)
func TestWithAccessKey(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
ak string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field ak
is unused (unused)
func TestWithSecretAccessKey(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
sak string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field sak
is unused (unused)
func TestWithTimeout(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
timeout string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field timeout
is unused (unused)
func TestWithHandler(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
h rest.Handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field h
is unused (unused)
} | ||
|
||
func (o *observer) backup(ctx context.Context) (err error) { | ||
ctx, span := trace.StartSpan(ctx, "vald/agent-sidecar/service/StorageObserver.backup") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
ineffectual assignment to ctx
(ineffassign)
Signed-off-by: kpango <[email protected]>
[WARNING] Changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thanks.
Signed-off-by: kpango <[email protected]>
[WARNING] Changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
golangci
pkg/agent/sidecar/usecase/sidecard.go|137 col 2| only one cuddle assignment allowed before if statement (wsl)
pkg/agent/sidecar/usecase/sidecard.go|140 col 2| if statements should only be cuddled with assignments (wsl)
pkg/agent/sidecar/usecase/sidecard.go|147 col 2| assignments should only be cuddled with other assignments (wsl)
pkg/agent/sidecar/usecase/sidecard.go|167 col 2| return statements should not be cuddled if block has more than two lines (wsl)
pkg/agent/sidecar/usecase/sidecard.go|178 col 2| return statements should not be cuddled if block has more than two lines (wsl)
pkg/agent/sidecar/usecase/sidecard_test.go|38 col 2| declarations should never be cuddled (wsl)
pkg/agent/sidecar/usecase/sidecard_test.go|54 col 3| if statements should only be cuddled with assignments (wsl)
pkg/agent/sidecar/usecase/sidecard_test.go|237 col 3| if statements should only be cuddled with assignments (wsl)
pkg/agent/sidecar/usecase/sidecard.go|17 col 1| ST1000: at least one file in a package should have a package comment (stylecheck)
internal/file/watch/watch.go|94 col 1| cognitive complexity 54 of func (*watch).Start
is high (> 30) (gocognit)
func TestWithBackupDuration(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
dur string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field dur
is unused (unused)
type test struct { | ||
name string | ||
args args | ||
want want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field want
is unused (unused)
type args struct { | ||
dur string | ||
} | ||
type want struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
type want
is unused (unused)
func TestWithDirs(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
dirs []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field dirs
is unused (unused)
func TestWithBackupDurationLimit(t *testing.T) { | ||
type T = interface{} | ||
type args struct { | ||
dur string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
field dur
is unused (unused)
service.WithBackupDurationLimit(cfg.AgentSidecar.AutoBackupDurationLimit), | ||
service.WithDirs(cfg.AgentSidecar.WatchPaths...), | ||
) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
only one cuddle assignment allowed before if statement (wsl)
if err != nil { | ||
return nil, err | ||
} | ||
g := handler.New(handler.WithStorageObserver(so)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
assignments should only be cuddled with other assignments (wsl)
if r.observability != nil { | ||
return r.observability.PreStart(ctx) | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
return statements should not be cuddled if block has more than two lines (wsl)
|
||
func (r *run) Start(ctx context.Context) (<-chan error, error) { | ||
ech := make(chan error, 5) | ||
var soech, sech, oech <-chan error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
declarations should never be cuddled (wsl)
func (r *run) Start(ctx context.Context) (<-chan error, error) { | ||
ech := make(chan error, 5) | ||
var soech, sech, oech <-chan error | ||
var err error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golangci] reported by reviewdog 🐶
declarations should never be cuddled (wsl)
Signed-off-by: kpango [email protected]
Description:
We decided to implement blob storage backup functionality.
so, I added a prototype of agent sidecar flame, @rinx please implement backup logic after this PR merged.
Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: