summaryrefslogtreecommitdiff
path: root/coredump-handler
diff options
context:
space:
mode:
authorlinxin <[email protected]>2023-05-04 18:29:05 +0800
committerlinxin <[email protected]>2023-05-04 18:29:05 +0800
commitbd8134ad8a719f8c34dcfc0bafd80ae814ab673a (patch)
tree93f75cdda18626700caa650db45fb32c0b909511 /coredump-handler
parentc78ce80834e04ad105d46249f1bd3c0fa790e4d4 (diff)
修改命名规范,删除debug pod,增加挂载方案
Diffstat (limited to 'coredump-handler')
-rw-r--r--coredump-handler/coredump-handler.go12
-rw-r--r--coredump-handler/coredump-handler_test.go4
2 files changed, 8 insertions, 8 deletions
diff --git a/coredump-handler/coredump-handler.go b/coredump-handler/coredump-handler.go
index 4bd6f3b..f05c232 100644
--- a/coredump-handler/coredump-handler.go
+++ b/coredump-handler/coredump-handler.go
@@ -3,8 +3,8 @@ package main
import (
"archive/zip"
"context"
- "coredump-handler/config"
- "coredump-handler/types"
+ "coredump-tools/config"
+ "coredump-tools/types"
"encoding/json"
"errors"
"flag"
@@ -87,7 +87,7 @@ func getContainerId(pid string) (string, error) {
containerID := match[1]
return containerID, nil
}
-func getImageId(container_id string, sock_path string) (string, error) {
+func getImageName(container_id string, sock_path string) (string, error) {
// 连接 containerd daemon
client, err := containerd.New(sock_path)
if err != nil {
@@ -226,13 +226,13 @@ func main() {
container_id, err := getContainerId(coredump_config.Initial_ns_pid)
//根据查找到的container id查找对应的image name
if err == nil && len(container_id) != 0 {
- coredump_config.Image_id, err = getImageId(container_id, pipe_config.Containered_sock_path)
+ coredump_config.Image_name, err = getImageName(container_id, pipe_config.Containered_sock_path)
if err != nil {
journal.Print(journal.PriInfo, err.Error())
}
}
- if coredump_config.Image_id == "" {
- coredump_config.Image_id = "NULL"
+ if coredump_config.Image_name == "" {
+ coredump_config.Image_name = "NULL"
}
//根据配置项选择存储coredump文件方式
if pipe_config.Compress == false {
diff --git a/coredump-handler/coredump-handler_test.go b/coredump-handler/coredump-handler_test.go
index 3d309c6..aad83ec 100644
--- a/coredump-handler/coredump-handler_test.go
+++ b/coredump-handler/coredump-handler_test.go
@@ -3,7 +3,7 @@ package main
import (
"bufio"
"bytes"
- "coredump-handler/types"
+ "coredump-tools/types"
"fmt"
"io/ioutil"
"os"
@@ -76,7 +76,7 @@ func TestGetContainerId(t *testing.T) {
}
func TestGetImageId(t *testing.T) {
- image_id, err := getImageId("1234567890abcdef", "/var/run/containerd.sock")
+ image_id, err := getImageName("1234567890abcdef", "/var/run/containerd.sock")
if err != nil || len(image_id) == 0 {
t.Errorf("getImageId() error = %v; want image_id != \"\"", err)
}