Skip to content

Commit

Permalink
Merge pull request opencontainers#4344 from kolyshkin/nilness
Browse files Browse the repository at this point in the history
ci bumps
  • Loading branch information
rata committed Aug 1, 2024
2 parents 3d7bc3b + 15ec295 commit ad5b481
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
sudo apt -qy install libseccomp-dev
- uses: golangci/golangci-lint-action@v6
with:
version: v1.57
version: v1.59
# Extra linters, only checking new code from a pull request.
- name: lint-extra
if: github.event_name == 'pull_request'
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ linters:
- errorlint
- unconvert
- unparam

linters-settings:
govet:
enable:
- nilness
21 changes: 7 additions & 14 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *Container) Status() (Status, error) {
func (c *Container) State() (*State, error) {
c.m.Lock()
defer c.m.Unlock()
return c.currentState()
return c.currentState(), nil
}

// OCIState returns the current container's state information.
Expand Down Expand Up @@ -531,7 +531,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
logrus.Debug("runc-dmz: using runc-dmz") // used for tests
} else if errors.Is(err, dmz.ErrNoDmzBinary) {
logrus.Debug("runc-dmz binary not embedded in runc binary, falling back to /proc/self/exe clone")
} else if err != nil {
} else {
return nil, fmt.Errorf("failed to create runc-dmz binary clone: %w", err)
}
} else {
Expand Down Expand Up @@ -666,10 +666,7 @@ func (c *Container) newInitProcess(p *Process, cmd *exec.Cmd, comm *processComm)

func (c *Container) newSetnsProcess(p *Process, cmd *exec.Cmd, comm *processComm) (*setnsProcess, error) {
cmd.Env = append(cmd.Env, "_LIBCONTAINER_INITTYPE="+string(initSetns))
state, err := c.currentState()
if err != nil {
return nil, fmt.Errorf("unable to get container state: %w", err)
}
state := c.currentState()
// for setns process, we don't have to set cloneflags as the process namespaces
// will only be set via setns syscall
data, err := c.bootstrapData(0, state.NamespacePaths)
Expand Down Expand Up @@ -847,12 +844,8 @@ func (c *Container) updateState(process parentProcess) (*State, error) {
if process != nil {
c.initProcess = process
}
state, err := c.currentState()
if err != nil {
return nil, err
}
err = c.saveState(state)
if err != nil {
state := c.currentState()
if err := c.saveState(state); err != nil {
return nil, err
}
return state, nil
Expand Down Expand Up @@ -938,7 +931,7 @@ func (c *Container) isPaused() (bool, error) {
return state == configs.Frozen, nil
}

func (c *Container) currentState() (*State, error) {
func (c *Container) currentState() *State {
var (
startTime uint64
externalDescriptors []string
Expand Down Expand Up @@ -982,7 +975,7 @@ func (c *Container) currentState() (*State, error) {
}
}
}
return state, nil
return state
}

func (c *Container) currentOCIState() (*specs.State, error) {
Expand Down

0 comments on commit ad5b481

Please sign in to comment.