libcontainer: export createCgroupConfig
A `config.Cgroups` object is required to manipulate cgroups v1 and v2 using libcontainer. Export `createCgroupConfig` to allow API users to create `config.Cgroups` objects using directly libcontainer API. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
7496a96825
commit
cd7c59d042
|
@ -196,7 +196,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
|
||||||
if err := createDevices(spec, config); err != nil {
|
if err := createDevices(spec, config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c, err := createCgroupConfig(opts)
|
c, err := CreateCgroupConfig(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCgroupConfig(opts *CreateOpts) (*configs.Cgroup, error) {
|
func CreateCgroupConfig(opts *CreateOpts) (*configs.Cgroup, error) {
|
||||||
var (
|
var (
|
||||||
myCgroupPath string
|
myCgroupPath string
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ func TestLinuxCgroupWithMemoryResource(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup, err := createCgroupConfig(opts)
|
cgroup, err := CreateCgroupConfig(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create Cgroup config: %v", err)
|
t.Errorf("Couldn't create Cgroup config: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func TestLinuxCgroupSystemd(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup, err := createCgroupConfig(opts)
|
cgroup, err := CreateCgroupConfig(opts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create Cgroup config: %v", err)
|
t.Errorf("Couldn't create Cgroup config: %v", err)
|
||||||
|
@ -293,7 +293,7 @@ func TestLinuxCgroupSystemdWithEmptyPath(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup, err := createCgroupConfig(opts)
|
cgroup, err := CreateCgroupConfig(opts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create Cgroup config: %v", err)
|
t.Errorf("Couldn't create Cgroup config: %v", err)
|
||||||
|
@ -328,7 +328,7 @@ func TestLinuxCgroupSystemdWithInvalidPath(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := createCgroupConfig(opts)
|
_, err := CreateCgroupConfig(opts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Expected to produce an error if not using the correct format for cgroup paths belonging to systemd")
|
t.Error("Expected to produce an error if not using the correct format for cgroup paths belonging to systemd")
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ func TestLinuxCgroupsPathSpecified(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup, err := createCgroupConfig(opts)
|
cgroup, err := CreateCgroupConfig(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create Cgroup config: %v", err)
|
t.Errorf("Couldn't create Cgroup config: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ func TestLinuxCgroupsPathNotSpecified(t *testing.T) {
|
||||||
Spec: spec,
|
Spec: spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup, err := createCgroupConfig(opts)
|
cgroup, err := CreateCgroupConfig(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Couldn't create Cgroup config: %v", err)
|
t.Errorf("Couldn't create Cgroup config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue