-
Notifications
You must be signed in to change notification settings - Fork 242
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
Zap logger in CNI does not log the store lock related logs #2148
Conversation
b6e1d49
to
805c7b7
Compare
@@ -197,7 +198,7 @@ func (kvs *jsonFileStore) Lock(timeout time.Duration) error { | |||
return errors.Wrap(err, "processLock acquire error") | |||
} | |||
|
|||
log.Printf("Acquired process lock with timeout value of %v ", timeout) | |||
log.Logger.Info("Acquired process lock with value of ", zap.Duration("timeout", timeout)) |
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.
can it be like previous message "Acquired process lock with timeout value of"
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.
The message should just be Acquired process lock
. The rest of the context is provided by the zap parameter.
@@ -82,7 +83,7 @@ func (kvs *jsonFileStore) Read(key string, value interface{}) error { | |||
} | |||
|
|||
if len(b) == 0 { | |||
log.Printf("Unable to read file %s, was empty", kvs.fileName) | |||
log.Logger.Info("Unable to read was empty", zap.String("file", kvs.fileName)) |
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.
- This sentence reads a bit odd. Should just be
File is empty
. - Should be logged as an error. Does
Logger
have anError
method?
@@ -222,7 +223,7 @@ func (kvs *jsonFileStore) GetModificationTime() (time.Time, error) { | |||
|
|||
info, err := os.Stat(kvs.fileName) | |||
if err != nil { | |||
log.Printf("os.stat() for file %v failed: %v", kvs.fileName, err) | |||
log.Logger.Error("os.stat() for", zap.String("file", kvs.fileName), zap.Error(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.
Message should be Could not get file info
.
@@ -232,7 +233,7 @@ func (kvs *jsonFileStore) GetModificationTime() (time.Time, error) { | |||
func (kvs *jsonFileStore) Remove() { | |||
kvs.Mutex.Lock() | |||
if err := os.Remove(kvs.fileName); err != nil { | |||
log.Errorf("could not remove file %s. Error: %v", kvs.fileName, err) | |||
log.Logger.Error("could not remove", zap.String("file", kvs.fileName), zap.Error(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.
Could not remove file
0d8fa8d
to
3a8b8a2
Compare
use this PR #2231 to track this issue |
Reason for Change:
Some of the log messages that are related to Store packages such as "Acquiring lock", "release lock" or the related error msgs within the store package are not getting logged in CNI ZAP
Issue Fixed:
Example Linux Logs:
2023/08/15 20:46:09 [3142512] Released process lock
2023/08/15 20:46:38 [3143037] Acquiring process lock
2023/08/15 20:46:38 [3143037] Acquired process lock with timeout value of 10s
2023/08/15 20:46:38 [3143052] Released process lock
{"level":"info","ts":"2023-08-15T21:19:28.289Z","msg":"Acquiring process lock","pid":3184054}
{"level":"info","ts":"2023-08-15T21:19:28.289Z","msg":"Acquired process lock with value of ","pid":3184054,"timeout":10}
Example Windows Logs:
{"level":"info","ts":"2023-08-15T21:12:03.248Z","msg":"Acquiring process lock","pid":18144}
{"level":"info","ts":"2023-08-15T21:12:03.735Z","msg":"Acquired process lock with value of ","pid":17908,"timeout":60}
{"level":"info","ts":"2023-08-15T21:12:04.051Z","msg":"Released process lock","pid":17908}
Requirements:
Notes: