Louis job scheduler (#1197)

* Adds job repo
* Adds scheduler
* Adds plugin table which is a place holder for future expansion of the scheduler. Currently all jobs that are created are linked to the pi_system plugin which are jobs that are held in a local registeredJobs map populated at controller startup.
This commit is contained in:
Louis Ruch authored and GitHub committed 2021-05-06 14:54:10 -07:00
1 parent d1d35e827c
commit feb5d7385d
40 files changed
+5445 -13

No files matched your search

+15
View File
@@ -14,6 +14,8 @@ import (
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/scheduler/job"
"github.com/hashicorp/boundary/internal/servers"
"github.com/hashicorp/boundary/internal/servers/controller/common"
"github.com/hashicorp/boundary/internal/session"
@@ -48,6 +50,8 @@ type Controller struct {
StaticHostRepoFn common.StaticRepoFactory
TargetRepoFn common.TargetRepoFactory
scheduler *scheduler.Scheduler
kms *kms.Kms
}
@@ -137,6 +141,14 @@ func New(conf *Config) (*Controller, error) {
c.workerAuthCache = cache.New(0, 0)
jobRepoFn := func() (*job.Repository, error) {
return job.NewRepository(dbase, dbase, c.kms)
}
c.scheduler, err = scheduler.New(c.conf.RawConfig.Controller.Name, jobRepoFn, c.logger)
if err != nil {
return nil, fmt.Errorf("error creating new scheduler: %w", err)
}
return c, nil
}
@@ -146,6 +158,9 @@ func (c *Controller) Start() error {
return nil
}
c.baseContext, c.baseCancel = context.WithCancel(context.Background())
if err := c.scheduler.Start(c.baseContext); err != nil {
return fmt.Errorf("error starting scheduler: %w", err)
}
if err := c.startListeners(); err != nil {
return fmt.Errorf("error starting controller listeners: %w", err)