Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 通过 API execute_job_plan 启动执行方案,如果传入的主机全局变量为空,Job 返回内部错误 #2182

Closed
wangyu096 opened this issue Jul 3, 2023 · 1 comment
Assignees
Labels
done 已上线到正式环境并验收通过 kind/bug 程序故障Bug,漏洞

Comments

@wangyu096
Copy link
Collaborator

Version / Branch / tag

3.7.x

出了什么问题?(What Happened?)

  • 通过 API execute_job_plan 启动执行方案,如果传入的主机全局变量为空,Job 返回内部错误
  • 传入参数
{"bk_scope_type":"biz","bk_scope_id":"1000","bk_biz_id":1000,"job_plan_id":2000,"global_var_list":[{"name":"target_hosts","server":{"ip_list":[]}}]}
  • 异常信息
Caused by: feign.FeignException$BadRequest: [400] during [POST] to [http://job-manage/service/app/902/host/batchGet] [ServiceHostResourceClient#batchGetAppHosts(Long,ServiceBatchGetAppHostsReq)]: [{"success":false,"code":1241010,"errorType":2,"errorMsg":"请求参数[hosts]不合法,原因:hosts must not be empty","data":null,"requestId":"9490cfaded3eab716fe73efb06cf39cd","authResult":null,"errorDetail":null}]
	at feign.FeignException.clientErrorStatus(FeignException.java:213)
	at feign.FeignException.errorStatus(FeignException.java:194)
	at feign.FeignException.errorStatus(FeignException.java:185)
	at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)
	at com.tencent.bk.job.common.web.feign.FeignErrorDecoder.decode(FeignErrorDecoder.java:51)
	... 73 common frames omitted

[2023-07-03 15:01:12.683] ERROR [job-execute,377e6ae06f2a5c3de997f12117081b9e,da5de58c1cbc7c46] 30428 --- [http-nio-10502-exec-65] b.j.c.w.e.h.EsbExceptionControllerAdvice : Handle exception

java.lang.NullPointerException: null
	at com.tencent.bk.job.execute.service.impl.TaskExecuteServiceImpl.getServerValueFromVariable(TaskExecuteServiceImpl.java:1982)
	at com.tencent.bk.job.execute.service.impl.TaskExecuteServiceImpl.buildFinalTargetServers(TaskExecuteServiceImpl.java:1956)
	at com.tencent.bk.job.execute.service.impl.TaskExecuteServiceImpl.parseScriptStepInstanceFromPlanStep(TaskExecuteServiceImpl.java:1809)
	at com.tencent.bk.job.execute.service.impl.TaskExecuteServiceImpl.buildTaskInfoFromExecuteParam(TaskExecuteServiceImpl.java:1355)
	at com.tencent.bk.job.execute.service.impl.TaskExecuteServiceImpl.executeJobPlan(TaskExecuteServiceImpl.java:1202)
	at com.tencent.bk.job.execute.api.esb.v3.EsbExecuteJobPlanV3ResourceImpl.executeJobPlan(EsbExecuteJobPlanV3ResourceImpl.java:105)
	at com.tencent.bk.job.execute.api.esb.v3.EsbExecuteJobPlanV3ResourceImpl$$FastClassBySpringCGLIB$$4834dbc6.invoke(<generated>)

如何复现?(How to reproduce?)

  1. 执行方案包含 1 个主机变量并且被引用
  2. API 传入参数,主机变量为空(整个执行方案主机为空)
@wangyu096 wangyu096 added kind/bug 程序故障Bug,漏洞 backlog 需求初始状态,等待产品进行评估 labels Jul 3, 2023
@wangyu096 wangyu096 self-assigned this Jul 3, 2023
@wangyu096
Copy link
Collaborator Author

错误原因:执行方案的主机为空,去 job-manage 查询主机信息的时候,传入了空的主机列表,导致查询主机报错

jsonwan added a commit that referenced this issue Jul 5, 2023
fix: 通过 API execute_job_plan 启动执行方案,如果传入的主机全局变量为空,Job 返回内部错误 #2182
@wangyu096 wangyu096 added the todo 进入开发排期的状态,纳入了最近的迭代 label Jul 7, 2023
@bkjob-bot bkjob-bot added for gray 可以在灰度环境/预发布环境验收 for test 可以在测试环境进行验收 done 已上线到正式环境并验收通过 and removed backlog 需求初始状态,等待产品进行评估 todo 进入开发排期的状态,纳入了最近的迭代 for test 可以在测试环境进行验收 for gray 可以在灰度环境/预发布环境验收 labels Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done 已上线到正式环境并验收通过 kind/bug 程序故障Bug,漏洞
Projects
None yet
Development

No branches or pull requests

2 participants