Skip to content

Commit c60fac9

Browse files
authored
remove network mode (#301)
1 parent 8cd5364 commit c60fac9

File tree

12 files changed

+5883
-3406
lines changed

12 files changed

+5883
-3406
lines changed

cluster/calcium/create.go

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ func (c *Calcium) doMakeWorkloadOptions(no int, msg *types.CreateWorkloadMessage
335335
config.Volumes = msg.VolumeLimit.ApplyPlan(msg.VolumePlanLimit).ToStringSlice(false, true)
336336
config.VolumePlan = msg.VolumePlanLimit.ToLiteral()
337337
config.Debug = opts.Debug
338-
config.Network = opts.NetworkMode
339338
config.Networks = opts.Networks
340339

341340
// entry

cluster/calcium/replace.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ func (c *Calcium) ReplaceWorkload(ctx context.Context, opts *types.ReplaceOption
1818
if err := opts.Validate(); err != nil {
1919
return nil, err
2020
}
21-
if opts.Count == 0 {
22-
opts.Count = 1
23-
}
21+
opts.Normalize()
2422
if len(opts.IDs) == 0 {
2523
if len(opts.Nodenames) == 0 {
2624
opts.Nodenames = []string{""}
@@ -83,7 +81,6 @@ func (c *Calcium) ReplaceWorkload(ctx context.Context, opts *types.ReplaceOption
8381
fmt.Sprintf("workload %s is not running, can not inherit", workload.ID),
8482
)
8583
}
86-
replaceOpts.NetworkMode = ""
8784
replaceOpts.Networks = info.Networks
8885
log.Infof("[ReplaceWorkload] Inherit old workload network configuration mode %v", replaceOpts.Networks)
8986
}

engine/docker/container.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ func (e *Engine) VirtualizationCreate(ctx context.Context, opts *enginetypes.Vir
5959
if opts.RestartPolicy == restartAlways {
6060
restartRetryCount = 0
6161
}
62+
// no longer use opts.Network as networkmode
63+
// always get network name from networks
64+
// -----------------------------------------
6265
// network mode 和 networks 互斥
6366
// 没有 networks 的时候用 networkmode 的值
6467
// 有 networks 的时候一律用用 networks 的值作为 mode
65-
networkMode := dockercontainer.NetworkMode(opts.Network)
68+
var networkMode dockercontainer.NetworkMode
6669
for name := range opts.Networks {
6770
networkMode = dockercontainer.NetworkMode(name)
6871
if networkMode.IsHost() {

engine/systemd/unit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (b *unitBuilder) buildNetworkLimit() *unitBuilder {
8686
return b
8787
}
8888

89-
network := b.opts.Network
89+
network := ""
9090
for net := range b.opts.Networks {
9191
if net != "" {
9292
network = net

engine/types/virtualization.go

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type VirtualizationCreateOptions struct {
3333

3434
RestartPolicy string
3535

36-
Network string
3736
Networks map[string]string
3837

3938
Volumes []string

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ require (
4343
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
4444
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc
4545
google.golang.org/grpc v1.28.0
46+
google.golang.org/protobuf v1.23.0
4647
gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect
4748
)

go.sum

+30-13
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)