Merge pull request #3231 from najohnsn/no-linux-section

fix createDevices when no Linux section
This commit is contained in:
Mrunal Patel
2021-10-18 13:53:35 -07:00
committed by GitHub
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -678,7 +678,7 @@ func createDevices(spec *specs.Spec, config *configs.Config) ([]*devices.Device,
next:
for _, ad := range AllowedDevices {
if ad.Path != "" {
if ad.Path != "" && spec.Linux != nil {
for _, sd := range spec.Linux.Devices {
if sd.Path == ad.Path {
continue next
+22
View File
@@ -546,6 +546,28 @@ func TestSpecconvExampleValidate(t *testing.T) {
}
}
func TestSpecconvNoLinuxSection(t *testing.T) {
spec := Example()
spec.Root.Path = "/"
spec.Linux = nil
spec.Hostname = ""
opts := &CreateOpts{
CgroupName: "ContainerID",
Spec: spec,
}
config, err := CreateLibcontainerConfig(opts)
if err != nil {
t.Errorf("Couldn't create libcontainer config: %v", err)
}
validator := validate.New()
if err := validator.Validate(config); err != nil {
t.Errorf("Expected specconv to produce valid container config: %v", err)
}
}
func TestDupNamespaces(t *testing.T) {
spec := &specs.Spec{
Root: &specs.Root{