Commit a12dc2aa authored by Steve Azzopardi's avatar Steve Azzopardi

Merge branch 'remove-alias-for-logrus-imports' into 'master'

Remove unnecessary log alias for logrus inport

See merge request gitlab-org/gitlab-runner!1256
parents fea78b8a d9e9d81c
package commands
import (
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gitlab.com/gitlab-org/gitlab-runner/common"
)
......@@ -13,16 +14,16 @@ type ListCommand struct {
func (c *ListCommand) Execute(context *cli.Context) {
err := c.loadConfig()
if err != nil {
log.Warningln(err)
logrus.Warningln(err)
return
}
log.WithFields(log.Fields{
logrus.WithFields(logrus.Fields{
"ConfigFile": c.ConfigFile,
}).Println("Listing configured runners")
for _, runner := range c.config.Runners {
log.WithFields(log.Fields{
logrus.WithFields(logrus.Fields{
"Executor": runner.RunnerSettings.Executor,
"Token": runner.RunnerCredentials.Token,
"URL": runner.RunnerCredentials.URL,
......
......@@ -6,7 +6,7 @@ import (
"os/signal"
"strings"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gitlab.com/gitlab-org/gitlab-runner/common"
......@@ -69,7 +69,7 @@ func (s *RegisterCommand) ask(key, prompt string, allowEmptyOptional ...bool) st
if s.NonInteractive || prompt == "" {
if result == "" && !allowEmpty {
log.Panicln("The", key, "needs to be entered")
logrus.Panicln("The", key, "needs to be entered")
}
return result
}
......@@ -94,9 +94,9 @@ func (s *RegisterCommand) askExecutor() {
message := "Invalid executor specified"
if s.NonInteractive {
log.Panicln(message)
logrus.Panicln(message)
} else {
log.Errorln(message)
logrus.Errorln(message)
}
}
}
......@@ -143,10 +143,10 @@ func (s *RegisterCommand) askRunner() {
s.URL = s.ask("url", "Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):")
if s.Token != "" {
log.Infoln("Token specified trying to verify runner...")
log.Warningln("If you want to register use the '-r' instead of '-t'.")
logrus.Infoln("Token specified trying to verify runner...")
logrus.Warningln("If you want to register use the '-r' instead of '-t'.")
if !s.network.VerifyRunner(s.RunnerCredentials) {
log.Panicln("Failed to verify this runner. Perhaps you are having network problems")
logrus.Panicln("Failed to verify this runner. Perhaps you are having network problems")
}
} else {
// we store registration token as token, since we pass that to RunnerCredentials
......@@ -169,7 +169,7 @@ func (s *RegisterCommand) askRunner() {
result := s.network.RegisterRunner(s.RunnerCredentials, parameters)
if result == nil {
log.Panicln("Failed to register this runner. Perhaps you are having network problems")
logrus.Panicln("Failed to register this runner. Perhaps you are having network problems")
}
s.Token = result.Token
......@@ -275,7 +275,7 @@ func (s *RegisterCommand) Execute(context *cli.Context) {
s.context = context
err := s.loadConfig()
if err != nil {
log.Panicln(err)
logrus.Panicln(err)
}
s.askRunner()
......@@ -298,12 +298,12 @@ func (s *RegisterCommand) Execute(context *cli.Context) {
go func() {
signal := <-signals
s.network.UnregisterRunner(s.RunnerCredentials)
log.Fatalf("RECEIVED SIGNAL: %v", signal)
logrus.Fatalf("RECEIVED SIGNAL: %v", signal)
}()
}
if s.config.Concurrent < s.Limit {
log.Warningf("Specified limit (%d) larger then current concurrent limit (%d). Concurrent limit will not be enlarged.", s.Limit, s.config.Concurrent)
logrus.Warningf("Specified limit (%d) larger then current concurrent limit (%d). Concurrent limit will not be enlarged.", s.Limit, s.config.Concurrent)
}
s.askExecutor()
......@@ -312,7 +312,7 @@ func (s *RegisterCommand) Execute(context *cli.Context) {
s.prepareCache()
s.saveConfig()
log.Printf("Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!")
logrus.Printf("Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!")
}
func getHostname() string {
......
......@@ -6,7 +6,7 @@ import (
"syscall"
"time"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/tevino/abool"
"github.com/urfave/cli"
......@@ -38,11 +38,11 @@ func waitForInterrupts(finished *abool.AtomicBool, abortSignal chan os.Signal, d
// request stop, but wait for force exit
for interrupt == syscall.SIGQUIT {
log.Warningln("Requested quit, waiting for builds to finish")
logrus.Warningln("Requested quit, waiting for builds to finish")
interrupt = <-interruptSignals
}
log.Warningln("Requested exit:", interrupt)
logrus.Warningln("Requested exit:", interrupt)
go func() {
for {
......@@ -52,9 +52,9 @@ func waitForInterrupts(finished *abool.AtomicBool, abortSignal chan os.Signal, d
select {
case newSignal := <-interruptSignals:
log.Fatalln("forced exit:", newSignal)
logrus.Fatalln("forced exit:", newSignal)
case <-time.After(common.ShutdownTimeout * time.Second):
log.Fatalln("shutdown timed out")
logrus.Fatalln("shutdown timed out")
case <-doneSignal:
}
}
......@@ -70,7 +70,7 @@ func (r *RunSingleCommand) postBuild() {
func (r *RunSingleCommand) processBuild(data common.ExecutorData, abortSignal chan os.Signal) (err error) {
jobData, healthy := r.network.RequestJob(r.RunnerConfig, nil)
if !healthy {
log.Println("Runner is not healthy!")
logrus.Println("Runner is not healthy!")
select {
case <-time.After(common.NotHealthyCheckInterval * time.Second):
case <-abortSignal:
......@@ -108,11 +108,11 @@ func (r *RunSingleCommand) processBuild(data common.ExecutorData, abortSignal ch
func (r *RunSingleCommand) checkFinishedConditions() {
if r.MaxBuilds < 1 && !r.runForever {
log.Println("This runner has processed its build limit, so now exiting")
logrus.Println("This runner has processed its build limit, so now exiting")
r.finished.Set()
}
if r.WaitTimeout > 0 && int(time.Since(r.lastBuild).Seconds()) > r.WaitTimeout {
log.Println("This runner has not received a job in", r.WaitTimeout, "seconds, so now exiting")
logrus.Println("This runner has not received a job in", r.WaitTimeout, "seconds, so now exiting")
r.finished.Set()
}
return
......@@ -120,21 +120,21 @@ func (r *RunSingleCommand) checkFinishedConditions() {
func (r *RunSingleCommand) Execute(c *cli.Context) {
if len(r.URL) == 0 {
log.Fatalln("Missing URL")
logrus.Fatalln("Missing URL")
}
if len(r.Token) == 0 {
log.Fatalln("Missing Token")
logrus.Fatalln("Missing Token")
}
if len(r.Executor) == 0 {
log.Fatalln("Missing Executor")
logrus.Fatalln("Missing Executor")
}
executorProvider := common.GetExecutor(r.Executor)
if executorProvider == nil {
log.Fatalln("Unknown executor:", r.Executor)
logrus.Fatalln("Unknown executor:", r.Executor)
}
log.Println("Starting runner for", r.URL, "with token", r.ShortDescription(), "...")
logrus.Println("Starting runner for", r.URL, "with token", r.ShortDescription(), "...")
r.finished = abool.New()
abortSignal := make(chan os.Signal)
......@@ -148,12 +148,12 @@ func (r *RunSingleCommand) Execute(c *cli.Context) {
for !r.finished.IsSet() {
data, err := executorProvider.Acquire(&r.RunnerConfig)
if err != nil {
log.Warningln("Executor update:", err)
logrus.Warningln("Executor update:", err)
}
pErr := r.processBuild(data, abortSignal)
if pErr != nil {
log.WithError(pErr).Error("Failed to process build")
logrus.WithError(pErr).Error("Failed to process build")
}
r.checkFinishedConditions()
......
package commands
import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/network"
)
......@@ -17,10 +17,10 @@ type UnregisterCommand struct {
}
func (c *UnregisterCommand) unregisterAllRunners() (runners []*common.RunnerConfig) {
log.Warningln("Unregistering all runners")
logrus.Warningln("Unregistering all runners")
for _, r := range c.config.Runners {
if !c.network.UnregisterRunner(r.RunnerCredentials) {
log.Errorln("Failed to unregister runner", r.Name)
logrus.Errorln("Failed to unregister runner", r.Name)
//If unregister fails, leave the runner in the config
runners = append(runners, r)
}
......@@ -32,14 +32,14 @@ func (c *UnregisterCommand) unregisterSingleRunner() (runners []*common.RunnerCo
if len(c.Name) > 0 { // Unregister when given a name
runnerConfig, err := c.RunnerByName(c.Name)
if err != nil {
log.Fatalln(err)
logrus.Fatalln(err)
}
c.RunnerCredentials = runnerConfig.RunnerCredentials
}
// Unregister given Token and URL of the runner
if !c.network.UnregisterRunner(c.RunnerCredentials) {
log.Fatalln("Failed to unregister runner", c.Name)
logrus.Fatalln("Failed to unregister runner", c.Name)
}
for _, otherRunner := range c.config.Runners {
......@@ -56,7 +56,7 @@ func (c *UnregisterCommand) Execute(context *cli.Context) {
err := c.loadConfig()
if err != nil {
log.Fatalln(err)
logrus.Fatalln(err)
return
}
......@@ -77,9 +77,9 @@ func (c *UnregisterCommand) Execute(context *cli.Context) {
// save config file
err = c.saveConfig()
if err != nil {
log.Fatalln("Failed to update", c.ConfigFile, err)
logrus.Fatalln("Failed to update", c.ConfigFile, err)
}
log.Println("Updated", c.ConfigFile)
logrus.Println("Updated", c.ConfigFile)
}
func init() {
......
......@@ -3,7 +3,7 @@ package commands
import (
"errors"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gitlab.com/gitlab-org/gitlab-runner/common"
......@@ -23,14 +23,14 @@ func (c *VerifyCommand) Execute(context *cli.Context) {
err := c.loadConfig()
if err != nil {
log.Fatalln(err)
logrus.Fatalln(err)
return
}
// check if there's something to verify
toVerify, okRunners, err := c.selectRunners()
if err != nil {
log.Fatalln(err)
logrus.Fatalln(err)
return
}
......@@ -47,7 +47,7 @@ func (c *VerifyCommand) Execute(context *cli.Context) {
}
if !c.DeleteNonExisting {
log.Fatalln("Failed to verify runners")
logrus.Fatalln("Failed to verify runners")
return
}
......@@ -56,9 +56,9 @@ func (c *VerifyCommand) Execute(context *cli.Context) {
// save config file
err = c.saveConfig()
if err != nil {
log.Fatalln("Failed to update", c.ConfigFile, err)
logrus.Fatalln("Failed to update", c.ConfigFile, err)
}
log.Println("Updated", c.ConfigFile)
logrus.Println("Updated", c.ConfigFile)
}
func (c *VerifyCommand) selectRunners() (toVerify []*common.RunnerConfig, okRunners []*common.RunnerConfig, err error) {
......
package common
import (
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"gitlab.com/ayufan/golang-cli-helpers"
)
......@@ -13,7 +13,7 @@ type Commander interface {
}
func RegisterCommand(command cli.Command) {
log.Debugln("Registering", command.Name, "command...")
logrus.Debugln("Registering", command.Name, "command...")
commands = append(commands, command)
}
......
......@@ -16,7 +16,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/docker/go-units"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
api "k8s.io/api/core/v1"
"gitlab.com/gitlab-org/gitlab-runner/helpers"
......@@ -323,13 +323,13 @@ type Config struct {
func getDeprecatedStringSetting(setting string, tomlField string, envVariable string, tomlReplacement string, envReplacement string) string {
if setting != "" {
log.Warningf("%s setting is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", tomlField, tomlReplacement)
logrus.Warningf("%s setting is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", tomlField, tomlReplacement)
return setting
}
value := os.Getenv(envVariable)
if value != "" {
log.Warningf("%s environment variables is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", envVariable, envReplacement)
logrus.Warningf("%s environment variables is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", envVariable, envReplacement)
}
return value
......@@ -337,13 +337,13 @@ func getDeprecatedStringSetting(setting string, tomlField string, envVariable st
func getDeprecatedBoolSetting(setting bool, tomlField string, envVariable string, tomlReplacement string, envReplacement string) bool {
if setting {
log.Warningf("%s setting is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", tomlField, tomlReplacement)
logrus.Warningf("%s setting is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", tomlField, tomlReplacement)
return setting
}
value, _ := strconv.ParseBool(os.Getenv(envVariable))
if value {
log.Warningf("%s environment variables is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", envVariable, envReplacement)
logrus.Warningf("%s environment variables is deprecated and will be removed in GitLab Runner 12.0. Please use %s instead", envVariable, envReplacement)
}
return value
......@@ -360,7 +360,7 @@ func (c *CacheConfig) GetPath() string {
// TODO: Remove in 12.0
if c.S3CachePath != "" {
log.Warning("'--cache-s3-cache-path' command line option and `$S3_CACHE_PATH` environment variables are deprecated and will be removed in GitLab Runner 12.0. Please use '--cache-path' or '$CACHE_PATH' instead")
logrus.Warning("'--cache-s3-cache-path' command line option and `$S3_CACHE_PATH` environment variables are deprecated and will be removed in GitLab Runner 12.0. Please use '--cache-path' or '$CACHE_PATH' instead")
}
return c.S3CachePath
......@@ -373,7 +373,7 @@ func (c *CacheConfig) GetShared() bool {
// TODO: Remove in 12.0
if c.CacheShared {
log.Warning("'--cache-cache-shared' command line is deprecated and will be removed in GitLab Runner 12.0. Please use '--cache-shared' instead")
logrus.Warning("'--cache-cache-shared' command line is deprecated and will be removed in GitLab Runner 12.0. Please use '--cache-shared' instead")
}
return c.CacheShared
......@@ -475,7 +475,7 @@ func (c *DockerConfig) getMemoryBytes(size string, fieldName string) int64 {
bytes, err := units.RAMInBytes(size)
if err != nil {
log.Fatalf("Error parsing docker %s: %s", fieldName, err)
logrus.Fatalf("Error parsing docker %s: %s", fieldName, err)
}
return bytes
......@@ -613,11 +613,11 @@ func (c *RunnerCredentials) UniqueID() string {
return c.URL + c.Token
}
func (c *RunnerCredentials) Log() *log.Entry {
func (c *RunnerCredentials) Log() *logrus.Entry {
if c.ShortDescription() != "" {
return log.WithField("runner", c.ShortDescription())
return logrus.WithField("runner", c.ShortDescription())
}
return log.WithFields(log.Fields{})
return logrus.WithFields(logrus.Fields{})
}
func (c *RunnerCredentials) SameAs(other *RunnerCredentials) bool {
......@@ -717,7 +717,7 @@ func (c *Config) SaveConfig(configFile string) error {
newBuffer := bufio.NewWriter(&newConfig)
if err := toml.NewEncoder(newBuffer).Encode(c); err != nil {
log.Fatalf("Error encoding TOML: %s", err)
logrus.Fatalf("Error encoding TOML: %s", err)
return err
}
......@@ -751,7 +751,7 @@ func (c *Config) ListenOrServerMetricAddress() string {
// TODO: Remove in 12.0
if c.MetricsServerAddress != "" {
log.Warnln("'metrics_server' configuration entry is deprecated and will be removed in one of future releases; please use 'listen_address' instead")
logrus.Warnln("'metrics_server' configuration entry is deprecated and will be removed in one of future releases; please use 'listen_address' instead")
}
return c.MetricsServerAddress
......
......@@ -5,7 +5,7 @@ import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)
type ExecutorData interface{}
......@@ -85,7 +85,7 @@ func validateExecutorProvider(provider ExecutorProvider) error {
}
func RegisterExecutor(executor string, provider ExecutorProvider) {
log.Debugln("Registering", executor, "executor...")
logrus.Debugln("Registering", executor, "executor...")
if err := validateExecutorProvider(provider); err != nil {
panic("Executor cannot be registered: " + err.Error())
......
......@@ -3,7 +3,7 @@ package common
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-runner/helpers"
)
......@@ -59,7 +59,7 @@ type Shell interface {
var shells map[string]Shell
func RegisterShell(shell Shell) {
log.Debugln("Registering", shell.GetName(), "shell...")
logrus.Debugln("Registering", shell.GetName(), "shell...")
if shells == nil {
shells = make(map[string]Shell)
......
......@@ -2,13 +2,13 @@ package service_helpers
import (
"github.com/ayufan/golang-kardianos-service"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)
func New(i service.Interface, c *service.Config) (service.Service, error) {
s, err := service.New(i, c)
if err == service.ErrNoServiceSystemDetected {
log.Warningln("No service system detected. Some features may not work!")
logrus.Warningln("No service system detected. Some features may not work!")
return &SimpleService{
i: i,
......
......@@ -4,13 +4,14 @@ import (
"bytes"
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"net"
"os"
"os/exec"
"regexp"
"strings"
"time"
"github.com/sirupsen/logrus"
)
type StatusType string
......@@ -73,7 +74,7 @@ func IsStatusOnlineOrTransient(vmStatus StatusType) bool {
func VboxManageOutput(exe string, args ...string) (string, error) {
var stdout, stderr bytes.Buffer
log.Debugf("Executing VBoxManageOutput: %#v", args)
logrus.Debugf("Executing VBoxManageOutput: %#v", args)
cmd := exec.Command(exe, args...)
cmd.Stdout = &stdout
cmd.Stderr = &stderr
......@@ -154,14 +155,14 @@ func getUsedVirtualBoxPorts() (usedPorts [][]string, err error) {
func allocatePort(handler func(port string) error) (port string, err error) {
ln, err := net.Listen("tcp", ":0")
if err != nil {
log.Debugln("VirtualBox ConfigureSSH:", err)
logrus.Debugln("VirtualBox ConfigureSSH:", err)
return
}
defer ln.Close()
usedPorts, err := getUsedVirtualBoxPorts()
if err != nil {
log.Debugln("VirtualBox ConfigureSSH:", err)
logrus.Debugln("VirtualBox ConfigureSSH:", err)
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment