func checkPubSub() error { oldConfig, _ := config.GetString("redis-queue:host") if oldConfig != "" { return config.NewWarning(`Using "redis-queue:*" is deprecated. Please change your tsuru.conf to use "pubsub:*" options. See http://docs.tsuru.io/en/latest/reference/config.html#pubsub for more details.`) } redisHost, _ := config.GetString("pubsub:redis-host") if redisHost == "" { return config.NewWarning(`Config entry "pubsub:redis-host" is not set, default "localhost" will be used. Running "tsuru app-log -f" might not work.`) } return nil }
func (w *CheckerSuite) TestCheckPubSubOld(c *check.C) { config.Unset("pubsub:redis-host") config.Set("redis-queue:host", "localhost") err := checkPubSub() c.Assert(err, check.FitsTypeOf, config.NewWarning("")) c.Assert(err, check.ErrorMatches, ".*Using \"redis-queue:\\*\" is deprecated.*") }
func (s *CheckerSuite) TestCheckRouterHipacheCanHaveHipacheInRoutersConf(c *check.C) { config.Unset("routers:hipache") config.Set("hipache:domain", "something") err := checkRouter() c.Assert(err, check.FitsTypeOf, config.NewWarning("")) c.Assert(err, check.ErrorMatches, ".*Setting \"hipache:\\*\" config entries is deprecated.*") }
func checkQueue() error { queueConfig, _ := config.GetString("queue:mongo-url") if queueConfig == "" { return config.NewWarning(`Config entry "queue:mongo-url" is not set, default "localhost" will be used. Running "tsuru-admin docker-node-{add,remove}" commands might not work.`) } return nil }
func (s *CheckerSuite) TestCheckSchedulerConfigSegregate(c *check.C) { config.Set("docker:segregate", true) err := checkScheduler() baseWarn := config.NewWarning("") c.Assert(err, check.FitsTypeOf, baseWarn) c.Assert(err, check.ErrorMatches, `Setting "docker:segregate" is not necessary anymore, this is the default behavior from now on.`) config.Set("docker:segregate", false) err = checkScheduler() c.Assert(err, check.Not(check.FitsTypeOf), baseWarn) c.Assert(err, check.ErrorMatches, `You must remove "docker:segregate" from your config.`) }
// Check Schedulers // It verifies your scheduler configuration and validates related confs. func checkScheduler() error { if servers, err := config.Get("docker:servers"); err == nil && servers != nil { return fmt.Errorf(`Using docker:servers is deprecated, please remove it your config and use "tsuru-admin docker-node-add" do add docker nodes.`) } isSegregate, err := config.GetBool("docker:segregate") if err == nil { if isSegregate { return config.NewWarning(`Setting "docker:segregate" is not necessary anymore, this is the default behavior from now on.`) } else { return fmt.Errorf(`You must remove "docker:segregate" from your config.`) } } return nil }
// Check Router // It verifies your router configuration and validates related confs. func checkRouter() error { defaultRouter, _ := config.GetString("docker:router") if defaultRouter == "" { return fmt.Errorf(`You must configure a default router in "docker:router".`) } isHipacheOld := false if defaultRouter == "hipache" { hipacheOld, _ := config.Get("hipache") isHipacheOld = hipacheOld != nil } routerConf, _ := config.Get("routers:" + defaultRouter) if isHipacheOld { return config.NewWarning(`Setting "hipache:*" config entries is deprecated. You should configure your router with "routers:*". See http://docs.tsuru.io/en/latest/reference/config.html#routers for more details.`) } if routerConf == nil { return fmt.Errorf(`You must configure your default router %q in "routers:%s".`, defaultRouter, defaultRouter) } routerType, _ := config.Get("routers:" + defaultRouter + ":type") if routerType == nil { return fmt.Errorf(`You must configure your default router type in "routers:%s:type".`, defaultRouter) } return nil }
func (w *CheckerSuite) TestCheckQueueNotSet(c *check.C) { config.Unset("queue:mongo-url") err := checkQueue() c.Assert(err, check.FitsTypeOf, config.NewWarning("")) c.Assert(err, check.ErrorMatches, ".*Config entry \"queue:mongo-url\" is not set.*") }
func (w *CheckerSuite) TestCheckPubSubMissing(c *check.C) { config.Unset("pubsub:redis-host") err := checkPubSub() c.Assert(err, check.FitsTypeOf, config.NewWarning("")) c.Assert(err, check.ErrorMatches, ".*Config entry \"pubsub:redis-host\" is not set.*") }