fix issues with privileged not set
This commit is contained in:
@@ -7,7 +7,6 @@ package daemon
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/kelseyhightower/envconfig"
|
||||||
@@ -18,13 +17,6 @@ type Config struct {
|
|||||||
Debug bool `envconfig:"DRONE_DEBUG"`
|
Debug bool `envconfig:"DRONE_DEBUG"`
|
||||||
Trace bool `envconfig:"DRONE_TRACE"`
|
Trace bool `envconfig:"DRONE_TRACE"`
|
||||||
|
|
||||||
Logger struct {
|
|
||||||
File string `envconfig:"DRONE_LOG_FILE"`
|
|
||||||
MaxAge int `envconfig:"DRONE_LOG_FILE_MAX_AGE" default:"1"`
|
|
||||||
MaxBackups int `envconfig:"DRONE_LOG_FILE_MAX_BACKUPS" default:"1"`
|
|
||||||
MaxSize int `envconfig:"DRONE_LOG_FILE_MAX_SIZE" default:"100"`
|
|
||||||
}
|
|
||||||
|
|
||||||
Client struct {
|
Client struct {
|
||||||
Address string `ignored:"true"`
|
Address string `ignored:"true"`
|
||||||
Proto string `envconfig:"DRONE_RPC_PROTO" default:"http"`
|
Proto string `envconfig:"DRONE_RPC_PROTO" default:"http"`
|
||||||
@@ -60,6 +52,7 @@ type Config struct {
|
|||||||
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
|
||||||
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
|
||||||
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
|
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
|
||||||
|
Secrets map[string]string `envconfig:"DRONE_RUNNER_SECRETS"`
|
||||||
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
|
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
|
||||||
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
|
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
|
||||||
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
|
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
|
||||||
@@ -68,8 +61,8 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Platform struct {
|
Platform struct {
|
||||||
OS string `envconfig:"DRONE_PLATFORM_OS"`
|
OS string `envconfig:"DRONE_PLATFORM_OS" default:"linux"`
|
||||||
Arch string `envconfig:"DRONE_PLATFORM_ARCH"`
|
Arch string `envconfig:"DRONE_PLATFORM_ARCH" default:"amd64"`
|
||||||
Kernel string `envconfig:"DRONE_PLATFORM_KERNEL"`
|
Kernel string `envconfig:"DRONE_PLATFORM_KERNEL"`
|
||||||
Variant string `envconfig:"DRONE_PLATFORM_VARIANT"`
|
Variant string `envconfig:"DRONE_PLATFORM_VARIANT"`
|
||||||
}
|
}
|
||||||
@@ -115,13 +108,6 @@ func fromEnviron() (Config, error) {
|
|||||||
config.Client.Host,
|
config.Client.Host,
|
||||||
)
|
)
|
||||||
|
|
||||||
if config.Platform.OS == "" {
|
|
||||||
config.Platform.OS = runtime.GOOS
|
|
||||||
}
|
|
||||||
if config.Platform.Arch == "" {
|
|
||||||
config.Platform.Arch = runtime.GOARCH
|
|
||||||
}
|
|
||||||
|
|
||||||
// environment variables can be sourced from a separate
|
// environment variables can be sourced from a separate
|
||||||
// file. These variables are loaded and appended to the
|
// file. These variables are loaded and appended to the
|
||||||
// environment list.
|
// environment list.
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
),
|
),
|
||||||
Compiler: &compiler.Compiler{
|
Compiler: &compiler.Compiler{
|
||||||
Environ: config.Runner.Environ,
|
Environ: config.Runner.Environ,
|
||||||
Privileged: config.Runner.Privileged,
|
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||||
Networks: config.Runner.Networks,
|
Networks: config.Runner.Networks,
|
||||||
Volumes: config.Runner.Volumes,
|
Volumes: config.Runner.Volumes,
|
||||||
// Resources: nil,
|
// Resources: nil,
|
||||||
@@ -131,10 +131,15 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
config.Registry.SkipVerify,
|
config.Registry.SkipVerify,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Secret: secret.External(
|
Secret: secret.Combine(
|
||||||
config.Secret.Endpoint,
|
secret.StaticVars(
|
||||||
config.Secret.Token,
|
config.Runner.Secrets,
|
||||||
config.Secret.SkipVerify,
|
),
|
||||||
|
secret.External(
|
||||||
|
config.Secret.Endpoint,
|
||||||
|
config.Secret.Token,
|
||||||
|
config.Secret.SkipVerify,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
Execer: runtime.NewExecer(
|
Execer: runtime.NewExecer(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func cloneImage(platform manifest.Platform) string {
|
|||||||
case "windows":
|
case "windows":
|
||||||
return "drone/git:latest"
|
return "drone/git:latest"
|
||||||
default:
|
default:
|
||||||
return "drone/git:1"
|
return "drone/git:latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func TestClone(t *testing.T) {
|
|||||||
want := []*engine.Step{
|
want := []*engine.Step{
|
||||||
{
|
{
|
||||||
ID: "random",
|
ID: "random",
|
||||||
Image: "drone/git:1",
|
Image: "drone/git:latest",
|
||||||
Name: "clone",
|
Name: "clone",
|
||||||
Pull: engine.PullDefault,
|
Pull: engine.PullDefault,
|
||||||
RunPolicy: engine.RunAlways,
|
RunPolicy: engine.RunAlways,
|
||||||
@@ -84,7 +84,7 @@ func TestCloneDisable(t *testing.T) {
|
|||||||
func TestCloneCreate(t *testing.T) {
|
func TestCloneCreate(t *testing.T) {
|
||||||
want := &engine.Step{
|
want := &engine.Step{
|
||||||
Name: "clone",
|
Name: "clone",
|
||||||
Image: "drone/git:1",
|
Image: "drone/git:latest",
|
||||||
RunPolicy: engine.RunAlways,
|
RunPolicy: engine.RunAlways,
|
||||||
Envs: map[string]string{"PLUGIN_DEPTH": "50"},
|
Envs: map[string]string{"PLUGIN_DEPTH": "50"},
|
||||||
}
|
}
|
||||||
@@ -102,11 +102,11 @@ func TestCloneImage(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
in: manifest.Platform{},
|
in: manifest.Platform{},
|
||||||
out: "drone/git:1",
|
out: "drone/git:latest",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: manifest.Platform{OS: "linux"},
|
in: manifest.Platform{OS: "linux"},
|
||||||
out: "drone/git:1",
|
out: "drone/git:latest",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: manifest.Platform{OS: "windows"},
|
in: manifest.Platform{OS: "windows"},
|
||||||
|
|||||||
2
engine/compiler/testdata/graph.json
vendored
2
engine/compiler/testdata/graph.json
vendored
@@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"id": "random",
|
"id": "random",
|
||||||
"environment": {},
|
"environment": {},
|
||||||
"image": "drone/git:1",
|
"image": "drone/git:latest",
|
||||||
"labels": {},
|
"labels": {},
|
||||||
"name": "clone",
|
"name": "clone",
|
||||||
"run_policy": "always",
|
"run_policy": "always",
|
||||||
|
|||||||
2
engine/compiler/testdata/serial.json
vendored
2
engine/compiler/testdata/serial.json
vendored
@@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
"id": "random",
|
"id": "random",
|
||||||
"environment": {},
|
"environment": {},
|
||||||
"image": "drone/git:1",
|
"image": "drone/git:latest",
|
||||||
"labels": {},
|
"labels": {},
|
||||||
"name": "clone",
|
"name": "clone",
|
||||||
"run_policy": "always",
|
"run_policy": "always",
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ func (s *Runner) Run(ctx context.Context, stage *drone.Stage) error {
|
|||||||
|
|
||||||
stage.Machine = s.Machine
|
stage.Machine = s.Machine
|
||||||
err := s.Client.Accept(ctx, stage)
|
err := s.Client.Accept(ctx, stage)
|
||||||
|
if err != nil && err == client.ErrOptimisticLock {
|
||||||
|
log.Debug("stage accepted by another runner")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("cannot accept stage")
|
log.WithError(err).Error("cannot accept stage")
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user