Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OOM adjustment flag to hostconfig via swarmctl cli #3177

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/api.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5803,6 +5803,13 @@ file {
type_name: ".docker.swarmkit.v1.ContainerSpec.Ulimit"
json_name: "ulimits"
}
field {
name: "oom_score_adj"
number: 30
label: LABEL_OPTIONAL
type: TYPE_INT64
json_name: "oomScoreAdj"
}
nested_type {
name: "LabelsEntry"
field {
Expand Down Expand Up @@ -11691,6 +11698,21 @@ file {
weak_dependency: 2
syntax: "proto3"
}
file {
name: "github.com/docker/swarmkit/api/test.proto"
package: "docker.swarmkit.v1"
message_type {
name: "TestService"
field {
name: "TestService"
number: 1
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "TestService"
}
}
syntax: "proto3"
}
file {
name: "github.com/docker/swarmkit/api/watch.proto"
package: "docker.swarmkit.v1"
Expand Down
353 changes: 193 additions & 160 deletions api/specs.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions api/specs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ message TaskSpec {
// Placement specifies node selection constraints
Placement placement = 5;



// LogDriver specifies the log driver to use for the task. Any runtime will
// direct logs into the specified driver for the duration of the task.
Driver log_driver = 6;
Expand Down Expand Up @@ -370,6 +372,8 @@ message ContainerSpec {
// Ulimits defines the list of ulimits to set in the container. This option
// is equivalent to passing --ulimit to docker run.
repeated Ulimit ulimits = 29;

int64 oom_score_adj = 30;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment, in the fashion of the comments above, explaining what the field does. These end up as godoc comments, so the comment should start with something like

// OomScoreAdj <sets/defines/verbs>

}

// EndpointSpec defines the properties that can be configured to
Expand Down
3 changes: 3 additions & 0 deletions api/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ message ResourceRequirements {
Resources limits = 1;
Resources reservations = 2;


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary edits in this file.

// Amount of swap in bytes - can only be used together with a memory limit
// -1 means unlimited
// a null pointer indicates that the default behaviour of granting twice
Expand All @@ -90,6 +91,8 @@ message ResourceRequirements {
// to the container OS's default - generally 60, or the value predefined in
// the image; set to -1 to unset a previously set value
google.protobuf.Int64Value memory_swappiness = 4;


}

message Platform {
Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarm-rafttool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

"github.com/moby/swarmkit/v2/swarmd/internal/defaults"
"github.com/moby/swarmkit/swarmd/internal/defaults"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/cluster/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"text/tabwriter"

gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/cluster/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"text/tabwriter"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/cluster/unlockkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"fmt"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/manager/encryption"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/cluster/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"time"

gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/cli"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/config/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"io"
"os"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/config/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"text/tabwriter"

gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/config/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/dustin/go-humanize"
gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/config/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
16 changes: 8 additions & 8 deletions swarmd/cmd/swarmctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
import (
"os"

"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/cluster"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/config"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/network"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/node"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/secret"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/service"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/task"
"github.com/moby/swarmkit/v2/swarmd/internal/defaults"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/cluster"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/config"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/network"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/node"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/secret"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/service"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/task"
"github.com/moby/swarmkit/swarmd/internal/defaults"
"github.com/moby/swarmkit/v2/version"
"github.com/spf13/cobra"
"google.golang.org/grpc/status"
Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net"
"strings"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/network/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"text/tabwriter"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/network/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"text/tabwriter"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/network/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/node/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"reflect"
"strings"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions swarmd/cmd/swarmctl/node/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"text/tabwriter"

"github.com/dustin/go-humanize"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/task"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/api/genericresource"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/task"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/node/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"text/tabwriter"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/node/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package node
import (
"errors"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/secret/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"io"
"os"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/secret/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"text/tabwriter"

gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/secret/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/dustin/go-humanize"
gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/secret/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions swarmd/cmd/swarmctl/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"fmt"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/service/flagparser"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/service/flagparser"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/service/flagparser/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
10 changes: 10 additions & 0 deletions swarmd/cmd/swarmctl/service/flagparser/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,15 @@ func parseContainer(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
}
}

if flags.Changed("oom-score-adj") {

oomScoreAdj, err := flags.GetInt64("oom-score-adj")
if err != nil {
return err
}

spec.Task.GetContainer().OomScoreAdj = oomScoreAdj
}

return nil
}
3 changes: 2 additions & 1 deletion swarmd/cmd/swarmctl/service/flagparser/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -50,6 +50,7 @@ func AddServiceFlags(flags *pflag.FlagSet) {
flags.String("restart-delay", "5s", "delay between task restarts")
flags.Uint64("restart-max-attempts", 0, "maximum number of restart attempts (0 = unlimited)")
flags.String("restart-window", "0s", "time window to evaluate restart attempts (0 = unbound)")
flags.Int64("oom-score-adj", 0, "oom score adjustment (-1000 to 1000)")

flags.StringSlice("constraint", nil, "Placement constraint (e.g. node.labels.key==value)")

Expand Down
4 changes: 2 additions & 2 deletions swarmd/cmd/swarmctl/service/flagparser/network.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package flagparser

import (
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/network"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/network"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion swarmd/cmd/swarmctl/service/flagparser/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions swarmd/cmd/swarmctl/service/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

"github.com/dustin/go-humanize"
gogotypes "github.com/gogo/protobuf/types"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/swarmd/cmd/swarmctl/task"
"github.com/moby/swarmkit/v2/api"
"github.com/moby/swarmkit/v2/api/genericresource"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/common"
"github.com/moby/swarmkit/v2/swarmd/cmd/swarmctl/task"
"github.com/spf13/cobra"
)

Expand Down
Loading
Loading