Skip to content

Commit

Permalink
Allow for OomScoreAdj
Browse files Browse the repository at this point in the history
Signed-off-by: plaurent <[email protected]>
  • Loading branch information
psaintlaurent committed Jun 28, 2024
1 parent f738c98 commit 02761fd
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cli/command/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ 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.Var(&opts.oomScoreAdj, flagOomScoreAdj, "oom score adjustment (-1000 to 1000)")
flags.Int64Var(&opts.oomScoreAdj, flagOomScoreAdj, 0, "oom score adjustment (-1000 to 1000)")

flags.Var(cliopts.NewListOptsRef(&opts.resources.resGenericResources, ValidateSingleGenericResource), "generic-resource", "User defined resources")
flags.SetAnnotation(flagHostAdd, "version", []string{"1.32"})
Expand Down
6 changes: 3 additions & 3 deletions cli/command/service/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ type serviceOptions struct {
capAdd opts.ListOpts
capDrop opts.ListOpts
ulimits opts.UlimitOpt
oomScoreAdj opts.OomScoreAdj
oomScoreAdj int64

resources resourceOptions
stopGrace opts.DurationOpt
Expand Down Expand Up @@ -576,7 +576,7 @@ func newServiceOptions() *serviceOptions {
capAdd: opts.NewListOpts(nil),
capDrop: opts.NewListOpts(nil),
ulimits: *opts.NewUlimitOpt(nil),
oomScoreAdj: opts.OomScoreAdj(0),
oomScoreAdj: int64(opts.OomScoreAdj(0)),
}
}

Expand Down Expand Up @@ -749,7 +749,7 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N
CapabilityAdd: capAdd,
CapabilityDrop: capDrop,
Ulimits: options.ulimits.GetList(),
OomScoreAdj: options.oomScoreAdj.Value(),
OomScoreAdj: options.oomScoreAdj,
},
Networks: networks,
Resources: resources,
Expand Down
2 changes: 1 addition & 1 deletion cli/command/service/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ 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.Var(&options.oomScoreAdj, flagOomScoreAdj, "oom score adjustment (-1000 to 1000)")
flags.Int64Var(&options.oomScoreAdj, flagOomScoreAdj, 0, "oom score adjustment (-1000 to 1000)")

// Add needs parsing, Remove only needs the key
flags.Var(newListOptsVar(), flagGenericResourcesRemove, "Remove a Generic resource")
Expand Down
1 change: 1 addition & 0 deletions docs/reference/commandline/service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Create a new service
| `--name` | `string` | | Service name |
| [`--network`](#network) | `network` | | Network attachments |
| `--no-healthcheck` | | | Disable any container-specified HEALTHCHECK |
| `--oom-score-adj` | `int64` | `0` | oom score adjustment (-1000 to 1000) |
| `--no-resolve-image` | | | Do not query the registry to resolve image digest and supported platforms |
| [`--placement-pref`](#placement-pref) | `pref` | | Add a placement preference |
| [`-p`](#publish), [`--publish`](#publish) | `port` | | Publish a port as a node port |
Expand Down
1 change: 1 addition & 0 deletions docs/reference/commandline/service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Update a service
| `--network-rm` | `list` | | Remove a network |
| `--no-healthcheck` | | | Disable any container-specified HEALTHCHECK |
| `--no-resolve-image` | | | Do not query the registry to resolve image digest and supported platforms |
| `--oom-score-adj` | `int64` | `0` | oom score adjustment (-1000 to 1000) |
| `--placement-pref-add` | `pref` | | Add a placement preference |
| `--placement-pref-rm` | `pref` | | Remove a placement preference |
| [`--publish-add`](#publish-add) | `port` | | Add or update a published port |
Expand Down
5 changes: 2 additions & 3 deletions opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,8 @@ func (o *OomScoreAdj) String() string {
}

func (o *OomScoreAdj) Set(value string) error {

var conv int64
conv, _ = strconv.ParseInt(value, 10, 64)
conv, err := strconv.ParseInt(value, 10, 64)
*o = OomScoreAdj(conv)
return nil
return err
}
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ github.com/docker/distribution/registry/client/transport
github.com/docker/distribution/registry/storage/cache
github.com/docker/distribution/registry/storage/cache/memory
github.com/docker/distribution/uuid
github.com/docker/docker v27.0.1-rc.1.0.20240621131212-ff1e2c0de72a+incompatible
# github.com/docker/docker v27.0.1-rc.1.0.20240621131212-ff1e2c0de72a+incompatible
## explicit
github.com/docker/docker/api
github.com/docker/docker/api/types
Expand Down

0 comments on commit 02761fd

Please sign in to comment.