// MakePodName append podname,jobname,taskName and index and returns the string. funcMakePodName(jobName string, taskName string, index int)string { return fmt.Sprintf(jobhelpers.PodNameFmt, jobName, taskName, index) }
Note: ip_local_port_range and ip_local_reserved_ports settings are independent and both are considered by the kernel when determining which ports are available for automatic port assignments.
graph LR
InitContainer --> TrainingContainer
InitContainer --> SidecarContainer
InitContainer and SidecarContainer act like system container and they are transparent to the TrainingContainer
TrainingJob(process) of user is running at TrainingContainer
we can do the init env action at InitContainer, such as download data, and the upload action can be done at SidecarContainer
however, there will be an engineering problem, that is, the file read permission problem. The best way is to make the InitC / SidecarC / TrainingC users (uid) the same
A Context is safe for simultaneous use by multiple goroutines. Code can pass a single Context to any number of goroutines and cancel that Context to signal all of them.
var rootCmd = &cobra.Command{ Use: "long run cli", Run: func(cmd *cobra.Command, args []string) { cli := run.New() err := cli.LongRun(cmd.Context())
if err != nil { fmt.Printf("cli run err: %v\n", err) if exitError, ok := err.(*exec.ExitError); ok { fmt.Printf("exit code: %d\n", exitError.ExitCode()) } } }, }
Wait until the child process specified by each process ID pid or job specification jobspec exits and return the exit status of the last command waited for.
注意 return the exit status of the last command waited for
所以上述代码,wait 命令实际上获取到的是 tee 命令的退出码
在 shell 中获取 pipeline command status 的简易方法似乎只能通过 ${PIPESTATUS[0]}
get pid of pipeline command in background
进一步的,我们想获取 someCommand 的 pid,有办法么,尝试做如下改造
1 2 3 4 5 6 7 8 9 10 11
someCommand="python test.py"
{ ${someCommand} 2>&1 & pid_someCommand=$! wait ${pid_someCommand} exit $? } | tee -a training.log &