Add --cpus flag to ctr
Signed-off-by: Michael Crosby <michael@thepasture.io>
This commit is contained in:
parent
eb6354a118
commit
02afa94256
@ -58,6 +58,11 @@ var platformRunFlags = []cli.Flag{
|
||||
Name: "remap-labels",
|
||||
Usage: "provide the user namespace ID remapping to the snapshotter via label options; requires snapshotter support",
|
||||
},
|
||||
cli.Float64Flag{
|
||||
Name: "cpus",
|
||||
Usage: "set the CFS cpu qouta",
|
||||
Value: 0.0,
|
||||
},
|
||||
}
|
||||
|
||||
// NewContainer creates a new container
|
||||
@ -179,6 +184,13 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if context.Bool("seccomp") {
|
||||
opts = append(opts, seccomp.WithDefaultProfile())
|
||||
}
|
||||
if cpus := context.Float64("cpus"); cpus > 0.0 {
|
||||
var (
|
||||
period = uint64(100000)
|
||||
quota = int64(cpus * 100000.0)
|
||||
)
|
||||
opts = append(opts, oci.WithCPUCFS(quota, period))
|
||||
}
|
||||
|
||||
joinNs := context.StringSlice("with-ns")
|
||||
for _, ns := range joinNs {
|
||||
|
@ -118,3 +118,10 @@ func deviceFromPath(path, permissions string) (*specs.LinuxDevice, error) {
|
||||
GID: &stat.Gid,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// WithCPUCFS sets the container's Completely fair scheduling (CFS) quota and period
|
||||
func WithCPUCFS(quota int64, period uint64) SpecOpts {
|
||||
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user