@@ -99,7 +99,7 @@ func (c *Container) Status() (Status, error) {
9999func (c * Container ) State () (* State , error ) {
100100 c .m .Lock ()
101101 defer c .m .Unlock ()
102- return c .currentState ()
102+ return c .currentState (), nil
103103}
104104
105105// OCIState returns the current container's state information.
@@ -531,7 +531,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
531531 logrus .Debug ("runc-dmz: using runc-dmz" ) // used for tests
532532 } else if errors .Is (err , dmz .ErrNoDmzBinary ) {
533533 logrus .Debug ("runc-dmz binary not embedded in runc binary, falling back to /proc/self/exe clone" )
534- } else if err != nil {
534+ } else {
535535 return nil , fmt .Errorf ("failed to create runc-dmz binary clone: %w" , err )
536536 }
537537 } else {
@@ -666,10 +666,7 @@ func (c *Container) newInitProcess(p *Process, cmd *exec.Cmd, comm *processComm)
666666
667667func (c * Container ) newSetnsProcess (p * Process , cmd * exec.Cmd , comm * processComm ) (* setnsProcess , error ) {
668668 cmd .Env = append (cmd .Env , "_LIBCONTAINER_INITTYPE=" + string (initSetns ))
669- state , err := c .currentState ()
670- if err != nil {
671- return nil , fmt .Errorf ("unable to get container state: %w" , err )
672- }
669+ state := c .currentState ()
673670 // for setns process, we don't have to set cloneflags as the process namespaces
674671 // will only be set via setns syscall
675672 data , err := c .bootstrapData (0 , state .NamespacePaths )
@@ -847,12 +844,8 @@ func (c *Container) updateState(process parentProcess) (*State, error) {
847844 if process != nil {
848845 c .initProcess = process
849846 }
850- state , err := c .currentState ()
851- if err != nil {
852- return nil , err
853- }
854- err = c .saveState (state )
855- if err != nil {
847+ state := c .currentState ()
848+ if err := c .saveState (state ); err != nil {
856849 return nil , err
857850 }
858851 return state , nil
@@ -938,7 +931,7 @@ func (c *Container) isPaused() (bool, error) {
938931 return state == configs .Frozen , nil
939932}
940933
941- func (c * Container ) currentState () ( * State , error ) {
934+ func (c * Container ) currentState () * State {
942935 var (
943936 startTime uint64
944937 externalDescriptors []string
@@ -982,7 +975,7 @@ func (c *Container) currentState() (*State, error) {
982975 }
983976 }
984977 }
985- return state , nil
978+ return state
986979}
987980
988981func (c * Container ) currentOCIState () (* specs.State , error ) {
0 commit comments