Skip to content

Commit 8f7a8c7

Browse files
committed
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent ba23bf2 commit 8f7a8c7

File tree

26 files changed

+137
-75
lines changed

26 files changed

+137
-75
lines changed

api/client/container/update.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,21 @@ func runUpdate(dockerCli *client.DockerCli, opts *updateOptions) error {
135135

136136
ctx := context.Background()
137137

138-
var errs []string
138+
var (
139+
warns []string
140+
errs []string
141+
)
139142
for _, container := range opts.containers {
140-
if err := dockerCli.Client().ContainerUpdate(ctx, container, updateConfig); err != nil {
143+
r, err := dockerCli.Client().ContainerUpdate(ctx, container, updateConfig)
144+
if err != nil {
141145
errs = append(errs, err.Error())
142146
} else {
143147
fmt.Fprintf(dockerCli.Out(), "%s\n", container)
144148
}
149+
warns = append(warns, r.Warnings...)
150+
}
151+
if len(warns) > 0 {
152+
fmt.Fprintf(dockerCli.Out(), "%s", strings.Join(warns, "\n"))
145153
}
146154
if len(errs) > 0 {
147155
return fmt.Errorf("%s", strings.Join(errs, "\n"))

api/client/network/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func runCreate(dockerCli *client.DockerCli, opts createOptions) error {
7979
nc := types.NetworkCreate{
8080
Driver: opts.driver,
8181
Options: opts.driverOpts.GetAll(),
82-
IPAM: network.IPAM{
82+
IPAM: &network.IPAM{
8383
Driver: opts.ipamDriver,
8484
Config: ipamCfg,
8585
Options: opts.ipamOpt.GetAll(),

api/client/stack/deploy.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/docker/docker/api/client/bundlefile"
1313
"github.com/docker/docker/cli"
1414
"github.com/docker/engine-api/types"
15-
"github.com/docker/engine-api/types/network"
1615
"github.com/docker/engine-api/types/swarm"
1716
)
1817

@@ -105,8 +104,6 @@ func updateNetworks(
105104
createOpts := types.NetworkCreate{
106105
Labels: getStackLabels(namespace, nil),
107106
Driver: defaultNetworkDriver,
108-
// TODO: remove when engine-api uses omitempty for IPAM
109-
IPAM: network.IPAM{Driver: "default"},
110107
}
111108

112109
for _, internalName := range networks {

api/client/swarm/opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) {
172172
func (opts *swarmOptions) ToSpec() swarm.Spec {
173173
spec := swarm.Spec{}
174174
spec.Orchestration.TaskHistoryRetentionLimit = opts.taskHistoryLimit
175-
spec.Dispatcher.HeartbeatPeriod = uint64(opts.dispatcherHeartbeat.Nanoseconds())
175+
spec.Dispatcher.HeartbeatPeriod = opts.dispatcherHeartbeat
176176
spec.CAConfig.NodeCertExpiry = opts.nodeCertExpiry
177177
spec.CAConfig.ExternalCAs = opts.externalCA.Value()
178178
return spec

api/client/swarm/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func mergeSwarm(swarm *swarm.Swarm, flags *pflag.FlagSet) error {
6363

6464
if flags.Changed(flagDispatcherHeartbeat) {
6565
if v, err := flags.GetDuration(flagDispatcherHeartbeat); err == nil {
66-
spec.Dispatcher.HeartbeatPeriod = uint64(v.Nanoseconds())
66+
spec.Dispatcher.HeartbeatPeriod = v
6767
}
6868
}
6969

api/server/router/container/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type stateBackend interface {
4242
ContainerStart(name string, hostConfig *container.HostConfig, validateHostname bool) error
4343
ContainerStop(name string, seconds int) error
4444
ContainerUnpause(name string) error
45-
ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) ([]string, error)
45+
ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) (types.ContainerUpdateResponse, error)
4646
ContainerWait(name string, timeout time.Duration) (int, error)
4747
}
4848

api/server/router/container/container_routes.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,12 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
327327

328328
name := vars["name"]
329329
validateHostname := versions.GreaterThanOrEqualTo(version, "1.24")
330-
warnings, err := s.backend.ContainerUpdate(name, hostConfig, validateHostname)
330+
resp, err := s.backend.ContainerUpdate(name, hostConfig, validateHostname)
331331
if err != nil {
332332
return err
333333
}
334334

335-
return httputils.WriteJSON(w, http.StatusOK, &types.ContainerUpdateResponse{
336-
Warnings: warnings,
337-
})
335+
return httputils.WriteJSON(w, http.StatusOK, resp)
338336
}
339337

340338
func (s *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

daemon/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var defaultSpec = types.Spec{
6767
NodeCertExpiry: 90 * 24 * time.Hour,
6868
},
6969
Dispatcher: types.DispatcherConfig{
70-
HeartbeatPeriod: uint64((5 * time.Second).Nanoseconds()),
70+
HeartbeatPeriod: 5 * time.Second,
7171
},
7272
Orchestration: types.OrchestrationConfig{
7373
TaskHistoryRetentionLimit: 10,

daemon/cluster/convert/network.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,23 @@ func BasicNetworkCreateToGRPC(create basictypes.NetworkCreateRequest) swarmapi.N
179179
},
180180
Ipv6Enabled: create.EnableIPv6,
181181
Internal: create.Internal,
182-
IPAM: &swarmapi.IPAMOptions{
182+
}
183+
if create.IPAM != nil {
184+
ns.IPAM = &swarmapi.IPAMOptions{
183185
Driver: &swarmapi.Driver{
184186
Name: create.IPAM.Driver,
185187
Options: create.IPAM.Options,
186188
},
187-
},
188-
}
189-
ipamSpec := make([]*swarmapi.IPAMConfig, 0, len(create.IPAM.Config))
190-
for _, ipamConfig := range create.IPAM.Config {
191-
ipamSpec = append(ipamSpec, &swarmapi.IPAMConfig{
192-
Subnet: ipamConfig.Subnet,
193-
Range: ipamConfig.IPRange,
194-
Gateway: ipamConfig.Gateway,
195-
})
189+
}
190+
ipamSpec := make([]*swarmapi.IPAMConfig, 0, len(create.IPAM.Config))
191+
for _, ipamConfig := range create.IPAM.Config {
192+
ipamSpec = append(ipamSpec, &swarmapi.IPAMConfig{
193+
Subnet: ipamConfig.Subnet,
194+
Range: ipamConfig.IPRange,
195+
Gateway: ipamConfig.Gateway,
196+
})
197+
}
198+
ns.IPAM.Configs = ipamSpec
196199
}
197-
ns.IPAM.Configs = ipamSpec
198200
return ns
199201
}

daemon/cluster/convert/swarm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
2323
SnapshotInterval: c.Spec.Raft.SnapshotInterval,
2424
KeepOldSnapshots: c.Spec.Raft.KeepOldSnapshots,
2525
LogEntriesForSlowFollowers: c.Spec.Raft.LogEntriesForSlowFollowers,
26-
HeartbeatTick: c.Spec.Raft.HeartbeatTick,
27-
ElectionTick: c.Spec.Raft.ElectionTick,
26+
HeartbeatTick: int(c.Spec.Raft.HeartbeatTick),
27+
ElectionTick: int(c.Spec.Raft.ElectionTick),
2828
},
2929
},
3030
},
@@ -35,7 +35,7 @@ func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
3535
}
3636

3737
heartbeatPeriod, _ := ptypes.Duration(c.Spec.Dispatcher.HeartbeatPeriod)
38-
swarm.Spec.Dispatcher.HeartbeatPeriod = uint64(heartbeatPeriod)
38+
swarm.Spec.Dispatcher.HeartbeatPeriod = heartbeatPeriod
3939

4040
swarm.Spec.CAConfig.NodeCertExpiry, _ = ptypes.Duration(c.Spec.CAConfig.NodeCertExpiry)
4141

@@ -73,8 +73,8 @@ func SwarmSpecToGRPC(s types.Spec) (swarmapi.ClusterSpec, error) {
7373
SnapshotInterval: s.Raft.SnapshotInterval,
7474
KeepOldSnapshots: s.Raft.KeepOldSnapshots,
7575
LogEntriesForSlowFollowers: s.Raft.LogEntriesForSlowFollowers,
76-
HeartbeatTick: s.Raft.HeartbeatTick,
77-
ElectionTick: s.Raft.ElectionTick,
76+
HeartbeatTick: uint32(s.Raft.HeartbeatTick),
77+
ElectionTick: uint32(s.Raft.ElectionTick),
7878
},
7979
Dispatcher: swarmapi.DispatcherConfig{
8080
HeartbeatPeriod: ptypes.DurationProto(time.Duration(s.Dispatcher.HeartbeatPeriod)),

0 commit comments

Comments
 (0)