-
Notifications
You must be signed in to change notification settings - Fork 78
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] bugfix: do not create metadata file when create/append flag is not set for the agent/agent-sidecar #904
[patch] bugfix: do not create metadata file when create/append flag is not set for the agent/agent-sidecar #904
Conversation
[CHATOPS:HELP] ChatOps commands.
|
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.
SGTM. please check it by e2e testing.
Codecov Report
@@ Coverage Diff @@
## master #904 +/- ##
==========================================
+ Coverage 19.19% 19.23% +0.04%
==========================================
Files 422 423 +1
Lines 19548 19622 +74
==========================================
+ Hits 3752 3775 +23
- Misses 15586 15631 +45
- Partials 210 216 +6
Continue to review full report at Codecov.
|
please check internal testing error. |
@@ -170,12 +170,26 @@ func (n *ngt) initNGT(opts ...core.Option) (err error) { | |||
n.core, err = core.New(opts...) | |||
return err | |||
} | |||
if os.IsPermission(err) { |
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 🐶
if statements should only be cuddled with assignments (wsl)
@@ -170,12 +170,26 @@ func (n *ngt) initNGT(opts ...core.Option) (err error) { | |||
n.core, err = core.New(opts...) | |||
return err | |||
} | |||
if os.IsPermission(err) { | |||
log.Debugf("no permission for index path,\tpath: %s,\terr: %v", n.path, err) | |||
return err |
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 with no blank line before (nlreturn)
|
||
log.Debugf("load index from %s", n.path) | ||
|
||
agentMetadata, err := metadata.Load(filepath.Join(n.path, metadata.AgentMetadataFileName)) | ||
if err != nil { | ||
log.Warnf("cannot read metadata from %s: %s", metadata.AgentMetadataFileName, err) | ||
|
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 think we should check metadata.Load's err is os.IsNotExists or not, if err is os.ErrNotExists we can check kvsdb exsitance.
func Load(path string) (*Metadata, error) { | ||
func Load(path string) (meta *Metadata, err error) { | ||
var fi os.FileInfo | ||
if fi, err = os.Stat(path); 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 🐶
if statements should only be cuddled with assignments used in the if statement itself (wsl)
/rebase |
[REBASE] Rebase triggered by kevindiu for branch: bugfix/agent-sidecar/empty-metadata-file-opened |
ee2cfc2
to
83835bb
Compare
@@ -38,20 +39,27 @@ type NGT struct { | |||
IndexCount uint64 `json:"index_count" yaml:"index_count"` | |||
} | |||
|
|||
func Load(path string) (*Metadata, error) { | |||
func Load(path string) (meta *Metadata, 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 🐶
exported function Load
should have comment or be unexported (golint)
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 👍
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
Description:
This PR fix a bug when the agent sidecar try to open the
metadata.json
file and if the file is not exists, the empty file will be created and causing agent failed to start.Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: