runtime: fail early when starting docker container with FC

FC does not support network device hotplug. Let's add a check to fail
early when starting containers created by docker.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao
2023-08-22 11:17:31 +00:00
parent 32fd013716
commit 21204caf20
3 changed files with 54 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import (
"syscall"
"testing"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
@@ -580,3 +581,25 @@ func TestRevertBytes(t *testing.T) {
num := RevertBytes(testNum)
assert.Equal(expectedNum, num)
}
func TestIsDockerContainer(t *testing.T) {
assert := assert.New(t)
ociSpec := &specs.Spec{
Hooks: &specs.Hooks{
Prestart: []specs.Hook{
{
Args: []string{
"haha",
},
},
},
},
}
assert.False(IsDockerContainer(ociSpec))
ociSpec.Hooks.Prestart = append(ociSpec.Hooks.Prestart, specs.Hook{
Args: []string{"libnetwork-xxx"},
})
assert.True(IsDockerContainer(ociSpec))
}