From bc6a3f65f9ffa725fd0042acea0a280c0cdeb4f1 Mon Sep 17 00:00:00 2001 From: Andrew Chiw Date: Tue, 22 Dec 2020 14:12:28 +0100 Subject: [PATCH] logging: change Fatal* to Error*, and ensure that return err always executes directly after a log.Error. Exception: utils.go:ExtractGzip() --- cmd/events.go | 12 ++++----- cmd/serve.go | 4 +-- pkg/lctrld/common.go | 2 +- pkg/lctrld/docker.go | 58 ++++++++++++++++++++++--------------------- pkg/lctrld/lctrld.go | 26 +++++++++---------- pkg/lctrld/payload.go | 51 ++++++++++++++++++------------------- pkg/server/web.go | 10 ++++---- pkg/utils/utils.go | 12 ++++----- 8 files changed, 89 insertions(+), 86 deletions(-) diff --git a/cmd/events.go b/cmd/events.go index a8c827e..ed3bb89 100644 --- a/cmd/events.go +++ b/cmd/events.go @@ -79,19 +79,19 @@ func setupEvent(cmd *cobra.Command, args []string) (err error) { fmt.Println("Here we go!!") err = lctrld.CreateEvent(settings, evt) if err != nil { - log.Fatal("There was an error, run the command with --debug for more info:", err) + log.Error("There was an error, run the command with --debug for more info:", err) return err } dmc := lctrld.NewDockerMachineConfig(settings, evt.ID()) err = lctrld.Provision(settings, evt, lctrld.RunCommand, dmc) if err != nil { - log.Fatal("There was an error, run the command with --debug for more info:", err) + log.Error("There was an error, run the command with --debug for more info:", err) return err } err = lctrld.StoreEvent(settings, evt) if err != nil { - log.Fatal("There was a problem saving the updated Event", err) + log.Error("There was a problem saving the updated Event", err) return err } fmt.Println("Operation completed in", time.Since(start)) @@ -113,12 +113,12 @@ func tearDownEvent(cmd *cobra.Command, args []string) (err error) { start := time.Now() evt, err := lctrld.LoadEvent(settings, args[0]) if err != nil { - log.Fatal("There was an error shutting down the event: ", err) + log.Error("There was an error shutting down the event: ", err) return err } err = lctrld.DestroyEvent(settings, evt, lctrld.RunCommand) if err != nil { - log.Fatal("There was an error shutting down the event: ", err) + log.Error("There was an error shutting down the event: ", err) return err } fmt.Println("Operation completed in", time.Since(start)) @@ -177,7 +177,7 @@ func retryEvent(cmd *cobra.Command, args []string) (err error) { log.Infof("Updated info for %s: %#v\n", v, evt2.State[v]) } if err != nil { - log.Fatal("There was a problem saving the updated Event", err) + log.Error("There was a problem saving the updated Event", err) return } return diff --git a/cmd/serve.go b/cmd/serve.go index 0621940..a7cf1f7 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -1,7 +1,7 @@ package cmd import ( - "log" + log "github.com/sirupsen/logrus" "github.com/apeunit/LaunchControlD/pkg/server" "github.com/spf13/cobra" @@ -20,6 +20,6 @@ func init() { func serve(cmd *cobra.Command, args []string) { if err := server.ServeHTTP(settings); err != nil { - log.Fatal(err) + log.Error(err) } } diff --git a/pkg/lctrld/common.go b/pkg/lctrld/common.go index 212f7c6..56a15a8 100644 --- a/pkg/lctrld/common.go +++ b/pkg/lctrld/common.go @@ -93,7 +93,7 @@ func RunCommand(bin string, args, envVars []string) (out string, err error) { // execute the command o, err := cmd.CombinedOutput() if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", bin, args, err, string(o)) + log.Errorf("%s %s failed with %s, %s\n", bin, args, err, string(o)) return } out = strings.TrimSpace(string(o)) diff --git a/pkg/lctrld/docker.go b/pkg/lctrld/docker.go index 65d81b8..2ec11eb 100644 --- a/pkg/lctrld/docker.go +++ b/pkg/lctrld/docker.go @@ -16,7 +16,7 @@ func InspectEvent(settings config.Schema, evt *model.Event, cmdRunner CommandRun path, err := evts(settings, evt.ID()) log.Debugln("InspectEvent event", evt.ID(), "home:", path) if err != nil { - log.Fatal("Inspect failed:", err) + log.Error("Inspect failed:", err) return } dmBin := dmBin(settings) @@ -156,8 +156,8 @@ func RereadDockerMachineInfo(settings config.Schema, evt *model.Event, dmc Docke for i, v := range validatorAccounts { mc, err := dmc.ReadConfig(fmt.Sprint(i)) if err != nil { - log.Fatal("Provision read machine config error:", err) - break + log.Error("Provision read machine config error:", err) + return nil, err } evt.State[v.Name] = mc } @@ -173,40 +173,40 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu for name, state := range evt.State { envVars, err := dockerMachineEnv(settings, evt) if err != nil { - log.Fatalf("dockerMachineEnv() failed while generating envVars: %s", err) - break + log.Errorf("dockerMachineEnv() failed while generating envVars: %s", err) + return err } // docker-machine ssh mkdir -p /home/docker/nodeconfig args := []string{"ssh", state.ID(), "mkdir", "-p", "/home/docker/nodeconfig"} _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) - break + log.Errorf("docker-machine %s failed with %s", args, err) + return err } // docker-machine scp -r pathDaemon evtx-d97517a3673688070aef-0:/home/docker/nodeconfig args = []string{"scp", "-r", evt.Accounts[name].ConfigLocation.DaemonConfigDir, fmt.Sprintf("%s:/home/docker/nodeconfig", state.ID())} _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) - break + log.Errorf("docker-machine %s failed with %s", args, err) + return err } // docker-machine scp -r pathCLI evtx-d97517a3673688070aef-0:/home/docker/nodeconfig args = []string{"scp", "-r", evt.Accounts[name].ConfigLocation.CLIConfigDir, fmt.Sprintf("%s:/home/docker/nodeconfig", state.ID())} _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) - break + log.Errorf("docker-machine %s failed with %s", args, err) + return err } // docker-machine chmod -R 777 /home/docker/nodeconfig args = []string{"ssh", state.ID(), "chmod", "-R", "777", "/home/docker/nodeconfig"} _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) - break + log.Errorf("docker-machine %s failed with %s", args, err) + return err } } @@ -214,8 +214,8 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu for email, state := range evt.State { envVars, err := dockerMachineEnv(settings, evt) if err != nil { - log.Fatalf("dockerMachineEnv() failed while generating envVars: %s", err) - break + log.Errorf("dockerMachineEnv() failed while generating envVars: %s", err) + return err } // Build the output of docker-machine -s /tmp/workspace/evts/evtx-d97517a3673688070aef/.docker/machine/ env evtx-d97517a3673688070aef-1 @@ -226,8 +226,8 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu log.Debugf("Running docker %s for validator %s machine; envVars %s\n", args, email, envVars) _, err = cmdRunner("docker", args, envVars) if err != nil { - log.Fatalf("docker %s failed with %s", args, err) - break + log.Errorf("docker %s failed with %s", args, err) + return err } } @@ -235,8 +235,8 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu for email, state := range evt.State { envVars, err := dockerMachineEnv(settings, evt) if err != nil { - log.Fatalf("dockerMachineEnv() failed while generating envVars: %s", err) - break + log.Errorf("dockerMachineEnv() failed while generating envVars: %s", err) + return err } // Build the output of docker-machine -s /tmp/workspace/evts/evtx-d97517a3673688070aef/.docker/machine/ env evtx-d97517a3673688070aef-1 @@ -247,8 +247,8 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu log.Debugf("Running docker %s for validator %s machine; envVars %s\n", args, email, envVars) _, err = cmdRunner("docker", args, envVars) if err != nil { - log.Fatalf("docker %s failed with %s", args, err) - break + log.Errorf("docker %s failed with %s", args, err) + return err } } @@ -268,7 +268,7 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu log.Debugf("Running docker-machine %s on validator %s machine; envVars %s\n", args, firstNode, envVars) _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatal(err) + log.Error(err) return } @@ -276,7 +276,7 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu // o, err = cmdRunner(dmBin, args, envVars) // log.Infoln(o) // if err != nil { - // log.Fatal(err) + // log.Error(err) // return // } @@ -286,25 +286,27 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu args = []string{"scp", "-r", faucetAccount.ConfigLocation.CLIConfigDir, fmt.Sprintf("%s:/home/docker/nodeconfig/faucet_account", evt.State[v[0]].ID())} _, err = cmdRunner("docker-machine", args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) + log.Errorf("docker-machine %s failed with %s", args, err) return } // docker-machine chmod -R 777 /home/docker/nodeconfig AGAIN - what a mess! args = []string{"ssh", evt.State[v[0]].ID(), "chmod", "-R", "777", "/home/docker/nodeconfig"} _, err = cmdRunner(dmBin, args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) + log.Errorf("docker-machine %s failed with %s", args, err) + return } evtDir, err := evts(settings, evt.ID()) if err != nil { - log.Fatal(err) + log.Error(err) + return } args = []string{"scp", "-r", filepath.Join(evtDir, "faucetconfig.yml"), fmt.Sprintf("%s:/home/docker/nodeconfig/", evt.State[v[0]].ID())} _, err = cmdRunner("docker-machine", args, envVars) if err != nil { - log.Fatalf("docker-machine %s failed with %s", args, err) + log.Errorf("docker-machine %s failed with %s", args, err) return } @@ -315,7 +317,7 @@ func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRu log.Debugf("Running docker %s on %s; envVars %s\n", args, firstValidator.ID(), envVars) _, err = cmdRunner("docker", args, envVars) if err != nil { - log.Fatalf("docker %s failed with %s", args, err) + log.Errorf("docker %s failed with %s", args, err) return } return diff --git a/pkg/lctrld/lctrld.go b/pkg/lctrld/lctrld.go index f2b915c..31e3e0f 100644 --- a/pkg/lctrld/lctrld.go +++ b/pkg/lctrld/lctrld.go @@ -18,7 +18,7 @@ func SetupWorkspace(settings config.Schema) (err error) { log.Debugln("Folder ", settings.Workspace, "does not exists, creating") err = os.MkdirAll(settings.Workspace, 0700) if err != nil { - log.Fatal("SetupWorkspace: ", err) + log.Error("SetupWorkspace: ", err) return } } @@ -29,7 +29,7 @@ func SetupWorkspace(settings config.Schema) (err error) { log.Debugln("Folder", dir, "does not exists, creating") err = os.MkdirAll(dir, 0700) if err != nil { - log.Fatal("SetupWorkspace: ", err) + log.Error("SetupWorkspace: ", err) return } } @@ -53,20 +53,20 @@ func InstallDockerMachine(settings config.Schema) (err error) { // generate a temp dir td, err := tmp(settings) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } log.Debug("InstallDockerMachine: file will be download in ", td) dwnFile, err := utils.DownloadFile(td, downloadURL) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } dwnFilePath := _path(td, dwnFile) log.Debug("InstallDockerMachine: download complete ", dwnFilePath) ct, err := utils.DetectContentType(dwnFilePath) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } log.Debug("InstallDockerMachine: downloaded file ", dwnFilePath, " has content-type ", ct) @@ -75,7 +75,7 @@ func InstallDockerMachine(settings config.Schema) (err error) { log.Debugln("InstallDockerMachine: downloaded file is binary, moving to the destination path") err = os.Rename(dwnFilePath, targetPath) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } case "application/zip": @@ -83,25 +83,25 @@ func InstallDockerMachine(settings config.Schema) (err error) { case "application/x-gzip": err = utils.ExtractGzip(dwnFilePath, td) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } err = utils.SearchAndMove(td, file, targetPath) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } default: err = fmt.Errorf("InstallDockerMachine: unsupported file type %s", ct) } if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } // make it executable os.Chmod(targetPath, 0700) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) } return } @@ -109,7 +109,7 @@ func InstallDockerMachine(settings config.Schema) (err error) { // check if the system has been setup already err = dine(settings.DockerMachine.Binary, settings.DockerMachine.BinaryURL) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } for dName, driver := range settings.DockerMachine.Drivers { @@ -120,7 +120,7 @@ func InstallDockerMachine(settings config.Schema) (err error) { } err = dine(driver.Binary, driver.BinaryURL) if err != nil { - log.Fatal("InstallDockerMachine: ", err) + log.Error("InstallDockerMachine: ", err) return } } @@ -161,7 +161,7 @@ func ListEvents(settings config.Schema) (events []model.Event, err error) { log.Debugln("Event found", info.Name()) evt, err := model.LoadEvent(subPath) if err != nil { - log.Fatal("ListEvents failed:", err) + log.Error("ListEvents failed:", err) return err } events = append(events, *evt) diff --git a/pkg/lctrld/payload.go b/pkg/lctrld/payload.go index af9a6de..5feb59b 100644 --- a/pkg/lctrld/payload.go +++ b/pkg/lctrld/payload.go @@ -108,14 +108,15 @@ func InitDaemon(settings config.Schema, evt *model.Event, runCommand CommandRunn args := []string{"init", fmt.Sprintf("%s node %s", acc.Name, machineConfig.ID()), "--home", acc.ConfigLocation.DaemonConfigDir, "--chain-id", evt.ID()} out, err := runCommand(evt.Payload.DaemonPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) return nil, err } args = []string{"tendermint", "show-node-id", "--home", acc.ConfigLocation.DaemonConfigDir} out, err = runCommand(evt.Payload.DaemonPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + return nil, err } machineConfig.TendermintNodeID = strings.TrimSuffix(out, "\n") } @@ -139,8 +140,8 @@ func GenerateKeys(settings config.Schema, evt *model.Event, runCommand CommandRu args := []string{"keys", "add", account.Name, "-o", "json", "--keyring-backend", "test", "--home", account.ConfigLocation.CLIConfigDir} out, err := runCommand(evt.Payload.CLIPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.CLIPath, args, err, out) - break + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.CLIPath, args, err, out) + return nil, err } var result map[string]interface{} @@ -162,8 +163,8 @@ func GenerateKeys(settings config.Schema, evt *model.Event, runCommand CommandRu args := []string{"keys", "add", acc.Name, "-o", "json", "--keyring-backend", "test", "--home", extraAccDir} out, err := runCommand(evt.Payload.CLIPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.CLIPath, args, err, out) - break + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.CLIPath, args, err, out) + return nil, err } var result map[string]interface{} @@ -193,8 +194,8 @@ func AddGenesisAccounts(settings config.Schema, evt *model.Event, runCommand Com args := []string{"add-genesis-account", account.Address, account.GenesisBalance, "--home", evt.Accounts[name].ConfigLocation.DaemonConfigDir} out, err := runCommand(evt.Payload.DaemonPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) - break + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + return err } } } @@ -228,8 +229,8 @@ func GenesisTxs(settings config.Schema, evt *model.Event, runCommand CommandRunn args := []string{"gentx", "--name", email, "--ip", state.Instance.IPAddress, "--amount", stakeAmount[len(stakeAmount)-1], "--home-client", evt.Accounts[email].ConfigLocation.CLIConfigDir, "--keyring-backend", "test", "--home", evt.Accounts[email].ConfigLocation.DaemonConfigDir, "--output-document", outputDocument} out, err := runCommand(evt.Payload.DaemonPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) - break + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + return err } } @@ -257,8 +258,8 @@ func CollectGenesisTxs(settings config.Schema, evt *model.Event, runCommand Comm args := []string{"collect-gentxs", "--gentx-dir", path.Join(basePath, "genesis_txs"), "--home", evt.Accounts[name].ConfigLocation.DaemonConfigDir} out, err := runCommand(evt.Payload.DaemonPath, args, envVars) if err != nil { - log.Fatalf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) - break + log.Errorf("%s %s failed with %s, %s\n", evt.Payload.DaemonPath, args, err, out) + return err } } return @@ -277,26 +278,26 @@ func EditConfigs(settings config.Schema, evt *model.Event, runCommand CommandRun node0Genesis, err := os.Open(pathToNode0Genesis) if err != nil { log.Errorf("cannot open file genesis descriptor: %s: %v", pathToNode0Genesis, err) - break + return err } otherGenesis := path.Join(valAcc.ConfigLocation.DaemonConfigDir, "config/genesis.json") log.Infof("otherGenesis: %s\n", otherGenesis) err = os.Remove(otherGenesis) if err != nil { - log.Fatalf("Removing %s failed with %s\n", otherGenesis, err) - break + log.Errorf("Removing %s failed with %s\n", otherGenesis, err) + return err } newOtherGenesis, err := os.Create(otherGenesis) if err != nil { - log.Fatalf("Creating a blank %s failed with %s\n", otherGenesis, err) - break + log.Errorf("Creating a blank %s failed with %s\n", otherGenesis, err) + return err } written, err := io.Copy(newOtherGenesis, node0Genesis) if err != nil { - log.Fatalf("Copying %s to %s failed with %s\n", pathToNode0Genesis, otherGenesis, err) - break + log.Errorf("Copying %s to %s failed with %s\n", pathToNode0Genesis, otherGenesis, err) + return err } log.Debugf("Copied %v bytes to %s", written, otherGenesis) } @@ -314,8 +315,8 @@ func EditConfigs(settings config.Schema, evt *model.Event, runCommand CommandRun configPath := path.Join(evt.Accounts[name].ConfigLocation.DaemonConfigDir, "config/config.toml") t, err := toml.LoadFile(configPath) if err != nil { - log.Fatalf("Reading toml from file %s failed with %s", configPath, err) - break + log.Errorf("Reading toml from file %s failed with %s", configPath, err) + return err } t.SetPathWithComment([]string{"p2p", "persistent_peers"}, "persistent_peers has been automatically set by lctrld", false, strings.Join(persistentPeerList, ",")) t.SetPathWithComment([]string{"rpc", "laddr"}, "laddr has been automatically set by lctrld", false, "tcp://0.0.0.0:26657") @@ -323,13 +324,13 @@ func EditConfigs(settings config.Schema, evt *model.Event, runCommand CommandRun w, err := os.Create(configPath) if err != nil { - log.Fatalf("Opening file %s in write-mode failed with %s", configPath, err) - break + log.Errorf("Opening file %s in write-mode failed with %s", configPath, err) + return err } _, err = t.WriteTo(w) if err != nil { - log.Fatalf("Writing TOML to %s failed with %s", configPath, err) - break + log.Errorf("Writing TOML to %s failed with %s", configPath, err) + return err } } return diff --git a/pkg/server/web.go b/pkg/server/web.go index 0b8b011..b4c3ba4 100644 --- a/pkg/server/web.go +++ b/pkg/server/web.go @@ -213,7 +213,7 @@ func register(c *fiber.Ctx) error { // @Success 200 {object} APIReply "API Reply" // @Router /v1/events [post] func eventCreate(c *fiber.Ctx) error { - // TODO: workaround to handle log.Fatal in lib + // TODO: workaround to handle log.Error in lib defer handlePanic(c) // retrieve the owner email @@ -272,7 +272,7 @@ func eventCreate(c *fiber.Ctx) error { // @Success 200 {object} APIEvent // @Router /v1/events/{id}/deploy [put] func eventDeploy(c *fiber.Ctx) error { - // TODO: workaround to handle log.Fatal in lib + // TODO: workaround to handle log.Error in lib defer handlePanic(c) eventID := c.Params("eventID") @@ -301,7 +301,7 @@ func eventDeploy(c *fiber.Ctx) error { // @Success 200 {object} APIEvent // @Router /v1/events/{id} [delete] func deleteEvent(c *fiber.Ctx) error { - // TODO: workaround to handle log.Fatal in lib + // TODO: workaround to handle log.Error in lib defer handlePanic(c) eventID := c.Params("eventID") @@ -329,7 +329,7 @@ func deleteEvent(c *fiber.Ctx) error { // @Success 200 {object} APIEvent // @Router /v1/events/{id} [get] func getEvent(c *fiber.Ctx) error { - // TODO: workaround to handle log.Fatal in lib + // TODO: workaround to handle log.Error in lib defer handlePanic(c) eventID := c.Params("eventID") @@ -352,7 +352,7 @@ func getEvent(c *fiber.Ctx) error { // @Success 200 {array} APIEvent // @Router /v1/events [get] func listEvents(c *fiber.Ctx) error { - // TODO: workaround to handle log.Fatal in lib + // TODO: workaround to handle log.Error in lib defer handlePanic(c) // retrieve the owner email diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7b3d205..c579fbe 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -95,7 +95,7 @@ func ExtractGzip(filePath, outFolder string) (err error) { } uncompressedStream, err := gzip.NewReader(gzipStream) if err != nil { - log.Fatal("ExtractTarGz: NewReader failed") + log.Error("ExtractTarGz: NewReader failed") } tarReader := tar.NewReader(uncompressedStream) @@ -108,25 +108,25 @@ func ExtractGzip(filePath, outFolder string) (err error) { } if err != nil { - log.Fatalf("ExtractTarGz: Next() failed: %s", err.Error()) + log.Errorf("ExtractTarGz: Next() failed: %s", err.Error()) } switch header.Typeflag { case tar.TypeDir: if err := os.Mkdir(filepath.Join(outFolder, header.Name), 0755); err != nil { - log.Fatalf("ExtractTarGz: Mkdir() failed: %s", err.Error()) + log.Errorf("ExtractTarGz: Mkdir() failed: %s", err.Error()) } case tar.TypeReg: outFile, err := os.Create(filepath.Join(outFolder, header.Name)) if err != nil { - log.Fatalf("ExtractTarGz: Create() failed: %s", err.Error()) + log.Errorf("ExtractTarGz: Create() failed: %s", err.Error()) } defer outFile.Close() if _, err := io.Copy(outFile, tarReader); err != nil { - log.Fatalf("ExtractTarGz: Copy() failed: %s", err.Error()) + log.Errorf("ExtractTarGz: Copy() failed: %s", err.Error()) } default: - log.Fatalf( + log.Errorf( "ExtractTarGz: unknown type: %v in %s", header.Typeflag, header.Name)