mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-30 17:58:14 +00:00 
			
		
		
		
	 07af1bab70
			
		
	
	07af1bab70
	
	
	
		
			
			This updates vendored runc/libcontainer to 1.1.0, and google/cadvisor to a version updated to runc 1.1.0 (google/cadvisor#3048). Changes in vendor are generated by (roughly): ./hack/pin-dependency.sh github.com/google/cadvisor v0.44.0 ./hack/pin-dependency.sh github.com/opencontainers/runc v1.1.0 ./hack/update-vendor.sh ./hack/lint-dependencies.sh # And follow all its recommendations. ./hack/update-vendor.sh ./hack/update-internal-modules.sh ./hack/lint-dependencies.sh # Re-check everything again. Co-Authored-By: Kir Kolyshkin <kolyshkin@gmail.com>
		
			
				
	
	
		
			129 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package libcontainer
 | |
| 
 | |
| import (
 | |
| 	"errors"
 | |
| 	"os"
 | |
| 	"os/exec"
 | |
| 
 | |
| 	"github.com/opencontainers/runc/libcontainer/system"
 | |
| )
 | |
| 
 | |
| func newRestoredProcess(cmd *exec.Cmd, fds []string) (*restoredProcess, error) {
 | |
| 	var err error
 | |
| 	pid := cmd.Process.Pid
 | |
| 	stat, err := system.Stat(pid)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return &restoredProcess{
 | |
| 		cmd:              cmd,
 | |
| 		processStartTime: stat.StartTime,
 | |
| 		fds:              fds,
 | |
| 	}, nil
 | |
| }
 | |
| 
 | |
| type restoredProcess struct {
 | |
| 	cmd              *exec.Cmd
 | |
| 	processStartTime uint64
 | |
| 	fds              []string
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) start() error {
 | |
| 	return errors.New("restored process cannot be started")
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) pid() int {
 | |
| 	return p.cmd.Process.Pid
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) terminate() error {
 | |
| 	err := p.cmd.Process.Kill()
 | |
| 	if _, werr := p.wait(); err == nil {
 | |
| 		err = werr
 | |
| 	}
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) wait() (*os.ProcessState, error) {
 | |
| 	// TODO: how do we wait on the actual process?
 | |
| 	// maybe use --exec-cmd in criu
 | |
| 	err := p.cmd.Wait()
 | |
| 	if err != nil {
 | |
| 		var exitErr *exec.ExitError
 | |
| 		if !errors.As(err, &exitErr) {
 | |
| 			return nil, err
 | |
| 		}
 | |
| 	}
 | |
| 	st := p.cmd.ProcessState
 | |
| 	return st, nil
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) startTime() (uint64, error) {
 | |
| 	return p.processStartTime, nil
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) signal(s os.Signal) error {
 | |
| 	return p.cmd.Process.Signal(s)
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) externalDescriptors() []string {
 | |
| 	return p.fds
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) setExternalDescriptors(newFds []string) {
 | |
| 	p.fds = newFds
 | |
| }
 | |
| 
 | |
| func (p *restoredProcess) forwardChildLogs() chan error {
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // nonChildProcess represents a process where the calling process is not
 | |
| // the parent process.  This process is created when a factory loads a container from
 | |
| // a persisted state.
 | |
| type nonChildProcess struct {
 | |
| 	processPid       int
 | |
| 	processStartTime uint64
 | |
| 	fds              []string
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) start() error {
 | |
| 	return errors.New("restored process cannot be started")
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) pid() int {
 | |
| 	return p.processPid
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) terminate() error {
 | |
| 	return errors.New("restored process cannot be terminated")
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) wait() (*os.ProcessState, error) {
 | |
| 	return nil, errors.New("restored process cannot be waited on")
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) startTime() (uint64, error) {
 | |
| 	return p.processStartTime, nil
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) signal(s os.Signal) error {
 | |
| 	proc, err := os.FindProcess(p.processPid)
 | |
| 	if err != nil {
 | |
| 		return err
 | |
| 	}
 | |
| 	return proc.Signal(s)
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) externalDescriptors() []string {
 | |
| 	return p.fds
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) setExternalDescriptors(newFds []string) {
 | |
| 	p.fds = newFds
 | |
| }
 | |
| 
 | |
| func (p *nonChildProcess) forwardChildLogs() chan error {
 | |
| 	return nil
 | |
| }
 |