remove deprecated scheduler
This commit is contained in:
parent
dbebe9d7d9
commit
dd2cc872c2
7 changed files with 18 additions and 151 deletions
|
@ -17,7 +17,6 @@ package main
|
|||
import (
|
||||
"github.com/drone/drone/cmd/drone-server/config"
|
||||
"github.com/drone/drone/core"
|
||||
"github.com/drone/drone/scheduler/docker"
|
||||
"github.com/drone/drone/scheduler/kube"
|
||||
"github.com/drone/drone/scheduler/nomad"
|
||||
"github.com/drone/drone/scheduler/queue"
|
||||
|
@ -43,17 +42,9 @@ func provideScheduler(store core.StageStore, config config.Config) core.Schedule
|
|||
return provideNomadScheduler(config)
|
||||
default:
|
||||
return provideQueueScheduler(store, config)
|
||||
// return provideDockerScheduler(config)
|
||||
}
|
||||
}
|
||||
|
||||
// provideDockerScheduler is a Wire provider function that
|
||||
// returns an in-memory Docker scheduler.
|
||||
func provideDockerScheduler(config config.Config) core.Scheduler {
|
||||
logrus.Info("main: local docker runner enabled")
|
||||
return docker.New()
|
||||
}
|
||||
|
||||
// provideKubernetesScheduler is a Wire provider function that
|
||||
// returns a nomad kubernetes from the environment configuration.
|
||||
func provideKubernetesScheduler(config config.Config) core.Scheduler {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -18,7 +18,7 @@ require (
|
|||
github.com/drone/drone-go v0.0.0-20190217024616-3e8b71333e59
|
||||
github.com/drone/drone-runtime v0.0.0-20190210191445-ad403a0ca24e
|
||||
github.com/drone/drone-ui v0.0.0-20190223014501-189a4d227db5
|
||||
github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963
|
||||
github.com/drone/drone-yaml v1.0.1
|
||||
github.com/drone/envsubst v1.0.1
|
||||
github.com/drone/go-license v1.0.2
|
||||
github.com/drone/go-login v1.0.3
|
||||
|
|
2
go.sum
2
go.sum
|
@ -48,6 +48,8 @@ github.com/drone/drone-yaml v1.0.1-0.20190222011027-9e589be71ad8 h1:Fig8cPBvJu/0
|
|||
github.com/drone/drone-yaml v1.0.1-0.20190222011027-9e589be71ad8/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||
github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963 h1:c/xcHqxU4sSjehiWoN91nNDN0QmB0UyHOVINvJJ1GUg=
|
||||
github.com/drone/drone-yaml v1.0.1-0.20190222030833-0e9ca9cdb963/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||
github.com/drone/drone-yaml v1.0.1 h1:a5t5zCqDFRa791B6/7i19rSpuT9slublvCGt5v0tl+I=
|
||||
github.com/drone/drone-yaml v1.0.1/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
|
||||
github.com/drone/envsubst v1.0.1 h1:NOOStingM2sbBwsIUeQkKUz8ShwCUzmqMxWrpXItfPE=
|
||||
github.com/drone/envsubst v1.0.1/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
||||
github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrkok=
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// +build !oss
|
||||
|
||||
package mockscm
|
||||
|
||||
//go:generate mockgen -package=mockscm -destination=mock_gen.go github.com/drone/go-scm/scm ContentService,GitService,OrganizationService,PullRequestService,RepositoryService,UserService
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
// Package Docker is DEPRECATED. DO NOT UPDATE.
|
||||
|
||||
package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
"github.com/drone/drone/operator/runner"
|
||||
)
|
||||
|
||||
var _ core.Scheduler = (*Scheduler)(nil)
|
||||
|
||||
// Scheduler is a Docker scheduler.
|
||||
type Scheduler struct {
|
||||
sync.Mutex
|
||||
|
||||
pending chan int64
|
||||
running map[int64]context.CancelFunc
|
||||
runner *runner.Runner
|
||||
}
|
||||
|
||||
// New returns a new Docker scheduler.
|
||||
func New() *Scheduler {
|
||||
return NewRunner(nil)
|
||||
}
|
||||
|
||||
// NewRunner returns a new Docker scheduler.
|
||||
func NewRunner(runner *runner.Runner) *Scheduler {
|
||||
return &Scheduler{
|
||||
pending: make(chan int64, 100),
|
||||
running: make(map[int64]context.CancelFunc),
|
||||
runner: runner,
|
||||
}
|
||||
}
|
||||
|
||||
// SetRunner sets the build runner.
|
||||
func (s *Scheduler) SetRunner(runner *runner.Runner) {
|
||||
s.runner = runner
|
||||
}
|
||||
|
||||
// Start starts the scheduler.
|
||||
func (s *Scheduler) Start(ctx context.Context, cap int) error {
|
||||
var g errgroup.Group
|
||||
for i := 0; i < cap; i++ {
|
||||
g.Go(func() error {
|
||||
return s.start(ctx)
|
||||
})
|
||||
}
|
||||
return g.Wait()
|
||||
}
|
||||
|
||||
func (s *Scheduler) start(ctx context.Context) error {
|
||||
for {
|
||||
select {
|
||||
case id := <-s.pending:
|
||||
s.run(ctx, id)
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) run(ctx context.Context, id int64) error {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
s.Lock()
|
||||
s.running[id] = cancel
|
||||
s.Unlock()
|
||||
|
||||
err := s.runner.Run(ctx, id)
|
||||
|
||||
s.Lock()
|
||||
delete(s.running, id)
|
||||
s.Unlock()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Schedule schedules the stage for execution.
|
||||
func (s *Scheduler) Schedule(ctx context.Context, stage *core.Stage) error {
|
||||
select {
|
||||
case s.pending <- stage.ID:
|
||||
return nil
|
||||
default:
|
||||
return errors.New("Internal build queue is full")
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel cancels scheduled or running jobs associated
|
||||
// with the parent build ID.
|
||||
func (s *Scheduler) Cancel(_ context.Context, id int64) error {
|
||||
s.Lock()
|
||||
cancel, ok := s.running[id]
|
||||
s.Unlock()
|
||||
if ok {
|
||||
cancel()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stats returns stats specific to the scheduler.
|
||||
func (s *Scheduler) Stats(_ context.Context) (interface{}, error) {
|
||||
s.Lock()
|
||||
stats := &status{
|
||||
Pending: len(s.pending),
|
||||
Running: len(s.running),
|
||||
}
|
||||
s.Unlock()
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func (s *Scheduler) Request(context.Context, core.Filter) (*core.Stage, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Scheduler) Cancelled(context.Context, int64) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
type status struct {
|
||||
Pending int `json:"pending"`
|
||||
Running int `json:"running"`
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package docker
|
|
@ -1,6 +1,16 @@
|
|||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
// Copyright 2019 Drone IO, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package dbtest
|
||||
|
||||
|
|
Loading…
Reference in a new issue