77 lines
2.4 KiB
Diff
77 lines
2.4 KiB
Diff
From d704f38600a31138107460b7eba4a68a0b8362ea Mon Sep 17 00:00:00 2001
|
|
From: vegbir <yangjiaqi16@huawei.com>
|
|
Date: Tue, 26 Sep 2023 17:05:06 +0800
|
|
Subject: [PATCH] support isulad container engine
|
|
|
|
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
|
---
|
|
pkg/core/typedef/containerinfo.go | 5 +++++
|
|
pkg/core/typedef/rawpod.go | 8 ++++++--
|
|
2 files changed, 11 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/pkg/core/typedef/containerinfo.go b/pkg/core/typedef/containerinfo.go
|
|
index 39cb2cc..d810e5b 100644
|
|
--- a/pkg/core/typedef/containerinfo.go
|
|
+++ b/pkg/core/typedef/containerinfo.go
|
|
@@ -15,6 +15,7 @@
|
|
package typedef
|
|
|
|
import (
|
|
+ "fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
"sync"
|
|
@@ -32,12 +33,15 @@ const (
|
|
DOCKER
|
|
// CONTAINERD means containerd container engine
|
|
CONTAINERD
|
|
+ // ISULAD means isulad container engine
|
|
+ ISULAD
|
|
)
|
|
|
|
var (
|
|
supportEnginesPrefixMap = map[ContainerEngineType]string{
|
|
DOCKER: "docker://",
|
|
CONTAINERD: "containerd://",
|
|
+ ISULAD: "iSulad://",
|
|
}
|
|
currentContainerEngines = UNDEFINED
|
|
setContainerEnginesOnce sync.Once
|
|
@@ -85,6 +89,7 @@ func fixContainerEngine(containerID string) {
|
|
for engine, prefix := range supportEnginesPrefixMap {
|
|
if strings.HasPrefix(containerID, prefix) {
|
|
currentContainerEngines = engine
|
|
+ fmt.Printf("The container engine is %v\n", strings.Split(currentContainerEngines.Prefix(), ":")[0])
|
|
return
|
|
}
|
|
}
|
|
diff --git a/pkg/core/typedef/rawpod.go b/pkg/core/typedef/rawpod.go
|
|
index 59dfb59..138c580 100644
|
|
--- a/pkg/core/typedef/rawpod.go
|
|
+++ b/pkg/core/typedef/rawpod.go
|
|
@@ -149,7 +149,11 @@ func (pod *RawPod) ExtractContainerInfos() map[string]*ContainerInfo {
|
|
podCgroupPath := pod.CgroupPath()
|
|
for _, rawContainer := range nameRawContainersMap {
|
|
id, err := rawContainer.GetRealContainerID()
|
|
- if id == "" || err != nil {
|
|
+ if err != nil {
|
|
+ fmt.Printf("failed to parse container ID: %v\n", err)
|
|
+ continue
|
|
+ }
|
|
+ if id == "" {
|
|
continue
|
|
}
|
|
idContainersMap[id] = NewContainerInfo(id, podCgroupPath, rawContainer)
|
|
@@ -169,7 +173,7 @@ func (cont *RawContainer) GetRealContainerID() (string, error) {
|
|
setContainerEnginesOnce.Do(func() { fixContainerEngine(cont.status.ContainerID) })
|
|
|
|
if !currentContainerEngines.Support(cont) {
|
|
- return "", fmt.Errorf("fatal error : unsupported container engine")
|
|
+ return "", fmt.Errorf("unsupported container engine: %v", cont.status.ContainerID)
|
|
}
|
|
|
|
cid := cont.status.ContainerID[len(currentContainerEngines.Prefix()):]
|
|
--
|
|
2.25.1
|
|
|