drop useless function error and info
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
This commit is contained in:
parent
8e6534fb98
commit
17baa749a7
265
0010-drop-useless-function-error-and-info.patch
Normal file
265
0010-drop-useless-function-error-and-info.patch
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
From f5cc3ac5b6ecd78adbccd6792c2705c850a1c189 Mon Sep 17 00:00:00 2001
|
||||||
|
From: vegbir <yangjiaqi16@huawei.com>
|
||||||
|
Date: Tue, 29 Aug 2023 09:01:50 +0000
|
||||||
|
Subject: [PATCH] drop useless function error and info
|
||||||
|
|
||||||
|
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||||
|
---
|
||||||
|
container/container.go | 14 +++++++++-----
|
||||||
|
hack/syscontainer-tools_wrapper | 1 -
|
||||||
|
hooks/syscontainer-hooks/poststop.go | 2 +-
|
||||||
|
libdevice/binds_unix.go | 2 +-
|
||||||
|
libdevice/container_work.go | 7 ++++---
|
||||||
|
libnetwork/drivers/eth/driver.go | 9 +++++----
|
||||||
|
pkg/udevd/udevd.go | 9 ++++++---
|
||||||
|
pkg/udevd/udevd_controller.go | 6 ++++--
|
||||||
|
utils/transfer.go | 2 +-
|
||||||
|
utils/utils.go | 12 ++++++++++++
|
||||||
|
10 files changed, 43 insertions(+), 21 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/container/container.go b/container/container.go
|
||||||
|
index 67f6b53..fb9b20f 100644
|
||||||
|
--- a/container/container.go
|
||||||
|
+++ b/container/container.go
|
||||||
|
@@ -125,7 +125,9 @@ func (c *Container) Lock() error {
|
||||||
|
// LOCK_EX means only one process could lock it at one time.
|
||||||
|
// LOCK_NB is not set, using block mode.
|
||||||
|
if err := unix.Flock(int(f.Fd()), unix.LOCK_EX); err != nil {
|
||||||
|
- f.Close()
|
||||||
|
+ if closeErr := f.Close(); closeErr != nil {
|
||||||
|
+ logrus.Warnf("fail to close %v: %v", fileName, closeErr)
|
||||||
|
+ }
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.lock = f
|
||||||
|
@@ -147,9 +149,9 @@ func (c *Container) GetCgroupPath() (string, error) {
|
||||||
|
return "", fmt.Errorf("%s: %v", string(out), err)
|
||||||
|
}
|
||||||
|
cgroupPath := strings.Trim(string(out), "\n")
|
||||||
|
- if len(cgroupPath) >= 2 {
|
||||||
|
- cgroupPath = cgroupPath[1 : len(cgroupPath)-1]
|
||||||
|
- }
|
||||||
|
+ if len(cgroupPath) >= 2 {
|
||||||
|
+ cgroupPath = cgroupPath[1 : len(cgroupPath)-1]
|
||||||
|
+ }
|
||||||
|
if cgroupPath == "" {
|
||||||
|
// by default, the cgroup path is "/isulad/<id>"
|
||||||
|
cgroupPath = "/isulad"
|
||||||
|
@@ -204,7 +206,9 @@ func getIsuladContainerSpec(id string) (spec *specs.Spec, err error) {
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if config != nil {
|
||||||
|
- config.Close()
|
||||||
|
+ if closeErr := config.Close(); closeErr != nil {
|
||||||
|
+ logrus.Warnf("fail to close %v: %v", configPath, closeErr)
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err := json.NewDecoder(config).Decode(&spec); err != nil {
|
||||||
|
diff --git a/hack/syscontainer-tools_wrapper b/hack/syscontainer-tools_wrapper
|
||||||
|
index 671eec3..33db18e 100644
|
||||||
|
--- a/hack/syscontainer-tools_wrapper
|
||||||
|
+++ b/hack/syscontainer-tools_wrapper
|
||||||
|
@@ -9,7 +9,6 @@
|
||||||
|
# PURPOSE.
|
||||||
|
# See the Mulan PSL v2 for more details.
|
||||||
|
# Description: syscontainer tools wrapper
|
||||||
|
-# Author: zhangsong234
|
||||||
|
# Create: 2020-01-17
|
||||||
|
|
||||||
|
LOG_DIR=/var/log/hyperagent
|
||||||
|
diff --git a/hooks/syscontainer-hooks/poststop.go b/hooks/syscontainer-hooks/poststop.go
|
||||||
|
index 35f648e..8f03bd7 100644
|
||||||
|
--- a/hooks/syscontainer-hooks/poststop.go
|
||||||
|
+++ b/hooks/syscontainer-hooks/poststop.go
|
||||||
|
@@ -86,7 +86,7 @@ func RemoveNetworkDevices(state *configs.HookState, hookConfig *hconfig.Containe
|
||||||
|
if err := os.Remove(file.Name()); err != nil {
|
||||||
|
logrus.Errorf("Failed to remove fileName err: %v", err)
|
||||||
|
}
|
||||||
|
- file.Close()
|
||||||
|
+ utils.DropError(file.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
|
for _, nic := range hookConfig.NetworkInterfaces {
|
||||||
|
diff --git a/libdevice/binds_unix.go b/libdevice/binds_unix.go
|
||||||
|
index 2c45700..ca784c0 100644
|
||||||
|
--- a/libdevice/binds_unix.go
|
||||||
|
+++ b/libdevice/binds_unix.go
|
||||||
|
@@ -128,7 +128,7 @@ func findPathDevice(path string) (*types.Device, string, error) {
|
||||||
|
reader := bufio.NewReader(stdout)
|
||||||
|
|
||||||
|
// ignore first line.
|
||||||
|
- reader.ReadString('\n')
|
||||||
|
+ utils.DropError(reader.ReadString('\n'))
|
||||||
|
line, err := reader.ReadString('\n')
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("reader.ReadString error: %v", err)
|
||||||
|
diff --git a/libdevice/container_work.go b/libdevice/container_work.go
|
||||||
|
index 050438f..07bfdfa 100644
|
||||||
|
--- a/libdevice/container_work.go
|
||||||
|
+++ b/libdevice/container_work.go
|
||||||
|
@@ -16,7 +16,6 @@ package libdevice
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
- "github.com/sirupsen/logrus"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
@@ -26,6 +25,8 @@ import (
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
|
+ "github.com/sirupsen/logrus"
|
||||||
|
+
|
||||||
|
"isula.org/syscontainer-tools/libdevice/nsexec"
|
||||||
|
"isula.org/syscontainer-tools/pkg/mount"
|
||||||
|
"isula.org/syscontainer-tools/types"
|
||||||
|
@@ -158,7 +159,7 @@ func doMount(pipe *os.File) error {
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("fail to create %s, err: %s", mnt.Destination, err)
|
||||||
|
}
|
||||||
|
- f.Close()
|
||||||
|
+ utils.DropError(f.Close())
|
||||||
|
}
|
||||||
|
return mount.Mount(mnt.Source, mnt.Destination, "none", mnt.Options)
|
||||||
|
}
|
||||||
|
@@ -290,7 +291,7 @@ func doAddBind(pipe *os.File) error {
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("fail to create transfer path,err: %s", err)
|
||||||
|
}
|
||||||
|
- f.Close()
|
||||||
|
+ utils.DropError(f.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Chown(bind.ContainerPath, bind.UID, bind.GID); err != nil {
|
||||||
|
diff --git a/libnetwork/drivers/eth/driver.go b/libnetwork/drivers/eth/driver.go
|
||||||
|
index 901ec9c..549e186 100644
|
||||||
|
--- a/libnetwork/drivers/eth/driver.go
|
||||||
|
+++ b/libnetwork/drivers/eth/driver.go
|
||||||
|
@@ -26,6 +26,7 @@ import (
|
||||||
|
"isula.org/syscontainer-tools/libnetwork/drivers/common"
|
||||||
|
"isula.org/syscontainer-tools/libnetwork/nsutils"
|
||||||
|
"isula.org/syscontainer-tools/pkg/ethtool"
|
||||||
|
+ "isula.org/syscontainer-tools/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ethDriver struct {
|
||||||
|
@@ -164,10 +165,10 @@ func (d *ethDriver) DeleteIf() (rErr error) {
|
||||||
|
// move the network interface back to the container
|
||||||
|
if err := netlink.LinkSetNsFd(hostNic, int(nsFD.Fd())); err != nil {
|
||||||
|
logrus.Errorf("Recover on failure: failed to move nic(%s) back to container: %v", d.GetHostNicName(), err)
|
||||||
|
- nsFD.Close()
|
||||||
|
+ utils.DropError(nsFD.Close())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
- nsFD.Close()
|
||||||
|
+ utils.DropError(nsFD.Close())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// set iface to user desired name
|
||||||
|
@@ -318,10 +319,10 @@ func (d *ethDriver) JoinAndConfigure() (rErr error) {
|
||||||
|
// move the network interface back to the host
|
||||||
|
if err := netlink.LinkSetNsFd(ctrNic, int(initnsFD.Fd())); err != nil {
|
||||||
|
logrus.Errorf("Recover on failure: failed to move nic(%s) back to host: %v", d.GetHostNicName(), err)
|
||||||
|
- initnsFD.Close()
|
||||||
|
+ utils.DropError(initnsFD.Close())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
- initnsFD.Close()
|
||||||
|
+ utils.DropError(initnsFD.Close())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// set iface to user desired name
|
||||||
|
diff --git a/pkg/udevd/udevd.go b/pkg/udevd/udevd.go
|
||||||
|
index 22b0cba..2465066 100644
|
||||||
|
--- a/pkg/udevd/udevd.go
|
||||||
|
+++ b/pkg/udevd/udevd.go
|
||||||
|
@@ -16,11 +16,14 @@ package udevd
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
- "github.com/sirupsen/logrus"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
+
|
||||||
|
+ "github.com/sirupsen/logrus"
|
||||||
|
+
|
||||||
|
+ "isula.org/syscontainer-tools/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func usingUdevd() (bool, error) {
|
||||||
|
@@ -42,8 +45,8 @@ func saveRules(path string, rules []*Rule) error {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
- f.WriteString("## This File is auto-generated by syscontainer-tools.\n")
|
||||||
|
- f.WriteString("## DO NOT EDIT IT\n\n")
|
||||||
|
+ utils.DropError(f.WriteString("## This File is auto-generated by syscontainer-tools.\n"))
|
||||||
|
+ utils.DropError(f.WriteString("## DO NOT EDIT IT\n\n"))
|
||||||
|
for _, r := range rules {
|
||||||
|
if _, err := f.WriteString(fmt.Sprintf("%s\n", r.ToUdevRuleString())); err != nil {
|
||||||
|
logrus.Errorf("f.WriteString err: %s", err)
|
||||||
|
diff --git a/pkg/udevd/udevd_controller.go b/pkg/udevd/udevd_controller.go
|
||||||
|
index d8ca84e..71138d5 100644
|
||||||
|
--- a/pkg/udevd/udevd_controller.go
|
||||||
|
+++ b/pkg/udevd/udevd_controller.go
|
||||||
|
@@ -18,8 +18,10 @@ import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
- hconfig "isula.org/syscontainer-tools/config"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
+
|
||||||
|
+ hconfig "isula.org/syscontainer-tools/config"
|
||||||
|
+ "isula.org/syscontainer-tools/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
@@ -97,7 +99,7 @@ func (sc *udevdController) Lock() error {
|
||||||
|
// LOCK_EX means only one process could lock it at one time.
|
||||||
|
// LOCK_NB is not set, using block mode.
|
||||||
|
if err := unix.Flock(int(f.Fd()), unix.LOCK_EX); err != nil {
|
||||||
|
- f.Close()
|
||||||
|
+ utils.DropError(f.Close())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sc.lock = f
|
||||||
|
diff --git a/utils/transfer.go b/utils/transfer.go
|
||||||
|
index a7f4b31..f164857 100644
|
||||||
|
--- a/utils/transfer.go
|
||||||
|
+++ b/utils/transfer.go
|
||||||
|
@@ -106,7 +106,7 @@ func parepareMountpoint(sPath, dPath, mOpt string, isDir bool) error {
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Fail to create transfer path,err: %s", err)
|
||||||
|
}
|
||||||
|
- f.Close()
|
||||||
|
+ DropError(f.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
if m, err := mount.Mounted(dPath); err != nil {
|
||||||
|
diff --git a/utils/utils.go b/utils/utils.go
|
||||||
|
index 31c8d14..3adbf2d 100644
|
||||||
|
--- a/utils/utils.go
|
||||||
|
+++ b/utils/utils.go
|
||||||
|
@@ -184,3 +184,15 @@ func RandomFile(folder string) string {
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+// DropError drop unused error
|
||||||
|
+func DropError(args ...interface{}) {
|
||||||
|
+ argn := len(args)
|
||||||
|
+ if argn == 0 {
|
||||||
|
+ return
|
||||||
|
+ }
|
||||||
|
+ arg := args[argn-1]
|
||||||
|
+ if arg != nil {
|
||||||
|
+ logrus.Warnf("drop error: %v\n", arg)
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#Basic Information
|
#Basic Information
|
||||||
Name: syscontainer-tools
|
Name: syscontainer-tools
|
||||||
Version: 0.9
|
Version: 0.9
|
||||||
Release: 58
|
Release: 59
|
||||||
Summary: syscontainer tools for IT, work with iSulad
|
Summary: syscontainer tools for IT, work with iSulad
|
||||||
License: Mulan PSL v2
|
License: Mulan PSL v2
|
||||||
URL: https://gitee.com/openeuler/syscontainer-tools
|
URL: https://gitee.com/openeuler/syscontainer-tools
|
||||||
@ -17,6 +17,7 @@ Patch6: 0006-syscontainer-tools-Add-sw64-architecture.patch
|
|||||||
Patch7: 0007-support-ipv6.patch
|
Patch7: 0007-support-ipv6.patch
|
||||||
Patch8: 0008-use-file-locks-to-avoid-remounting-the-sharepath-mas.patch
|
Patch8: 0008-use-file-locks-to-avoid-remounting-the-sharepath-mas.patch
|
||||||
Patch9: 0009-clean-up-run-syscontainer-tools-netns-containerid-di.patch
|
Patch9: 0009-clean-up-run-syscontainer-tools-netns-containerid-di.patch
|
||||||
|
Patch10: 0010-drop-useless-function-error-and-info.patch
|
||||||
|
|
||||||
#Dependency
|
#Dependency
|
||||||
BuildRequires: glibc-static
|
BuildRequires: glibc-static
|
||||||
@ -118,6 +119,12 @@ chmod 0640 ${HOOK_SPEC}/hookspec.json
|
|||||||
rm -rfv %{buildroot}
|
rm -rfv %{buildroot}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Aug 29 2023 yangjiaqi<yangjiaqi16@huawei.com> - 0.9-59
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:restart
|
||||||
|
- DESC:drop useless function error and info
|
||||||
|
|
||||||
* Tue Aug 29 2023 yangjiaqi<yangjiaqi16@huawei.com> - 0.9-58
|
* Tue Aug 29 2023 yangjiaqi<yangjiaqi16@huawei.com> - 0.9-58
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user