From 3000ef07c17d653a6ec48d14cde135e6fa07b723 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 11 Sep 2015 10:20:36 -0700 Subject: [PATCH 1/4] Added logging to server startup so we can see where it fails --- nomad/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nomad/server.go b/nomad/server.go index 135530f60..898a25de3 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -181,27 +181,35 @@ func NewServer(config *Config) (*Server, error) { // Initialize the RPC layer // TODO: TLS... + log.Printf("[DEBUG] nomad: starting RPC layer") if err := s.setupRPC(nil); err != nil { s.Shutdown() + log.Printf("[ERROR] nomad: failed to start RPC layer: %s", err) return nil, fmt.Errorf("Failed to start RPC layer: %v", err) } // Initialize the Raft server + log.Printf("[DEBUG] nomad: starting Raft") if err := s.setupRaft(); err != nil { s.Shutdown() + log.Printf("[ERROR] nomad: failed to start Raft: %s", err) return nil, fmt.Errorf("Failed to start Raft: %v", err) } // Initialize the wan Serf + log.Printf("[DEBUG] nomad: starting serf WAN") s.serf, err = s.setupSerf(config.SerfConfig, s.eventCh, serfSnapshot) if err != nil { s.Shutdown() + log.Printf("[ERROR] nomad: failed to start serf WAN: %s", err) return nil, fmt.Errorf("Failed to start serf: %v", err) } // Intialize the scheduling workers + log.Printf("[DEBUG] nomad: starting workers") if err := s.setupWorkers(); err != nil { s.Shutdown() + log.Printf("[ERROR] nomad: failed to start workers: %s", err) return nil, fmt.Errorf("Failed to start workers: %v", err) } From 6ea318cacb31ed7644d9eed693b0d4bc7475de18 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 11 Sep 2015 10:23:53 -0700 Subject: [PATCH 2/4] Change to use the logger instance defined earlier --- nomad/server.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nomad/server.go b/nomad/server.go index 898a25de3..4ab565085 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -181,35 +181,35 @@ func NewServer(config *Config) (*Server, error) { // Initialize the RPC layer // TODO: TLS... - log.Printf("[DEBUG] nomad: starting RPC layer") + logger.Printf("[DEBUG] nomad: starting RPC layer") if err := s.setupRPC(nil); err != nil { s.Shutdown() - log.Printf("[ERROR] nomad: failed to start RPC layer: %s", err) + logger.Printf("[ERROR] nomad: failed to start RPC layer: %s", err) return nil, fmt.Errorf("Failed to start RPC layer: %v", err) } // Initialize the Raft server - log.Printf("[DEBUG] nomad: starting Raft") + logger.Printf("[DEBUG] nomad: starting Raft") if err := s.setupRaft(); err != nil { s.Shutdown() - log.Printf("[ERROR] nomad: failed to start Raft: %s", err) + logger.Printf("[ERROR] nomad: failed to start Raft: %s", err) return nil, fmt.Errorf("Failed to start Raft: %v", err) } // Initialize the wan Serf - log.Printf("[DEBUG] nomad: starting serf WAN") + logger.Printf("[DEBUG] nomad: starting serf WAN") s.serf, err = s.setupSerf(config.SerfConfig, s.eventCh, serfSnapshot) if err != nil { s.Shutdown() - log.Printf("[ERROR] nomad: failed to start serf WAN: %s", err) + logger.Printf("[ERROR] nomad: failed to start serf WAN: %s", err) return nil, fmt.Errorf("Failed to start serf: %v", err) } // Intialize the scheduling workers - log.Printf("[DEBUG] nomad: starting workers") + logger.Printf("[DEBUG] nomad: starting workers") if err := s.setupWorkers(); err != nil { s.Shutdown() - log.Printf("[ERROR] nomad: failed to start workers: %s", err) + logger.Printf("[ERROR] nomad: failed to start workers: %s", err) return nil, fmt.Errorf("Failed to start workers: %v", err) } From 39feffd67fbc2de35f172bf8e761b035275247fc Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 11 Sep 2015 10:24:52 -0700 Subject: [PATCH 3/4] Change debug to info --- nomad/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nomad/server.go b/nomad/server.go index 4ab565085..84e87846b 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -181,7 +181,7 @@ func NewServer(config *Config) (*Server, error) { // Initialize the RPC layer // TODO: TLS... - logger.Printf("[DEBUG] nomad: starting RPC layer") + logger.Printf("[INFO] nomad: starting RPC layer") if err := s.setupRPC(nil); err != nil { s.Shutdown() logger.Printf("[ERROR] nomad: failed to start RPC layer: %s", err) @@ -189,7 +189,7 @@ func NewServer(config *Config) (*Server, error) { } // Initialize the Raft server - logger.Printf("[DEBUG] nomad: starting Raft") + logger.Printf("[INFO] nomad: starting Raft") if err := s.setupRaft(); err != nil { s.Shutdown() logger.Printf("[ERROR] nomad: failed to start Raft: %s", err) @@ -197,7 +197,7 @@ func NewServer(config *Config) (*Server, error) { } // Initialize the wan Serf - logger.Printf("[DEBUG] nomad: starting serf WAN") + logger.Printf("[INFO] nomad: starting serf WAN") s.serf, err = s.setupSerf(config.SerfConfig, s.eventCh, serfSnapshot) if err != nil { s.Shutdown() @@ -206,7 +206,7 @@ func NewServer(config *Config) (*Server, error) { } // Intialize the scheduling workers - logger.Printf("[DEBUG] nomad: starting workers") + logger.Printf("[INFO] nomad: starting workers") if err := s.setupWorkers(); err != nil { s.Shutdown() logger.Printf("[ERROR] nomad: failed to start workers: %s", err) From da93d4a30fe45a3a3a576bc8634795719e24075b Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 11 Sep 2015 10:26:33 -0700 Subject: [PATCH 4/4] Change error to err to be consistent with other usage --- client/driver/docker.go | 16 ++++++++-------- client/driver/qemu.go | 2 +- nomad/server.go | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index 514d33db6..0a7b000fd 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -138,7 +138,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle // Download the image pull, err := exec.Command("docker", "pull", image).CombinedOutput() if err != nil { - d.logger.Printf("[ERROR] driver.docker: pulling container %s", pull) + d.logger.Printf("[ERR] driver.docker: pulling container %s", pull) return nil, fmt.Errorf("Failed to pull `%s`: %s", image, err) } d.logger.Printf("[DEBUG] driver.docker: docker pull %s:\n%s", image, pull) @@ -148,7 +148,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle imageIDBytes, err := exec.Command("docker", "images", "-q", "--no-trunc", image).CombinedOutput() imageID := strings.TrimSpace(string(imageIDBytes)) if err != nil || imageID == "" { - d.logger.Printf("[ERROR] driver.docker: getting image id %s", imageID) + d.logger.Printf("[ERR] driver.docker: getting image id %s", imageID) return nil, fmt.Errorf("Failed to determine image id for `%s`: %s", image, err) } if !reDockerSha.MatchString(imageID) { @@ -160,7 +160,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle // Create a container container, err := client.CreateContainer(containerOptionsForTask(task, d.logger)) if err != nil { - d.logger.Printf("[ERROR] driver.docker: %s", err) + d.logger.Printf("[ERR] driver.docker: %s", err) return nil, fmt.Errorf("Failed to create container from image %s", image) } if !reDockerSha.MatchString(container.ID) { @@ -171,7 +171,7 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle // Start the container startBytes, err := exec.Command("docker", "start", container.ID).CombinedOutput() if err != nil { - d.logger.Printf("[ERROR] driver.docker: starting container %s", strings.TrimSpace(string(startBytes))) + d.logger.Printf("[ERR] driver.docker: starting container %s", strings.TrimSpace(string(startBytes))) return nil, fmt.Errorf("Failed to start container %s", container.ID) } d.logger.Printf("[INFO] driver.docker: started container %s", container.ID) @@ -230,7 +230,7 @@ func (h *dockerHandle) ID() string { } data, err := json.Marshal(pid) if err != nil { - h.logger.Printf("[ERROR] driver.docker: failed to marshal docker PID to JSON: %s", err) + h.logger.Printf("[ERR] driver.docker: failed to marshal docker PID to JSON: %s", err) } return fmt.Sprintf("DOCKER:%s", string(data)) } @@ -249,7 +249,7 @@ func (h *dockerHandle) Kill() error { // Stop the container stop, err := exec.Command("docker", "stop", "-t", "5", h.containerID).CombinedOutput() if err != nil { - log.Printf("[ERROR] driver.docker: stopping container %s", stop) + log.Printf("[ERR] driver.docker: stopping container %s", stop) return fmt.Errorf("Failed to stop container %s: %s", h.containerID, err) } log.Printf("[INFO] driver.docker: stopped container %s", h.containerID) @@ -257,7 +257,7 @@ func (h *dockerHandle) Kill() error { // Cleanup container rmContainer, err := exec.Command("docker", "rm", h.containerID).CombinedOutput() if err != nil { - log.Printf("[ERROR] driver.docker: removing container %s", rmContainer) + log.Printf("[ERR] driver.docker: removing container %s", rmContainer) return fmt.Errorf("Failed to remove container %s: %s", h.containerID, err) } log.Printf("[INFO] driver.docker: removed container %s", h.containerID) @@ -277,7 +277,7 @@ func (h *dockerHandle) run() { // Wait for it... waitBytes, err := exec.Command("docker", "wait", h.containerID).Output() if err != nil { - h.logger.Printf("[ERROR] driver.docker: unable to wait for %s; container already terminated", h.containerID) + h.logger.Printf("[ERR] driver.docker: unable to wait for %s; container already terminated", h.containerID) } wait := strings.TrimSpace(string(waitBytes)) diff --git a/client/driver/qemu.go b/client/driver/qemu.go index e4dff2696..0a57bbda2 100644 --- a/client/driver/qemu.go +++ b/client/driver/qemu.go @@ -235,7 +235,7 @@ func (h *qemuHandle) ID() string { } data, err := json.Marshal(pid) if err != nil { - log.Printf("[ERROR] failed to marshal Qemu PID to JSON: %s", err) + log.Printf("[ERR] failed to marshal Qemu PID to JSON: %s", err) } return fmt.Sprintf("QEMU:%s", string(data)) } diff --git a/nomad/server.go b/nomad/server.go index 84e87846b..f94e2d7c5 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -184,7 +184,7 @@ func NewServer(config *Config) (*Server, error) { logger.Printf("[INFO] nomad: starting RPC layer") if err := s.setupRPC(nil); err != nil { s.Shutdown() - logger.Printf("[ERROR] nomad: failed to start RPC layer: %s", err) + logger.Printf("[ERR] nomad: failed to start RPC layer: %s", err) return nil, fmt.Errorf("Failed to start RPC layer: %v", err) } @@ -192,7 +192,7 @@ func NewServer(config *Config) (*Server, error) { logger.Printf("[INFO] nomad: starting Raft") if err := s.setupRaft(); err != nil { s.Shutdown() - logger.Printf("[ERROR] nomad: failed to start Raft: %s", err) + logger.Printf("[ERR] nomad: failed to start Raft: %s", err) return nil, fmt.Errorf("Failed to start Raft: %v", err) } @@ -201,7 +201,7 @@ func NewServer(config *Config) (*Server, error) { s.serf, err = s.setupSerf(config.SerfConfig, s.eventCh, serfSnapshot) if err != nil { s.Shutdown() - logger.Printf("[ERROR] nomad: failed to start serf WAN: %s", err) + logger.Printf("[ERR] nomad: failed to start serf WAN: %s", err) return nil, fmt.Errorf("Failed to start serf: %v", err) } @@ -209,7 +209,7 @@ func NewServer(config *Config) (*Server, error) { logger.Printf("[INFO] nomad: starting workers") if err := s.setupWorkers(); err != nil { s.Shutdown() - logger.Printf("[ERROR] nomad: failed to start workers: %s", err) + logger.Printf("[ERR] nomad: failed to start workers: %s", err) return nil, fmt.Errorf("Failed to start workers: %v", err) }