server,cmd: fix error handling

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-07-19 20:37:49 +02:00 committed by Mrunal Patel
parent 90a446e2a5
commit 713bbabc61
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"os" "os"
@ -45,7 +46,7 @@ var runtimeVersionCommand = cli.Command{
// Set up a connection to the server. // Set up a connection to the server.
conn, err := grpc.Dial(address, grpc.WithInsecure()) conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil { if err != nil {
log.Fatalf("Failed to connect: %v", err) return fmt.Errorf("Failed to connect: %v", err)
} }
defer conn.Close() defer conn.Close()
client := pb.NewRuntimeServiceClient(conn) client := pb.NewRuntimeServiceClient(conn)
@ -54,9 +55,8 @@ var runtimeVersionCommand = cli.Command{
version := "v1alpha1" version := "v1alpha1"
err = Version(client, version) err = Version(client, version)
if err != nil { if err != nil {
log.Fatalf("Getting the runtime version failed: %v", err) return fmt.Errorf("Getting the runtime version failed: %v", err)
} }
return nil return nil
}, },
} }

View file

@ -17,14 +17,14 @@ func (s *Server) Version(ctx context.Context, req *pb.VersionRequest) (*pb.Versi
version, err := getGPRCVersion() version, err := getGPRCVersion()
if err != nil { if err != nil {
return nil, nil return nil, err
} }
runtimeName := "runc" runtimeName := "runc"
runtimeVersion, err := execRuncVersion("runc", "-v") runtimeVersion, err := execRuncVersion("runc", "-v")
if err != nil { if err != nil {
return nil, nil return nil, err
} }
runtimeApiVersion := "v1alpha1" runtimeApiVersion := "v1alpha1"