Merge pull request #5145 from psaintlaurent/ENGINE-903
Add OomScoreAdj to "docker service create" and "docker compose"
This commit is contained in:
@ -68,6 +68,8 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
flags.SetAnnotation(flagSysCtl, "version", []string{"1.40"})
|
||||
flags.Var(&opts.ulimits, flagUlimit, "Ulimit options")
|
||||
flags.SetAnnotation(flagUlimit, "version", []string{"1.41"})
|
||||
flags.Int64Var(&opts.oomScoreAdj, flagOomScoreAdj, 0, "Tune host's OOM preferences (-1000 to 1000) ")
|
||||
flags.SetAnnotation(flagOomScoreAdj, "version", []string{"1.46"})
|
||||
|
||||
flags.Var(cliopts.NewListOptsRef(&opts.resources.resGenericResources, ValidateSingleGenericResource), "generic-resource", "User defined resources")
|
||||
flags.SetAnnotation(flagHostAdd, "version", []string{"1.32"})
|
||||
|
||||
@ -529,6 +529,7 @@ type serviceOptions struct {
|
||||
capAdd opts.ListOpts
|
||||
capDrop opts.ListOpts
|
||||
ulimits opts.UlimitOpt
|
||||
oomScoreAdj int64
|
||||
|
||||
resources resourceOptions
|
||||
stopGrace opts.DurationOpt
|
||||
@ -747,6 +748,7 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N
|
||||
CapabilityAdd: capAdd,
|
||||
CapabilityDrop: capDrop,
|
||||
Ulimits: options.ulimits.GetList(),
|
||||
OomScoreAdj: options.oomScoreAdj,
|
||||
},
|
||||
Networks: networks,
|
||||
Resources: resources,
|
||||
@ -1043,6 +1045,7 @@ const (
|
||||
flagUlimit = "ulimit"
|
||||
flagUlimitAdd = "ulimit-add"
|
||||
flagUlimitRemove = "ulimit-rm"
|
||||
flagOomScoreAdj = "oom-score-adj"
|
||||
)
|
||||
|
||||
func validateAPIVersion(c swarm.ServiceSpec, serverAPIVersion string) error {
|
||||
|
||||
@ -108,6 +108,8 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
flags.SetAnnotation(flagUlimitAdd, "version", []string{"1.41"})
|
||||
flags.Var(newListOptsVar(), flagUlimitRemove, "Remove a ulimit option")
|
||||
flags.SetAnnotation(flagUlimitRemove, "version", []string{"1.41"})
|
||||
flags.Int64Var(&options.oomScoreAdj, flagOomScoreAdj, 0, "Tune host's OOM preferences (-1000 to 1000) ")
|
||||
flags.SetAnnotation(flagOomScoreAdj, "version", []string{"1.46"})
|
||||
|
||||
// Add needs parsing, Remove only needs the key
|
||||
flags.Var(newListOptsVar(), flagGenericResourcesRemove, "Remove a Generic resource")
|
||||
@ -367,6 +369,10 @@ func updateService(ctx context.Context, apiClient client.NetworkAPIClient, flags
|
||||
updateInt64Value(flagReserveMemory, &task.Resources.Reservations.MemoryBytes)
|
||||
}
|
||||
|
||||
if anyChanged(flags, flagOomScoreAdj) {
|
||||
updateInt64(flagOomScoreAdj, &task.ContainerSpec.OomScoreAdj)
|
||||
}
|
||||
|
||||
if err := addGenericResources(flags, task); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user