Skip to content

Commit

Permalink
When 'wait: no child processes' or 'waitid: no child processes' occur…
Browse files Browse the repository at this point in the history
…s, do not output an error (#1062)

* fix
  • Loading branch information
quzard authored Aug 14, 2023
1 parent d637c90 commit bc3f618
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/cn/data-pipeline/input/input-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| Type | String || 插件类型,指定为`input_command` |
| ScriptType | String || 指定脚本内容的类型,目前支持:bash、shell、python2、python3 |
| User | String || 运行命令使用的用户名,只支持非Root用户(建议配置最小权限,只给需要关注的目录/文件rwx权限) |
| ScriptContent | String || 脚本内容, 支持PlainText和base64加密的内容, 跟ContentEncoding的字段对应 |
| ScriptContent | String || 脚本内容, 支持PlainText和base64加密的内容, 跟ContentEncoding的字段对应, ScriptContent长度不能超过512*1024 |
| ContentEncoding | String || 脚本内容的文本格式 <br/> 支持PlainText(纯文本,不编码)\|Base64编码 默认:PlainText |
| LineSplitSep | String || 脚本输出内容的分隔符,为空时不进行分割,全部作为一条数据返回 |
| CmdPath | String || 执行脚本命令的路径,如果为空,则使用默认路径。bash、shell、python2、python3对应的默认路径如下:<br/>- bash: /usr/bin/bash<br/>- shell: /usr/bin/sh<br/>- python2: /usr/bin/python2<br/>- python3: /usr/bin/python3 |
Expand Down
5 changes: 5 additions & 0 deletions plugins/input/command/command_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ var SupportContentType = map[string]bool{
ContentTypePlainText: true,
ContentTypeBase64: true,
}

const (
errWaitNoChild = "wait: no child processes"
errWaitIDNoChild = "waitid: no child processes"
)
4 changes: 4 additions & 0 deletions plugins/input/command/command_script_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func WaitTimeout(cmd *exec.Cmd, timeout time.Duration) (isKilled bool, err error

err = cmd.Wait()

if err != nil && (err.Error() == errWaitNoChild || err.Error() == errWaitIDNoChild) {
err = nil
}

if kill != nil {
kill.Stop()
}
Expand Down
6 changes: 6 additions & 0 deletions plugins/input/command/input_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ func (in *InputCommand) Validate() (bool, error) {
return false, err
}

if len(in.ScriptContent) > 512*1024 {
err := fmt.Errorf("ScriptContent size is greater than 512K")
logger.Error(in.context.GetRuntimeContext(), util.CategoryConfigAlarm, "init input_command error", err)
return false, err
}

if in.TimeoutMilliSeconds > in.IntervalMs {
in.TimeoutMilliSeconds = in.IntervalMs
logger.Warning(in.context.GetRuntimeContext(), util.CategoryConfigAlarm, "init input_command warning", "TimeoutMilliSeconds > IntervalMs", "set TimeoutMilliSeconds = IntervalMs")
Expand Down

0 comments on commit bc3f618

Please sign in to comment.