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

[bugfix] fix agent sidecar behavior when index files are updated #598

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pkg/agent/sidecar/service/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ func (o *observer) onWrite(ctx context.Context, name string) error {
}
}()

ok, err := o.isValidMetadata(name)
if name != o.metadataPath {
return nil
}

ok, err := o.isValidMetadata()
if err != nil {
return err
}
Expand All @@ -338,7 +342,11 @@ func (o *observer) onCreate(ctx context.Context, name string) error {
}
}()

ok, err := o.isValidMetadata(name)
if name != o.metadataPath {
return nil
}

ok, err := o.isValidMetadata()
if err != nil {
return err
}
Expand All @@ -350,11 +358,7 @@ func (o *observer) onCreate(ctx context.Context, name string) error {
return o.terminate()
}

func (o *observer) isValidMetadata(name string) (bool, error) {
if name != o.metadataPath {
return false, nil
}

func (o *observer) isValidMetadata() (bool, error) {
metadata, err := metadata.Load(o.metadataPath)
if err != nil {
return false, err
Expand Down
5 changes: 1 addition & 4 deletions pkg/agent/sidecar/service/observer/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ func Test_observer_onCreate(t *testing.T) {

func Test_observer_isValidMetadata(t *testing.T) {
type args struct {
name string
}
type fields struct {
w watch.Watcher
Expand Down Expand Up @@ -887,7 +886,6 @@ func Test_observer_isValidMetadata(t *testing.T) {
{
name: "test_case_1",
args: args {
name: "",
},
fields: fields {
w: nil,
Expand All @@ -912,7 +910,6 @@ func Test_observer_isValidMetadata(t *testing.T) {
return test {
name: "test_case_2",
args: args {
name: "",
},
fields: fields {
w: nil,
Expand Down Expand Up @@ -958,7 +955,7 @@ func Test_observer_isValidMetadata(t *testing.T) {
ch: test.fields.ch,
}

got, err := o.isValidMetadata(test.args.name)
got, err := o.isValidMetadata()
if err := test.checkFunc(test.want, got, err); err != nil {
tt.Errorf("error = %v", err)
}
Expand Down