Skip to content

Commit

Permalink
Logging info and use store.Backend type instead of strings in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Dec 11, 2018
1 parent 6887c36 commit d21cf16
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions dkron/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (a *Agent) SetConfig(c *Config) {
func (a *Agent) StartServer() {
if a.Store == nil {
var sConfig *store.Config
if a.config.Backend == "boltdb" {
if a.config.Backend == store.BOLTDB {
sConfig = &store.Config{Bucket: a.config.Keyspace}
}
a.Store = NewStore(a.config.Backend, a.config.BackendMachines, a, a.config.Keyspace, sConfig)
Expand All @@ -317,7 +317,7 @@ func (a *Agent) StartServer() {
log.WithError(err).Fatal("agent: RPC server failed to start")
}

if a.config.Backend != "boltdb" {
if a.config.Backend != store.BOLTDB {
a.participate()
} else {
a.schedule()
Expand Down Expand Up @@ -358,7 +358,7 @@ func (a *Agent) runForElection() {
}

case err := <-errCh:
log.WithError(err).Debug("Leader election failed, channel is probably closed")
log.WithError(err).Error("Leader election failed, channel is probably closed")
metrics.IncrCounter([]string{"agent", "election", "failure"}, 1)
// Always stop the schedule of this server to prevent multiple servers with the scheduler on
a.sched.Stop()
Expand Down Expand Up @@ -407,7 +407,7 @@ func (a *Agent) eventLoop() {
case e := <-a.eventCh:
log.WithFields(logrus.Fields{
"event": e.String(),
}).Debug("agent: Received event")
}).Info("agent: Received event")
metrics.IncrCounter([]string{"agent", "event_received", e.String()}, 1)

// Log all member events
Expand Down Expand Up @@ -512,7 +512,7 @@ func (a *Agent) eventLoop() {

// Start or restart scheduler
func (a *Agent) schedule() {
log.Debug("agent: Restarting scheduler")
log.Info("agent: Restarting scheduler")
jobs, err := a.Store.GetJobs(nil)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -625,7 +625,7 @@ func (a *Agent) RefreshJobStatus(jobName string) {
log.WithFields(logrus.Fields{
"member": ex.NodeName,
"execution_key": ex.Key(),
}).Debug("agent: Asking member for pending execution")
}).Info("agent: Asking member for pending execution")

nodes = append(nodes, ex.NodeName)
group = strconv.FormatInt(ex.Group, 10)
Expand Down
2 changes: 1 addition & 1 deletion dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *HTTPTransport) indexHandler(c *gin.Context) {
"agent": {
"name": local.Name,
"version": Version,
"backend": h.agent.config.Backend,
"backend": string(h.agent.config.Backend),
"backend_status": strconv.FormatInt(int64(status), 10),
},
"serf": h.agent.serf.Stats(),
Expand Down
6 changes: 4 additions & 2 deletions dkron/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"time"

"github.com/abronan/valkeyrie/store"

flag "github.com/spf13/pflag"
)

Expand All @@ -15,7 +17,7 @@ type Config struct {
NodeName string `mapstructure:"node-name"`
BindAddr string `mapstructure:"bind-addr"`
HTTPAddr string `mapstructure:"http-addr"`
Backend string
Backend store.Backend
BackendMachines []string `mapstructure:"backend-machine"`
Profile string
Interface string
Expand Down Expand Up @@ -93,7 +95,7 @@ func ConfigFlagSet() *flag.FlagSet {
cmdFlags.String("bind-addr", c.BindAddr, "Address to bind network listeners to.")
cmdFlags.String("advertise-addr", "", "Address used to advertise to other nodes in the cluster. By default, the bind address is advertised.")
cmdFlags.String("http-addr", c.HTTPAddr, "Address to bind the UI web server to. Only used when server.")
cmdFlags.String("backend", c.Backend, "store backend")
cmdFlags.String("backend", string(c.Backend), "store backend")
cmdFlags.StringSlice("backend-machine", c.BackendMachines, "store backend machines addresses")
cmdFlags.String("profile", c.Profile, "Profile is used to control the timing profiles used. The default if not provided is lan.")
cmdFlags.StringSlice("join", []string{}, "An initial agent to join with. This flag can be specified multiple times.")
Expand Down
2 changes: 1 addition & 1 deletion dkron/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newCommonDashboardData(a *Agent, nodeName, path string) *commonDashboardDat
Version: Version,
LeaderName: leaderName,
MemberName: nodeName,
Backend: a.config.Backend,
Backend: string(a.config.Backend),
AssetsPath: fmt.Sprintf("%s%s", path, assetsPrefix),
Path: fmt.Sprintf("%s%s", path, dashboardPathPrefix),
APIPath: fmt.Sprintf("%s%s", path, apiPathPrefix),
Expand Down
4 changes: 2 additions & 2 deletions dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Store struct {
Client store.Store
agent *Agent
keyspace string
backend string
backend store.Backend
}

type JobOptions struct {
Expand All @@ -59,7 +59,7 @@ func init() {
boltdb.Register()
}

func NewStore(backend string, machines []string, a *Agent, keyspace string, config *store.Config) *Store {
func NewStore(backend store.Backend, machines []string, a *Agent, keyspace string, config *store.Config) *Store {
s, err := valkeyrie.NewStore(store.Backend(backend), machines, config)
if err != nil {
log.Error(err)
Expand Down

0 comments on commit d21cf16

Please sign in to comment.