support for mem_limit and memswap_limit
This commit is contained in:
@@ -48,6 +48,14 @@ func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
|
|||||||
// Resources: toResources(src), // TODO
|
// Resources: toResources(src), // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set container limits
|
||||||
|
if v := int64(src.MemLimit); v > 0 {
|
||||||
|
dst.MemLimit = v
|
||||||
|
}
|
||||||
|
if v := int64(src.MemSwapLimit); v > 0 {
|
||||||
|
dst.MemSwapLimit = v
|
||||||
|
}
|
||||||
|
|
||||||
// appends the volumes to the container def.
|
// appends the volumes to the container def.
|
||||||
for _, vol := range src.Volumes {
|
for _, vol := range src.Volumes {
|
||||||
dst.Volumes = append(dst.Volumes, &engine.VolumeMount{
|
dst.Volumes = append(dst.Volumes, &engine.VolumeMount{
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ func TestParse(t *testing.T) {
|
|||||||
"GOOS": &manifest.Variable{Value: "linux"},
|
"GOOS": &manifest.Variable{Value: "linux"},
|
||||||
"GOARCH": &manifest.Variable{Value: "arm64"},
|
"GOARCH": &manifest.Variable{Value: "arm64"},
|
||||||
},
|
},
|
||||||
Failure: "ignore",
|
MemLimit: manifest.BytesSize(1073741824),
|
||||||
|
MemSwapLimit: manifest.BytesSize(2147483648),
|
||||||
|
Failure: "ignore",
|
||||||
When: manifest.Conditions{
|
When: manifest.Conditions{
|
||||||
Event: manifest.Condition{
|
Event: manifest.Condition{
|
||||||
Include: []string{"push"},
|
Include: []string{"push"},
|
||||||
|
|||||||
@@ -83,29 +83,31 @@ func (p *Pipeline) GetStep(name string) *Step {
|
|||||||
type (
|
type (
|
||||||
// Step defines a Pipeline step.
|
// Step defines a Pipeline step.
|
||||||
Step struct {
|
Step struct {
|
||||||
Command []string `json:"command,omitempty"`
|
Command []string `json:"command,omitempty"`
|
||||||
Commands []string `json:"commands,omitempty"`
|
Commands []string `json:"commands,omitempty"`
|
||||||
Detach bool `json:"detach,omitempty"`
|
Detach bool `json:"detach,omitempty"`
|
||||||
DependsOn []string `json:"depends_on,omitempty" yaml:"depends_on"`
|
DependsOn []string `json:"depends_on,omitempty" yaml:"depends_on"`
|
||||||
Devices []*VolumeDevice `json:"devices,omitempty"`
|
Devices []*VolumeDevice `json:"devices,omitempty"`
|
||||||
DNS []string `json:"dns,omitempty"`
|
DNS []string `json:"dns,omitempty"`
|
||||||
DNSSearch []string `json:"dns_search,omitempty" yaml:"dns_search"`
|
DNSSearch []string `json:"dns_search,omitempty" yaml:"dns_search"`
|
||||||
Entrypoint []string `json:"entrypoint,omitempty"`
|
Entrypoint []string `json:"entrypoint,omitempty"`
|
||||||
Environment map[string]*manifest.Variable `json:"environment,omitempty"`
|
Environment map[string]*manifest.Variable `json:"environment,omitempty"`
|
||||||
ExtraHosts []string `json:"extra_hosts,omitempty" yaml:"extra_hosts"`
|
ExtraHosts []string `json:"extra_hosts,omitempty" yaml:"extra_hosts"`
|
||||||
Failure string `json:"failure,omitempty"`
|
Failure string `json:"failure,omitempty"`
|
||||||
Image string `json:"image,omitempty"`
|
Image string `json:"image,omitempty"`
|
||||||
Network string `json:"network_mode,omitempty" yaml:"network_mode"`
|
MemLimit manifest.BytesSize `json:"mem_limit,omitempty" yaml:"mem_limit"`
|
||||||
Name string `json:"name,omitempty"`
|
MemSwapLimit manifest.BytesSize `json:"memswap_limit,omitempty" yaml:"memswap_limit"`
|
||||||
Privileged bool `json:"privileged,omitempty"`
|
Network string `json:"network_mode,omitempty" yaml:"network_mode"`
|
||||||
Pull string `json:"pull,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Settings map[string]*manifest.Parameter `json:"settings,omitempty"`
|
Privileged bool `json:"privileged,omitempty"`
|
||||||
Shell string `json:"shell,omitempty"`
|
Pull string `json:"pull,omitempty"`
|
||||||
ShmSize manifest.BytesSize `json:"shm_size,omitempty" yaml:"shm_size"`
|
Settings map[string]*manifest.Parameter `json:"settings,omitempty"`
|
||||||
User string `json:"user,omitempty"`
|
Shell string `json:"shell,omitempty"`
|
||||||
Volumes []*VolumeMount `json:"volumes,omitempty"`
|
ShmSize manifest.BytesSize `json:"shm_size,omitempty" yaml:"shm_size"`
|
||||||
When manifest.Conditions `json:"when,omitempty"`
|
User string `json:"user,omitempty"`
|
||||||
WorkingDir string `json:"working_dir,omitempty" yaml:"working_dir"`
|
Volumes []*VolumeMount `json:"volumes,omitempty"`
|
||||||
|
When manifest.Conditions `json:"when,omitempty"`
|
||||||
|
WorkingDir string `json:"working_dir,omitempty" yaml:"working_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Volume that can be mounted by containers.
|
// Volume that can be mounted by containers.
|
||||||
|
|||||||
2
engine/resource/testdata/manifest.yml
vendored
2
engine/resource/testdata/manifest.yml
vendored
@@ -32,6 +32,8 @@ steps:
|
|||||||
image: golang
|
image: golang
|
||||||
detach: false
|
detach: false
|
||||||
failure: ignore
|
failure: ignore
|
||||||
|
mem_limit: 1GiB
|
||||||
|
memswap_limit: 2GiB
|
||||||
commands:
|
commands:
|
||||||
- go build
|
- go build
|
||||||
- go test
|
- go test
|
||||||
|
|||||||
Reference in New Issue
Block a user