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

enhance: add more log for creating new objects #1450

Merged
merged 1 commit into from
Jun 3, 2018
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
2 changes: 2 additions & 0 deletions apis/server/container_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (s *Server) createContainer(ctx context.Context, rw http.ResponseWriter, re
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("container", config)

name := req.FormValue("name")

// to do compensation to potential nil pointer after validation
Expand Down
2 changes: 2 additions & 0 deletions apis/server/network_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (s *Server) createNetwork(ctx context.Context, rw http.ResponseWriter, req
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("network", config)

network, err := s.NetworkMgr.Create(ctx, *config)
if err != nil {
return err
Expand Down
11 changes: 11 additions & 0 deletions apis/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"encoding/json"
"fmt"
"io"

Expand Down Expand Up @@ -90,3 +91,13 @@ func writeLogStream(ctx context.Context, w io.Writer, tty bool, opt *types.Conta
}
}
}

// logCreateOptions will print create args in pouchd logs for debugging.
func logCreateOptions(objType string, config interface{}) {
args, err := json.Marshal(config)
if err != nil {
logrus.Errorf("failed to marsal config for %s: %v", objType, err)
} else {
logrus.Infof("create %s with args: %v", objType, string(args))
}
}
2 changes: 2 additions & 0 deletions apis/server/volume_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("volume", config)

name := config.Name
driver := config.Driver
options := config.DriverOpts
Expand Down