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

cleanup redundant logs in cns savestate-file, createorUpdateNetworkCo… #2442

Merged
merged 3 commits into from
Dec 19, 2023
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: 1 addition & 2 deletions cns/restserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,9 @@ func (service *HTTPRestService) getHomeAz(w http.ResponseWriter, r *http.Request
}

func (service *HTTPRestService) createOrUpdateNetworkContainer(w http.ResponseWriter, r *http.Request) {
logger.Printf("[Azure CNS] createOrUpdateNetworkContainer")

var req cns.CreateNetworkContainerRequest
if err := service.Listener.Decode(w, r, &req); err != nil {
logger.Errorf("[Azure CNS] could not decode request: %v", err)
w.WriteHeader(http.StatusBadRequest)
return
}
Expand Down
10 changes: 3 additions & 7 deletions cns/restserver/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ func (service *HTTPRestService) removeNetworkInfo(networkName string) {

// saveState writes CNS state to persistent store.
func (service *HTTPRestService) saveState() error {
logger.Printf("[Azure CNS] saveState")

// Skip if a store is not provided.
if service.store == nil {
logger.Printf("[Azure CNS] store not initialized.")
logger.Printf("[Azure CNS] store not initialized.")
return nil
}

// Update time stamp.
service.state.TimeStamp = time.Now()
err := service.store.Write(storeKey, &service.state)
if err == nil {
logger.Printf("[Azure CNS] State saved successfully.\n")
} else {
logger.Errorf("[Azure CNS] Failed to save state., err:%v\n", err)
if err != nil {
logger.Errorf("[Azure CNS] Failed to save state, err: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we don't need to log an error in this method if we're returning it and the caller can log it instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this method saveState() there are quite a few usages (~13) & all of them do not log the error currently, may require some work there probably we can address in next PR

}

return err
Expand Down