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

[patch] Add warn logging messages to agent-sidecar & ignore io.EOF error when reading metadata.json #608

Merged
merged 4 commits into from
Aug 3, 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
3 changes: 2 additions & 1 deletion pkg/agent/internal/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package metadata

import (
"io"
"os"

"github.com/vdaas/vald/internal/encoding/json"
Expand Down Expand Up @@ -46,7 +47,7 @@ func Load(path string) (*Metadata, error) {

var meta Metadata
err = json.Decode(f, &meta)
if err != nil {
if err != nil && err != io.EOF {
return nil, err
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/agent/sidecar/service/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (o *observer) PostStop(ctx context.Context) (err error) {
backup := func() error {
metadata, err := metadata.Load(o.metadataPath)
if err != nil {
log.Warn("cannot read metadata of the backup files:", err)
return err
}

Expand Down Expand Up @@ -247,6 +248,7 @@ func (o *observer) startTicker(ctx context.Context) (<-chan error, error) {
case <-ct.C:
metadata, err := metadata.Load(o.metadataPath)
if err != nil {
log.Warn("cannot read metadata of the backup files:", err)
ech <- err
continue
}
Expand Down Expand Up @@ -324,6 +326,7 @@ func (o *observer) onWrite(ctx context.Context, name string) error {

ok, err := o.isValidMetadata()
if err != nil {
log.Warn("cannot read metadata of the backup files:", err)
return err
}

Expand All @@ -348,6 +351,7 @@ func (o *observer) onCreate(ctx context.Context, name string) error {

ok, err := o.isValidMetadata()
if err != nil {
log.Warn("cannot read metadata of the backup files:", err)
return err
}

Expand Down