@@ -46,7 +46,6 @@ import (
46
46
"github.com/containerd/nerdctl/v2/pkg/imgutil"
47
47
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/native"
48
48
"github.com/containerd/nerdctl/v2/pkg/labels"
49
- "github.com/containerd/nerdctl/v2/pkg/logging"
50
49
"github.com/containerd/nerdctl/v2/pkg/ocihook/state"
51
50
)
52
51
@@ -97,7 +96,14 @@ type ImageMetadata struct {
97
96
98
97
type LogConfig struct {
99
98
Type string
100
- Config logging.LogConfig
99
+ Config loggerLogConfig
100
+ }
101
+
102
+ type loggerLogConfig struct {
103
+ Driver string `json:"driver"`
104
+ Opts map [string ]string `json:"opts,omitempty"`
105
+ LogURI string `json:"-"`
106
+ Address string `json:"address"`
101
107
}
102
108
103
109
// Container mimics a `docker container inspect` object.
@@ -138,7 +144,9 @@ type HostConfig struct {
138
144
ExtraHosts []string // List of extra hosts
139
145
PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
140
146
LogConfig LogConfig // Configuration of the logs for this container
141
-
147
+ BlkioWeight uint16 // Block IO weight (relative weight vs. other containers)
148
+ CpusetMems string // CpusetMems 0-2, 0,1
149
+ CpusetCpus string // CpusetCpus 0-2, 0,1
142
150
}
143
151
144
152
// From https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L416-L427
@@ -304,10 +312,9 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
304
312
305
313
if nerdctlLoguri := n .Labels [labels .LogURI ]; nerdctlLoguri != "" {
306
314
c .HostConfig .LogConfig .Type = nerdctlLoguri
307
- // c.HostConfig.LogConfig.Config = map[string]string{}
308
315
}
309
316
if logConfigJSON , ok := n .Labels [labels .LogConfig ]; ok {
310
- var logConfig logging. LogConfig
317
+ var logConfig loggerLogConfig
311
318
err := json .Unmarshal ([]byte (logConfigJSON ), & logConfig )
312
319
if err != nil {
313
320
return nil , fmt .Errorf ("failed to unmarshal log config: %v" , err )
@@ -317,12 +324,29 @@ func ContainerFromNative(n *native.Container) (*Container, error) {
317
324
c .HostConfig .LogConfig .Config = logConfig
318
325
} else {
319
326
// If LogConfig label is not present, set default values
320
- c .HostConfig .LogConfig .Config = logging. LogConfig {
327
+ c .HostConfig .LogConfig .Config = loggerLogConfig {
321
328
Driver : "json-file" ,
322
329
Opts : make (map [string ]string ),
323
330
}
324
331
}
325
332
333
+ if blkioWeightSet := n .Labels [labels .BlkioWeight ]; blkioWeightSet != "" {
334
+ var blkioWeight uint16
335
+ _ , err := fmt .Sscanf (blkioWeightSet , "%d" , & blkioWeight )
336
+ if err != nil {
337
+ return nil , fmt .Errorf ("failed to convert string to uint: %v" , err )
338
+ }
339
+ c .HostConfig .BlkioWeight = blkioWeight
340
+ }
341
+
342
+ if cpusetmems := n .Labels [labels .CPUSetMems ]; cpusetmems != "" {
343
+ c .HostConfig .CpusetMems = cpusetmems
344
+ }
345
+
346
+ if cpusetcpus := n .Labels [labels .CPUSetCPUs ]; cpusetcpus != "" {
347
+ c .HostConfig .CpusetCpus = cpusetcpus
348
+ }
349
+
326
350
cs := new (ContainerState )
327
351
cs .Restarting = n .Labels [restart .StatusLabel ] == string (containerd .Running )
328
352
cs .Error = n .Labels [labels .Error ]
0 commit comments