mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	Bump cadvisor dependencies to latest head.
This commit is contained in:
		
							
								
								
									
										75
									
								
								vendor/github.com/opencontainers/runc/libcontainer/process_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										75
									
								
								vendor/github.com/opencontainers/runc/libcontainer/process_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -51,7 +51,6 @@ type setnsProcess struct { | ||||
| 	fds           []string | ||||
| 	process       *Process | ||||
| 	bootstrapData io.Reader | ||||
| 	rootDir       *os.File | ||||
| } | ||||
|  | ||||
| func (p *setnsProcess) startTime() (string, error) { | ||||
| @@ -70,49 +69,48 @@ func (p *setnsProcess) start() (err error) { | ||||
| 	defer p.parentPipe.Close() | ||||
| 	err = p.cmd.Start() | ||||
| 	p.childPipe.Close() | ||||
| 	p.rootDir.Close() | ||||
| 	if err != nil { | ||||
| 		return newSystemErrorWithCause(err, "starting setns process") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if p.bootstrapData != nil { | ||||
| 		if _, err := io.Copy(p.parentPipe, p.bootstrapData); err != nil { | ||||
| 			return newSystemErrorWithCause(err, "copying bootstrap data to pipe") | ||||
| 			return newSystemError(err) | ||||
| 		} | ||||
| 	} | ||||
| 	if err = p.execSetns(); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "executing setns process") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if len(p.cgroupPaths) > 0 { | ||||
| 		if err := cgroups.EnterPid(p.cgroupPaths, p.pid()); err != nil { | ||||
| 			return newSystemErrorWithCausef(err, "adding pid %d to cgroups", p.pid()) | ||||
| 			return newSystemError(err) | ||||
| 		} | ||||
| 	} | ||||
| 	// set oom_score_adj | ||||
| 	if err := setOomScoreAdj(p.config.Config.OomScoreAdj, p.pid()); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "setting oom score") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	// set rlimits, this has to be done here because we lose permissions | ||||
| 	// to raise the limits once we enter a user-namespace | ||||
| 	if err := setupRlimits(p.config.Rlimits, p.pid()); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "setting rlimits for process") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if err := utils.WriteJSON(p.parentPipe, p.config); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "writing config to pipe") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
|  | ||||
| 	if err := syscall.Shutdown(int(p.parentPipe.Fd()), syscall.SHUT_WR); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "calling shutdown on init pipe") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	// wait for the child process to fully complete and receive an error message | ||||
| 	// if one was encoutered | ||||
| 	var ierr *genericError | ||||
| 	if err := json.NewDecoder(p.parentPipe).Decode(&ierr); err != nil && err != io.EOF { | ||||
| 		return newSystemErrorWithCause(err, "decoding init error from pipe") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	// Must be done after Shutdown so the child will exit and we can wait for it. | ||||
| 	if ierr != nil { | ||||
| 		p.wait() | ||||
| 		return ierr | ||||
| 		return newSystemError(ierr) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| @@ -125,7 +123,7 @@ func (p *setnsProcess) execSetns() error { | ||||
| 	status, err := p.cmd.Process.Wait() | ||||
| 	if err != nil { | ||||
| 		p.cmd.Wait() | ||||
| 		return newSystemErrorWithCause(err, "waiting on setns process to finish") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if !status.Success() { | ||||
| 		p.cmd.Wait() | ||||
| @@ -134,7 +132,7 @@ func (p *setnsProcess) execSetns() error { | ||||
| 	var pid *pid | ||||
| 	if err := json.NewDecoder(p.parentPipe).Decode(&pid); err != nil { | ||||
| 		p.cmd.Wait() | ||||
| 		return newSystemErrorWithCause(err, "reading pid from init pipe") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	process, err := os.FindProcess(pid.Pid) | ||||
| 	if err != nil { | ||||
| @@ -188,7 +186,6 @@ type initProcess struct { | ||||
| 	process       *Process | ||||
| 	bootstrapData io.Reader | ||||
| 	sharePidns    bool | ||||
| 	rootDir       *os.File | ||||
| } | ||||
|  | ||||
| func (p *initProcess) pid() int { | ||||
| @@ -224,7 +221,6 @@ func (p *initProcess) execSetns() error { | ||||
| 		return err | ||||
| 	} | ||||
| 	p.cmd.Process = process | ||||
| 	p.process.ops = p | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @@ -233,29 +229,28 @@ func (p *initProcess) start() error { | ||||
| 	err := p.cmd.Start() | ||||
| 	p.process.ops = p | ||||
| 	p.childPipe.Close() | ||||
| 	p.rootDir.Close() | ||||
| 	if err != nil { | ||||
| 		p.process.ops = nil | ||||
| 		return newSystemErrorWithCause(err, "starting init process command") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if _, err := io.Copy(p.parentPipe, p.bootstrapData); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err := p.execSetns(); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "running exec setns process for init") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	// Save the standard descriptor names before the container process | ||||
| 	// can potentially move them (e.g., via dup2()).  If we don't do this now, | ||||
| 	// we won't know at checkpoint time which file descriptor to look up. | ||||
| 	fds, err := getPipeFds(p.pid()) | ||||
| 	if err != nil { | ||||
| 		return newSystemErrorWithCausef(err, "getting pipe fds for pid %d", p.pid()) | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	p.setExternalDescriptors(fds) | ||||
| 	// Do this before syncing with child so that no children | ||||
| 	// can escape the cgroup | ||||
| 	if err := p.manager.Apply(p.pid()); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "applying cgroup configuration for process") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| @@ -264,10 +259,10 @@ func (p *initProcess) start() error { | ||||
| 		} | ||||
| 	}() | ||||
| 	if err := p.createNetworkInterfaces(); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "creating nework interfaces") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	if err := p.sendConfig(); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "sending config to init process") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	var ( | ||||
| 		procSync   syncT | ||||
| @@ -283,21 +278,21 @@ loop: | ||||
| 			if err == io.EOF { | ||||
| 				break loop | ||||
| 			} | ||||
| 			return newSystemErrorWithCause(err, "decoding sync type from init pipe") | ||||
| 			return newSystemError(err) | ||||
| 		} | ||||
| 		switch procSync.Type { | ||||
| 		case procReady: | ||||
| 			if err := p.manager.Set(p.config.Config); err != nil { | ||||
| 				return newSystemErrorWithCause(err, "setting cgroup config for ready process") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			// set oom_score_adj | ||||
| 			if err := setOomScoreAdj(p.config.Config.OomScoreAdj, p.pid()); err != nil { | ||||
| 				return newSystemErrorWithCause(err, "setting oom score for ready process") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			// set rlimits, this has to be done here because we lose permissions | ||||
| 			// to raise the limits once we enter a user-namespace | ||||
| 			if err := setupRlimits(p.config.Rlimits, p.pid()); err != nil { | ||||
| 				return newSystemErrorWithCause(err, "setting rlimits for ready process") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			// call prestart hooks | ||||
| 			if !p.config.Config.Namespaces.Contains(configs.NEWNS) { | ||||
| @@ -308,16 +303,16 @@ loop: | ||||
| 						Pid:     p.pid(), | ||||
| 						Root:    p.config.Config.Rootfs, | ||||
| 					} | ||||
| 					for i, hook := range p.config.Config.Hooks.Prestart { | ||||
| 					for _, hook := range p.config.Config.Hooks.Prestart { | ||||
| 						if err := hook.Run(s); err != nil { | ||||
| 							return newSystemErrorWithCausef(err, "running prestart hook %d", i) | ||||
| 							return newSystemError(err) | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			// Sync with child. | ||||
| 			if err := utils.WriteJSON(p.parentPipe, syncT{procRun}); err != nil { | ||||
| 				return newSystemErrorWithCause(err, "reading syncT run type") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			sentRun = true | ||||
| 		case procHooks: | ||||
| @@ -329,22 +324,22 @@ loop: | ||||
| 					Root:       p.config.Config.Rootfs, | ||||
| 					BundlePath: utils.SearchLabels(p.config.Config.Labels, "bundle"), | ||||
| 				} | ||||
| 				for i, hook := range p.config.Config.Hooks.Prestart { | ||||
| 				for _, hook := range p.config.Config.Hooks.Prestart { | ||||
| 					if err := hook.Run(s); err != nil { | ||||
| 						return newSystemErrorWithCausef(err, "running prestart hook %d", i) | ||||
| 						return newSystemError(err) | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			// Sync with child. | ||||
| 			if err := utils.WriteJSON(p.parentPipe, syncT{procResume}); err != nil { | ||||
| 				return newSystemErrorWithCause(err, "reading syncT resume type") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			sentResume = true | ||||
| 		case procError: | ||||
| 			// wait for the child process to fully complete and receive an error message | ||||
| 			// if one was encoutered | ||||
| 			if err := dec.Decode(&ierr); err != nil && err != io.EOF { | ||||
| 				return newSystemErrorWithCause(err, "decoding proc error from init") | ||||
| 				return newSystemError(err) | ||||
| 			} | ||||
| 			if ierr != nil { | ||||
| 				break loop | ||||
| @@ -352,22 +347,22 @@ loop: | ||||
| 			// Programmer error. | ||||
| 			panic("No error following JSON procError payload.") | ||||
| 		default: | ||||
| 			return newSystemError(fmt.Errorf("invalid JSON payload from child")) | ||||
| 			return newSystemError(fmt.Errorf("invalid JSON synchronisation payload from child")) | ||||
| 		} | ||||
| 	} | ||||
| 	if !sentRun { | ||||
| 		return newSystemErrorWithCause(ierr, "container init failed") | ||||
| 		return newSystemError(fmt.Errorf("could not synchronise with container process: %v", ierr)) | ||||
| 	} | ||||
| 	if p.config.Config.Namespaces.Contains(configs.NEWNS) && !sentResume { | ||||
| 		return newSystemError(fmt.Errorf("could not synchronise after executing prestart hooks with container process")) | ||||
| 	} | ||||
| 	if err := syscall.Shutdown(int(p.parentPipe.Fd()), syscall.SHUT_WR); err != nil { | ||||
| 		return newSystemErrorWithCause(err, "shutting down init pipe") | ||||
| 		return newSystemError(err) | ||||
| 	} | ||||
| 	// Must be done after Shutdown so the child will exit and we can wait for it. | ||||
| 	if ierr != nil { | ||||
| 		p.wait() | ||||
| 		return ierr | ||||
| 		return newSystemError(ierr) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| @@ -452,7 +447,7 @@ func getPipeFds(pid int) ([]string, error) { | ||||
|  | ||||
| // InitializeIO creates pipes for use with the process's STDIO | ||||
| // and returns the opposite side for each | ||||
| func (p *Process) InitializeIO(rootuid, rootgid int) (i *IO, err error) { | ||||
| func (p *Process) InitializeIO(rootuid int) (i *IO, err error) { | ||||
| 	var fds []uintptr | ||||
| 	i = &IO{} | ||||
| 	// cleanup in case of an error | ||||
| @@ -484,7 +479,7 @@ func (p *Process) InitializeIO(rootuid, rootgid int) (i *IO, err error) { | ||||
| 	p.Stderr, i.Stderr = w, r | ||||
| 	// change ownership of the pipes incase we are in a user namespace | ||||
| 	for _, fd := range fds { | ||||
| 		if err := syscall.Fchown(int(fd), rootuid, rootgid); err != nil { | ||||
| 		if err := syscall.Fchown(int(fd), rootuid, rootuid); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user