mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #4692 from kolyshkin/golangci-v2
ci: switch to golangci-lint v2
This commit is contained in:
@@ -38,9 +38,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt -q update
|
sudo apt -q update
|
||||||
sudo apt -qy install libseccomp-dev
|
sudo apt -qy install libseccomp-dev
|
||||||
- uses: golangci/golangci-lint-action@v6
|
- uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
version: v1.64
|
version: v2.0
|
||||||
# Extra linters, only checking new code from a pull request.
|
# Extra linters, only checking new code from a pull request.
|
||||||
- name: lint-extra
|
- name: lint-extra
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
|
|||||||
+7
-1
@@ -3,13 +3,19 @@
|
|||||||
#
|
#
|
||||||
# For the default linter config, see .golangci.yml. This config should
|
# For the default linter config, see .golangci.yml. This config should
|
||||||
# only enable additional linters not enabled in the default config.
|
# only enable additional linters not enabled in the default config.
|
||||||
|
version: "2"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
build-tags:
|
build-tags:
|
||||||
- seccomp
|
- seccomp
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- godot
|
- godot
|
||||||
- revive
|
- revive
|
||||||
|
- staticcheck
|
||||||
|
settings:
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
|||||||
+16
-4
@@ -1,18 +1,30 @@
|
|||||||
# For documentation, see https://golangci-lint.run/usage/configuration/
|
version: "2"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
build-tags:
|
build-tags:
|
||||||
- seccomp
|
- seccomp
|
||||||
|
|
||||||
linters:
|
formatters:
|
||||||
enable:
|
enable:
|
||||||
- gofumpt
|
- gofumpt
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
- errorlint
|
- errorlint
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
|
settings:
|
||||||
linters-settings:
|
|
||||||
govet:
|
govet:
|
||||||
enable:
|
enable:
|
||||||
- nilness
|
- nilness
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
- -ST1000 # https://staticcheck.dev/docs/checks/#ST1000 Incorrect or missing package comment.
|
||||||
|
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
|
||||||
|
- -ST1005 # https://staticcheck.dev/docs/checks/#ST1005 Incorrectly formatted error string.
|
||||||
|
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
|
||||||
|
exclusions:
|
||||||
|
presets:
|
||||||
|
- std-error-handling
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ checkpointed.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = container.Checkpoint(options)
|
err = container.Checkpoint(options)
|
||||||
if err == nil && !(options.LeaveRunning || options.PreDump) {
|
if err == nil && !options.LeaveRunning && !options.PreDump {
|
||||||
// Destroy the container unless we tell CRIU to keep it.
|
// Destroy the container unless we tell CRIU to keep it.
|
||||||
if err := container.Destroy(); err != nil {
|
if err := container.Destroy(); err != nil {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func (c *Caps) ApplyBoundingSet() error {
|
|||||||
return c.pid.Apply(capability.BOUNDING)
|
return c.pid.Apply(capability.BOUNDING)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply sets all the capabilities for the current process in the config.
|
// ApplyCaps sets all the capabilities for the current process in the config.
|
||||||
func (c *Caps) ApplyCaps() error {
|
func (c *Caps) ApplyCaps() error {
|
||||||
if c.pid == nil {
|
if c.pid == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -956,8 +956,8 @@ func (c *Container) criuSwrk(process *Process, req *criurpc.CriuReq, opts *CriuO
|
|||||||
// available but empty. criurpc.CriuReqType_VERSION actually
|
// available but empty. criurpc.CriuReqType_VERSION actually
|
||||||
// has no req.GetOpts().
|
// has no req.GetOpts().
|
||||||
if logrus.GetLevel() >= logrus.DebugLevel &&
|
if logrus.GetLevel() >= logrus.DebugLevel &&
|
||||||
!(req.GetType() == criurpc.CriuReqType_FEATURE_CHECK ||
|
(req.GetType() != criurpc.CriuReqType_FEATURE_CHECK &&
|
||||||
req.GetType() == criurpc.CriuReqType_VERSION) {
|
req.GetType() != criurpc.CriuReqType_VERSION) {
|
||||||
|
|
||||||
val := reflect.ValueOf(req.GetOpts())
|
val := reflect.ValueOf(req.GetOpts())
|
||||||
v := reflect.Indirect(val)
|
v := reflect.Indirect(val)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package intelrdt
|
|||||||
|
|
||||||
var cmtEnabled bool
|
var cmtEnabled bool
|
||||||
|
|
||||||
// Check if Intel RDT/CMT is enabled.
|
// IsCMTEnabled checks if Intel RDT/CMT is enabled.
|
||||||
func IsCMTEnabled() bool {
|
func IsCMTEnabled() bool {
|
||||||
featuresInit()
|
featuresInit()
|
||||||
return cmtEnabled
|
return cmtEnabled
|
||||||
|
|||||||
@@ -416,13 +416,13 @@ func WriteIntelRdtTasks(dir string, pid int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if Intel RDT/CAT is enabled
|
// IsCATEnabled checks if Intel RDT/CAT is enabled.
|
||||||
func IsCATEnabled() bool {
|
func IsCATEnabled() bool {
|
||||||
featuresInit()
|
featuresInit()
|
||||||
return catEnabled
|
return catEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if Intel RDT/MBA is enabled
|
// IsMBAEnabled checks if Intel RDT/MBA is enabled.
|
||||||
func IsMBAEnabled() bool {
|
func IsMBAEnabled() bool {
|
||||||
featuresInit()
|
featuresInit()
|
||||||
return mbaEnabled
|
return mbaEnabled
|
||||||
@@ -443,7 +443,7 @@ func (m *Manager) getIntelRdtPath() (string, error) {
|
|||||||
return filepath.Join(rootPath, clos), nil
|
return filepath.Join(rootPath, clos), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Applies Intel RDT configuration to the process with the specified pid
|
// Apply applies Intel RDT configuration to the process with the specified pid.
|
||||||
func (m *Manager) Apply(pid int) (err error) {
|
func (m *Manager) Apply(pid int) (err error) {
|
||||||
// If intelRdt is not specified in config, we do nothing
|
// If intelRdt is not specified in config, we do nothing
|
||||||
if m.config.IntelRdt == nil {
|
if m.config.IntelRdt == nil {
|
||||||
@@ -478,7 +478,7 @@ func (m *Manager) Apply(pid int) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroys the Intel RDT container-specific 'container_id' group
|
// Destroy destroys the Intel RDT container-specific container_id group.
|
||||||
func (m *Manager) Destroy() error {
|
func (m *Manager) Destroy() error {
|
||||||
// Don't remove resctrl group if closid has been explicitly specified. The
|
// Don't remove resctrl group if closid has been explicitly specified. The
|
||||||
// group is likely externally managed, i.e. by some other entity than us.
|
// group is likely externally managed, i.e. by some other entity than us.
|
||||||
@@ -494,8 +494,8 @@ func (m *Manager) Destroy() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns Intel RDT path to save in a state file and to be able to
|
// GetPath returns Intel RDT path to save in a state file and to be able to
|
||||||
// restore the object later
|
// restore the object later.
|
||||||
func (m *Manager) GetPath() string {
|
func (m *Manager) GetPath() string {
|
||||||
if m.path == "" {
|
if m.path == "" {
|
||||||
m.path, _ = m.getIntelRdtPath()
|
m.path, _ = m.getIntelRdtPath()
|
||||||
@@ -503,7 +503,7 @@ func (m *Manager) GetPath() string {
|
|||||||
return m.path
|
return m.path
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns statistics for Intel RDT
|
// GetStats returns statistics for Intel RDT.
|
||||||
func (m *Manager) GetStats() (*Stats, error) {
|
func (m *Manager) GetStats() (*Stats, error) {
|
||||||
// If intelRdt is not specified in config
|
// If intelRdt is not specified in config
|
||||||
if m.config.IntelRdt == nil {
|
if m.config.IntelRdt == nil {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package intelrdt
|
|||||||
// The flag to indicate if Intel RDT/MBM is enabled
|
// The flag to indicate if Intel RDT/MBM is enabled
|
||||||
var mbmEnabled bool
|
var mbmEnabled bool
|
||||||
|
|
||||||
// Check if Intel RDT/MBM is enabled.
|
// IsMBMEnabled checks if Intel RDT/MBM is enabled.
|
||||||
func IsMBMEnabled() bool {
|
func IsMBMEnabled() bool {
|
||||||
featuresInit()
|
featuresInit()
|
||||||
return mbmEnabled
|
return mbmEnabled
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ func mountCgroupV2(m *configs.Mount, c *mountConfig) error {
|
|||||||
err := utils.WithProcfd(c.root, m.Destination, func(dstFd string) error {
|
err := utils.WithProcfd(c.root, m.Destination, func(dstFd string) error {
|
||||||
return mountViaFds(m.Source, nil, m.Destination, dstFd, "cgroup2", uintptr(m.Flags), m.Data)
|
return mountViaFds(m.Source, nil, m.Destination, dstFd, "cgroup2", uintptr(m.Flags), m.Data)
|
||||||
})
|
})
|
||||||
if err == nil || !(errors.Is(err, unix.EPERM) || errors.Is(err, unix.EBUSY)) {
|
if err == nil || (!errors.Is(err, unix.EPERM) && !errors.Is(err, unix.EBUSY)) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1249,7 +1249,7 @@ func maskPath(path string, mountLabel string) error {
|
|||||||
// writeSystemProperty writes the value to a path under /proc/sys as determined from the key.
|
// writeSystemProperty writes the value to a path under /proc/sys as determined from the key.
|
||||||
// For e.g. net.ipv4.ip_forward translated to /proc/sys/net/ipv4/ip_forward.
|
// For e.g. net.ipv4.ip_forward translated to /proc/sys/net/ipv4/ip_forward.
|
||||||
func writeSystemProperty(key, value string) error {
|
func writeSystemProperty(key, value string) error {
|
||||||
keyPath := strings.Replace(key, ".", "/", -1)
|
keyPath := strings.ReplaceAll(key, ".", "/")
|
||||||
return os.WriteFile(path.Join("/proc/sys", keyPath), []byte(value), 0o644)
|
return os.WriteFile(path.Join("/proc/sys", keyPath), []byte(value), 0o644)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -104,11 +104,11 @@ func (s *notifySocket) waitForContainer(container *libcontainer.Container) error
|
|||||||
return s.run(state.InitProcessPid)
|
return s.run(state.InitProcessPid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *notifySocket) run(pid1 int) error {
|
func (s *notifySocket) run(pid1 int) error {
|
||||||
if n.socket == nil {
|
if s.socket == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
notifySocketHostAddr := net.UnixAddr{Name: n.host, Net: "unixgram"}
|
notifySocketHostAddr := net.UnixAddr{Name: s.host, Net: "unixgram"}
|
||||||
client, err := net.DialUnix("unixgram", nil, ¬ifySocketHostAddr)
|
client, err := net.DialUnix("unixgram", nil, ¬ifySocketHostAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -121,7 +121,7 @@ func (n *notifySocket) run(pid1 int) error {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
buf := make([]byte, 4096)
|
buf := make([]byte, 4096)
|
||||||
r, err := n.socket.Read(buf)
|
r, err := s.socket.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ type Event struct {
|
|||||||
Data interface{} `json:"data,omitempty"`
|
Data interface{} `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// stats is the runc specific stats structure for stability when encoding and decoding stats.
|
// Stats is the runc specific stats structure for stability when encoding and decoding stats.
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
CPU Cpu `json:"cpu"`
|
CPU Cpu `json:"cpu"`
|
||||||
CPUSet CPUSet `json:"cpuset"`
|
CPUSet CPUSet `json:"cpuset"`
|
||||||
|
|||||||
Reference in New Issue
Block a user