@@ -99,7 +99,7 @@ func (c *Container) Status() (Status, error) {
99
99
func (c * Container ) State () (* State , error ) {
100
100
c .m .Lock ()
101
101
defer c .m .Unlock ()
102
- return c .currentState ()
102
+ return c .currentState (), nil
103
103
}
104
104
105
105
// OCIState returns the current container's state information.
@@ -531,7 +531,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
531
531
logrus .Debug ("runc-dmz: using runc-dmz" ) // used for tests
532
532
} else if errors .Is (err , dmz .ErrNoDmzBinary ) {
533
533
logrus .Debug ("runc-dmz binary not embedded in runc binary, falling back to /proc/self/exe clone" )
534
- } else if err != nil {
534
+ } else {
535
535
return nil , fmt .Errorf ("failed to create runc-dmz binary clone: %w" , err )
536
536
}
537
537
} else {
@@ -666,10 +666,7 @@ func (c *Container) newInitProcess(p *Process, cmd *exec.Cmd, comm *processComm)
666
666
667
667
func (c * Container ) newSetnsProcess (p * Process , cmd * exec.Cmd , comm * processComm ) (* setnsProcess , error ) {
668
668
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 ()
673
670
// for setns process, we don't have to set cloneflags as the process namespaces
674
671
// will only be set via setns syscall
675
672
data , err := c .bootstrapData (0 , state .NamespacePaths )
@@ -847,12 +844,8 @@ func (c *Container) updateState(process parentProcess) (*State, error) {
847
844
if process != nil {
848
845
c .initProcess = process
849
846
}
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 {
856
849
return nil , err
857
850
}
858
851
return state , nil
@@ -938,7 +931,7 @@ func (c *Container) isPaused() (bool, error) {
938
931
return state == configs .Frozen , nil
939
932
}
940
933
941
- func (c * Container ) currentState () ( * State , error ) {
934
+ func (c * Container ) currentState () * State {
942
935
var (
943
936
startTime uint64
944
937
externalDescriptors []string
@@ -982,7 +975,7 @@ func (c *Container) currentState() (*State, error) {
982
975
}
983
976
}
984
977
}
985
- return state , nil
978
+ return state
986
979
}
987
980
988
981
func (c * Container ) currentOCIState () (* specs.State , error ) {
0 commit comments