在AWS ECS上运行从属服务器时,Jenkins java.io.NotSerializableException

时间:2019-04-01 04:43:55

标签: jenkins jenkins-pipeline jenkins-plugins

我遇到一个奇怪的问题:我将自己的从属服务器作为docker映像运行,有时作为Amazon容器作为主节点运行,有时使用Amazon Elastic Container Service插件在ECS(Fargate)上运行。

我在下面的代码段中运行

publishLambda(
       awsAccessKeyId:"${env.AWS_ACCESS_KEY_ID}",
       awsSecretKey:"${env.AWS_SECRET_ACCESS_KEY}",
       awsRegion:"${lambda_config.region}",
       functionARN:lambda_name,
       functionAlias:"DEV"
      )

我将奴隶作为docker容器运行时工作正常,但是在ECS上运行时, lambda成功发布后出现以下错误。当它试图通过网络获得响应时,我怀疑 hudson.remoting API是否有用。

无论容器在哪里运行,IMO hudson.remoting的行为都应相同。我如何得到这种差异?

  

java.io.NotSerializableException:   com.xti.jenkins.plugin.awslambda.publish.LambdaPublishServiceResponse       在java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)       在java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)       在hudson.remoting.UserRequest._serialize(UserRequest.java:264)       在hudson.remoting.UserRequest.serialize(UserRequest.java:273)上:hudson.remoting.Channel $ CallSiteStackTrace:远程调用   JNLP4连接来自   ec2-18-224-68-207.us-east-2.compute.amazonaws.com/18.224.68.207:40038           在hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)           在hudson.remoting.UserRequest $ ExceptionResponse.retrieve(UserRequest.java:357)           在hudson.remoting.Channel.call(Channel.java:955)           在com.xti.jenkins.plugin.awslambda.publish.LambdaPublishBuildStep.perform(LambdaPublishBuildStep.java:58)           在com.xti.jenkins.plugin.awslambda.publish.LambdaPublishBuildStep.perform(LambdaPublishBuildStep.java:46)           在org.jenkinsci.plugins.workflow.steps.CoreStep $ Execution.run(CoreStep.java:80)           在org.jenkinsci.plugins.workflow.steps.CoreStep $ Execution.run(CoreStep.java:67)           在org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda $ start $ 0(SynchronousNonBlockingStepExecution.java:47)           在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)           在java.util.concurrent.FutureTask.run(FutureTask.java:266)           在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)           在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)


  

原因:java.io.IOException:无法序列化   com.xti.jenkins.plugin.awslambda.publish.LambdaPublishServiceResponse@4ec0e00f       在hudson.remoting.UserRequest.serialize(UserRequest.java:275)       在hudson.remoting.UserRequest.perform(UserRequest.java:223)       在hudson.remoting.UserRequest.perform(UserRequest.java:54)       在hudson.remoting.Request $ 2.run(Request.java:369)       在hudson.remoting.InterceptingExecutorService $ 1.call(InterceptingExecutorService.java:72)       在java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)       在hudson.remoting.Engine $ 1.lambda $ newThread $ 0(Engine.java:93)


  

原因:java.lang.RuntimeException       在com.xti.jenkins.plugin.awslambda.publish.LambdaPublishBuildStep.perform(LambdaPublishBuildStep.java:66)       在com.xti.jenkins.plugin.awslambda.publish.LambdaPublishBuildStep.perform(LambdaPublishBuildStep.java:46)       在org.jenkinsci.plugins.workflow.steps.CoreStep $ Execution.run(CoreStep.java:80)       在org.jenkinsci.plugins.workflow.steps.CoreStep $ Execution.run(CoreStep.java:67)       在org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda $ start $ 0(SynchronousNonBlockingStepExecution.java:47)       在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)       在java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)       在java.lang.Thread.run(Thread.java:748)上完成:失败

1 个答案:

答案 0 :(得分:0)

这样做的原因是 Amazon Elastic Container Service插件中的类 LambdaPublishServiceResponse 没有继承 java.io.Serializable

并且由于必须从运行在ECS(fargate)上的从属服务器通过网络进行Java远程处理才能被主服务器检索,因此必须进行此更改。提出了PR https://github.com/XT-i/aws-lambda-jenkins-plugin/pull/100