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

fix CSI plugin load issue #3180

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 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
353 changes: 194 additions & 159 deletions api/specs.pb.go

Large diffs are not rendered by default.

5 changes: 5 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,9 @@ 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;
// OOmScoreAdj defines the relative value used for destroying a container during an OOM
// Values are between -1000 and 1000
int64 oom_score_adj = 30;
}

// EndpointSpec defines the properties that can be configured to
Expand Down
2 changes: 2 additions & 0 deletions api/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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
7 changes: 7 additions & 0 deletions manager/csi/fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package csi
import (
"context"
"fmt"
"net"
"strings"
"sync"

Expand Down Expand Up @@ -209,6 +210,7 @@ func (fpm *fakePluginMaker) newFakePlugin(pa mobyplugin.AddrPlugin, provider Sec
p := &fakePlugin{
name: pa.Name(),
socket: pa.Addr().String(),
addr: pa.Addr(),
swarmToCSI: map[string]string{},
volumesCreated: map[string]*api.Volume{},
volumesDeleted: []string{},
Expand All @@ -223,6 +225,7 @@ func (fpm *fakePluginMaker) newFakePlugin(pa mobyplugin.AddrPlugin, provider Sec
type fakePlugin struct {
name string
socket string
addr net.Addr
swarmToCSI map[string]string
// removedIDs is a set of node IDs for which RemoveNode has been called.
removedIDs map[string]struct{}
Expand Down Expand Up @@ -287,3 +290,7 @@ func (f *fakePlugin) AddNode(swarmID, csiID string) {
func (f *fakePlugin) RemoveNode(swarmID string) {
f.removedIDs[swarmID] = struct{}{}
}

func (f *fakePlugin) Addr() net.Addr {
return f.addr
}
8 changes: 8 additions & 0 deletions manager/csi/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -30,6 +31,7 @@ type Plugin interface {
UnpublishVolume(context.Context, *api.Volume, string) error
AddNode(swarmID, csiID string)
RemoveNode(swarmID string)
Addr() net.Addr
}

// plugin represents an individual CSI controller plugin
Expand All @@ -40,6 +42,7 @@ type plugin struct {

// socket is the unix socket to connect to this plugin at.
socket string
addr net.Addr

// provider is the SecretProvider, which allows retrieving secrets for CSI
// calls.
Expand Down Expand Up @@ -80,6 +83,7 @@ func NewPlugin(p mobyplugin.AddrPlugin, provider SecretProvider) Plugin {
// TODO(dperny): verify that we do not need to include the Network()
// portion of the Addr.
socket: fmt.Sprintf("%s://%s", p.Addr().Network(), p.Addr().String()),
addr: p.Addr(),
provider: provider,
swarmToCSI: map[string]string{},
csiToSwarm: map[string]string{},
Expand Down Expand Up @@ -341,3 +345,7 @@ func (p *plugin) makeControllerUnpublishVolumeRequest(v *api.Volume, nodeID stri
Secrets: secrets,
}
}

func (p *plugin) Addr() net.Addr {
return p.addr
}
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
}
1 change: 1 addition & 0 deletions swarmd/cmd/swarmctl/service/flagparser/flags.go
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions swarmd/dockerexec/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
Isolation: c.isolation(),
CapAdd: c.spec().CapabilityAdd,
CapDrop: c.spec().CapabilityDrop,
OomScoreAdj: int(c.spec().OomScoreAdj),
}

// The format of extra hosts on swarmkit is specified in:
Expand Down