Skip to content

Commit

Permalink
refacto(api): remove old pollers (#3394)
Browse files Browse the repository at this point in the history
UI and BDD are not impacted yet
  • Loading branch information
fsamin authored and yesnault committed Oct 5, 2018
1 parent 3582d06 commit b4e192e
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 1,680 deletions.
2 changes: 0 additions & 2 deletions engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/ovh/cds/engine/api/observability"
"github.com/ovh/cds/engine/api/pipeline"
"github.com/ovh/cds/engine/api/platform"
"github.com/ovh/cds/engine/api/poller"
"github.com/ovh/cds/engine/api/purge"
"github.com/ovh/cds/engine/api/queue"
"github.com/ovh/cds/engine/api/repositoriesmanager"
Expand Down Expand Up @@ -642,7 +641,6 @@ func (a *API) Serve(ctx context.Context) error {
sdk.GoRoutine("action.RequirementsCacheLoader", func() { action.RequirementsCacheLoader(ctx, 5*time.Second, a.DBConnectionFactory.GetDBMap, a.Cache) })
sdk.GoRoutine("hookRecoverer(ctx", func() { hookRecoverer(ctx, a.DBConnectionFactory.GetDBMap, a.Cache) })
sdk.GoRoutine("services.KillDeadServices", func() { services.KillDeadServices(ctx, a.mustDB) })
sdk.GoRoutine("poller.Initialize", func() { poller.Initialize(ctx, a.Cache, 10, a.DBConnectionFactory.GetDBMap) })
sdk.GoRoutine("migrate.CleanOldWorkflow", func() { migrate.CleanOldWorkflow(ctx, a.Cache, a.DBConnectionFactory.GetDBMap, a.Config.URL.API) })
sdk.GoRoutine("migrate.KeyMigration", func() { migrate.KeyMigration(a.Cache, a.DBConnectionFactory.GetDBMap, &sdk.User{Admin: true}) })
sdk.GoRoutine("broadcast.Initialize", func() { broadcast.Initialize(ctx, a.DBConnectionFactory.GetDBMap) })
Expand Down
4 changes: 0 additions & 4 deletions engine/api/api_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ func (api *API) InitRouter() {
r.Handle("/project/{key}/application/{permApplicationName}/pipeline/{permPipelineKey}/hook", r.POST(api.addHookHandler), r.GET(api.getHooksHandler))
r.Handle("/project/{key}/application/{permApplicationName}/pipeline/{permPipelineKey}/hook/{id}", r.PUT(api.updateHookHandler), r.DELETE(api.deleteHookHandler))

// Pollers
r.Handle("/project/{key}/application/{permApplicationName}/polling", r.GET(api.getApplicationPollersHandler))
r.Handle("/project/{key}/application/{permApplicationName}/pipeline/{permPipelineKey}/polling", r.POST(api.addPollerHandler), r.GET(api.getPollersHandler), r.PUT(api.updatePollerHandler), r.DELETE(api.deletePollerHandler))

// Build queue
r.Handle("/queue", r.GET(api.getQueueHandler))
r.Handle("/queue/{id}/take", r.POST(api.takePipelineBuildJobHandler))
Expand Down
16 changes: 3 additions & 13 deletions engine/api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/ovh/cds/engine/api/group"
"github.com/ovh/cds/engine/api/permission"
"github.com/ovh/cds/engine/api/pipeline"
"github.com/ovh/cds/engine/api/poller"
"github.com/ovh/cds/engine/api/project"
"github.com/ovh/cds/engine/api/repositoriesmanager"
"github.com/ovh/cds/engine/api/scheduler"
Expand Down Expand Up @@ -212,20 +211,20 @@ func (api *API) getApplicationTreeStatusHandler() service.Handler {
return sdk.WrapError(errApp, "getApplicationTreeStatusHandler>Cannot get application")
}

pbs, schedulers, pollers, hooks, errPB := workflowv0.GetWorkflowStatus(api.mustDB(), api.Cache, projectKey, applicationName, getUser(ctx), branchName, remote, version)
pbs, schedulers, hooks, errPB := workflowv0.GetWorkflowStatus(api.mustDB(), api.Cache, projectKey, applicationName, getUser(ctx), branchName, remote, version)
if errPB != nil {
return sdk.WrapError(errPB, "getApplicationHandler> Cannot load CD Tree status %s", app.Name)
}

response := struct {
Builds []sdk.PipelineBuild `json:"builds"`
Schedulers []sdk.PipelineScheduler `json:"schedulers"`
Pollers []sdk.RepositoryPoller `json:"pollers"`
Pollers []struct{} `json:"pollers"`
Hooks []sdk.Hook `json:"hooks"`
}{
pbs,
schedulers,
pollers,
nil,
hooks,
}

Expand All @@ -240,7 +239,6 @@ func (api *API) getApplicationHandler() service.Handler {
applicationName := vars["permApplicationName"]

applicationStatus := FormBool(r, "applicationStatus")
withPollers := FormBool(r, "withPollers")
withHooks := FormBool(r, "withHooks")
withNotifs := FormBool(r, "withNotifs")
withWorkflow := FormBool(r, "withWorkflow")
Expand Down Expand Up @@ -290,14 +288,6 @@ func (api *API) getApplicationHandler() service.Handler {
return sdk.WrapError(err, "getApplicationHandler> Unable to load groups by application")
}

if withPollers {
var errPoller error
app.RepositoryPollers, errPoller = poller.LoadByApplication(api.mustDB(), app.ID)
if errPoller != nil {
return sdk.WrapError(errPoller, "getApplicationHandler> Cannot load pollers for application %s", applicationName)
}
}

if withSchedulers {
var errScheduler error
app.Schedulers, errScheduler = scheduler.GetByApplication(api.mustDB(), app)
Expand Down
8 changes: 0 additions & 8 deletions engine/api/migrate/clean_old_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/ovh/cds/engine/api/artifact"
"github.com/ovh/cds/engine/api/cache"
"github.com/ovh/cds/engine/api/hook"
"github.com/ovh/cds/engine/api/poller"
"github.com/ovh/cds/engine/api/project"
"github.com/ovh/cds/engine/api/repositoriesmanager"
"github.com/ovh/cds/engine/api/scheduler"
Expand Down Expand Up @@ -262,13 +261,6 @@ func cleanApplication(db *gorp.DbMap, wg *sync.WaitGroup, chErr chan<- error, ap
return
}

if err := poller.DeleteAll(db, app.ID); err != nil {
errF := fmt.Errorf("cleanApplication> Unable to delete poller for application %s: %s", app.Name, err)
log.Warning("%s", errF)
chErr <- errF
return
}

if err := trigger.DeleteApplicationTriggers(db, app.ID); err != nil {
errF := fmt.Errorf("cleanApplication> Unable to delete trigger for application %s: %s", app.Name, err)
log.Warning("%s", errF)
Expand Down
73 changes: 0 additions & 73 deletions engine/api/poller/cleaner.go

This file was deleted.

133 changes: 0 additions & 133 deletions engine/api/poller/dao.go

This file was deleted.

Loading

0 comments on commit b4e192e

Please sign in to comment.