fix issues with privileged not set

This commit is contained in:
Brad Rydzewski
2019-10-24 19:25:18 -07:00
parent a6d6ee70c1
commit 4119ac2a6d
7 changed files with 24 additions and 29 deletions

View File

@@ -7,7 +7,6 @@ package daemon
import (
"fmt"
"os"
"runtime"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
@@ -18,13 +17,6 @@ type Config struct {
Debug bool `envconfig:"DRONE_DEBUG"`
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 {
Address string `ignored:"true"`
Proto string `envconfig:"DRONE_RPC_PROTO" default:"http"`
@@ -60,6 +52,7 @@ type Config struct {
Procs int64 `envconfig:"DRONE_RUNNER_MAX_PROCS"`
Environ map[string]string `envconfig:"DRONE_RUNNER_ENVIRON"`
EnvFile string `envconfig:"DRONE_RUNNER_ENV_FILE"`
Secrets map[string]string `envconfig:"DRONE_RUNNER_SECRETS"`
Labels map[string]string `envconfig:"DRONE_RUNNER_LABELS"`
Volumes map[string]string `envconfig:"DRONE_RUNNER_VOLUMES"`
Devices []string `envconfig:"DRONE_RUNNER_DEVICES"`
@@ -68,8 +61,8 @@ type Config struct {
}
Platform struct {
OS string `envconfig:"DRONE_PLATFORM_OS"`
Arch string `envconfig:"DRONE_PLATFORM_ARCH"`
OS string `envconfig:"DRONE_PLATFORM_OS" default:"linux"`
Arch string `envconfig:"DRONE_PLATFORM_ARCH" default:"amd64"`
Kernel string `envconfig:"DRONE_PLATFORM_KERNEL"`
Variant string `envconfig:"DRONE_PLATFORM_VARIANT"`
}
@@ -115,13 +108,6 @@ func fromEnviron() (Config, error) {
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
// file. These variables are loaded and appended to the
// environment list.

View File

@@ -117,7 +117,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
),
Compiler: &compiler.Compiler{
Environ: config.Runner.Environ,
Privileged: config.Runner.Privileged,
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
Networks: config.Runner.Networks,
Volumes: config.Runner.Volumes,
// Resources: nil,
@@ -131,10 +131,15 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
config.Registry.SkipVerify,
),
),
Secret: secret.External(
config.Secret.Endpoint,
config.Secret.Token,
config.Secret.SkipVerify,
Secret: secret.Combine(
secret.StaticVars(
config.Runner.Secrets,
),
secret.External(
config.Secret.Endpoint,
config.Secret.Token,
config.Secret.SkipVerify,
),
),
},
Execer: runtime.NewExecer(

View File

@@ -22,7 +22,7 @@ func cloneImage(platform manifest.Platform) string {
case "windows":
return "drone/git:latest"
default:
return "drone/git:1"
return "drone/git:latest"
}
}

View File

@@ -41,7 +41,7 @@ func TestClone(t *testing.T) {
want := []*engine.Step{
{
ID: "random",
Image: "drone/git:1",
Image: "drone/git:latest",
Name: "clone",
Pull: engine.PullDefault,
RunPolicy: engine.RunAlways,
@@ -84,7 +84,7 @@ func TestCloneDisable(t *testing.T) {
func TestCloneCreate(t *testing.T) {
want := &engine.Step{
Name: "clone",
Image: "drone/git:1",
Image: "drone/git:latest",
RunPolicy: engine.RunAlways,
Envs: map[string]string{"PLUGIN_DEPTH": "50"},
}
@@ -102,11 +102,11 @@ func TestCloneImage(t *testing.T) {
}{
{
in: manifest.Platform{},
out: "drone/git:1",
out: "drone/git:latest",
},
{
in: manifest.Platform{OS: "linux"},
out: "drone/git:1",
out: "drone/git:latest",
},
{
in: manifest.Platform{OS: "windows"},

View File

@@ -4,7 +4,7 @@
{
"id": "random",
"environment": {},
"image": "drone/git:1",
"image": "drone/git:latest",
"labels": {},
"name": "clone",
"run_policy": "always",

View File

@@ -4,7 +4,7 @@
{
"id": "random",
"environment": {},
"image": "drone/git:1",
"image": "drone/git:latest",
"labels": {},
"name": "clone",
"run_policy": "always",

View File

@@ -76,6 +76,10 @@ func (s *Runner) Run(ctx context.Context, stage *drone.Stage) error {
stage.Machine = s.Machine
err := s.Client.Accept(ctx, stage)
if err != nil && err == client.ErrOptimisticLock {
log.Debug("stage accepted by another runner")
return nil
}
if err != nil {
log.WithError(err).Error("cannot accept stage")
return err