option to set global shm_size

This commit is contained in:
Brad Rydzewski
2020-04-15 13:00:56 -04:00
parent db5468f23b
commit 80c26bc5d9
6 changed files with 17 additions and 3 deletions

View File

@@ -2,10 +2,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
- support for setting default container shmsize
### Changed
- update environment extension protocol to version 2
- registry credentials stored in repository secrets take precedence over globals
### Fixed
- ignoring global memory limit and memory swap limit
### Added
- support for environment extension variable masking
- support for username/password in config.json files

View File

@@ -76,6 +76,7 @@ type Config struct {
CPUPeriod int64 `envconfig:"DRONE_CPU_PERIOD"`
CPUShares int64 `envconfig:"DRONE_CPU_SHARES"`
CPUSet []string `envconfig:"DRONE_CPU_SET"`
ShmSize int64 `envconfig:"DRONE_SHM_SIZE"`
}
Environ struct {

View File

@@ -131,6 +131,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
CPUPeriod: config.Resources.CPUPeriod,
CPUShares: config.Resources.CPUShares,
CPUSet: config.Resources.CPUSet,
ShmSize: config.Resources.ShmSize,
},
Environ: provider.Combine(
provider.Static(config.Runner.Environ),

View File

@@ -51,6 +51,7 @@ type Resources struct {
CPUPeriod int64
CPUShares int64
CPUSet []string
ShmSize int64
}
// Compiler compiles the Yaml configuration file to an
@@ -371,12 +372,15 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
// the resource limits defined in the yaml currently
// take precedence over global values. This is something
// we should re-think in a future release.
if step.MemSwapLimit != 0 {
if step.MemSwapLimit == 0 {
step.MemSwapLimit = c.Resources.MemorySwap
}
if step.MemLimit != 0 {
if step.MemLimit == 0 {
step.MemLimit = c.Resources.Memory
}
if step.ShmSize == 0 {
step.ShmSize = c.Resources.ShmSize
}
step.CPUPeriod = c.Resources.CPUPeriod
step.CPUQuota = c.Resources.CPUQuota
step.CPUShares = c.Resources.CPUShares

2
go.mod
View File

@@ -12,7 +12,7 @@ require (
github.com/drone/drone-go v1.2.1-0.20200326064413-195394da1018
github.com/drone/drone-runtime v1.1.0
github.com/drone/envsubst v1.0.2
github.com/drone/runner-go v1.6.1-0.20200327163121-437a98da1948
github.com/drone/runner-go v1.6.1-0.20200415161953-7df9235cfbdb
github.com/drone/signal v1.0.0
github.com/ghodss/yaml v1.0.0
github.com/golang/mock v1.3.1

2
go.sum
View File

@@ -79,6 +79,8 @@ github.com/drone/runner-go v1.6.1-0.20200326064521-a238edf7e8d1 h1:jeZz31BlXzGx+
github.com/drone/runner-go v1.6.1-0.20200326064521-a238edf7e8d1/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
github.com/drone/runner-go v1.6.1-0.20200327163121-437a98da1948 h1:YZMRQrYZaDApfIQFtXUHusyeoWHWHlfnENxFrjr38fI=
github.com/drone/runner-go v1.6.1-0.20200327163121-437a98da1948/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
github.com/drone/runner-go v1.6.1-0.20200415161953-7df9235cfbdb h1:Z6sPkIuKY8rCpVPROlFlicdtH9/zPmn6TS9NFXnR1TA=
github.com/drone/runner-go v1.6.1-0.20200415161953-7df9235cfbdb/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=