简体   繁体   English

由于 .ebextensions 文件,Elastic Beanstalk 部署失败

[英]Elastic Beanstalk deployment failing due to .ebextensions File

I'm deploying a flask (flask-restplus) REST API to an AWS Elastic Beanstalk instance, and I'm running into a weird failure mode.我正在将烧瓶 (flask-restplus) REST API 部署到 AWS Elastic Beanstalk 实例,并且遇到了奇怪的故障模式。

One of my API endpoints has a dependency on OpenCV, which requires some dependencies as outlined at: ImportError: libGL.so.1: cannot open shared object file: No such file or directory while importing OCC .我的 API 端点之一依赖于 OpenCV,这需要一些依赖项,如下所述: ImportError: libGL.so.1: cannot open shared object file: No such file or directory while importing OCC Per the answers there, I created an .ebextensions directory and created two files, one to install the libGL packages, which looks like this:根据那里的答案,我创建了一个 .ebextensions 目录并创建了两个文件,一个用于安装 libGL 包,如下所示:

packages:
  yum:
    mesa-libGL : []
    mesa-libGL-devel : []

I saved that file as packages.config, if that matters.如果重要的话,我将该文件保存为packages.config。

The second file in .ebextensions downloads and installs zlib: .ebextensions 中的第二个文件下载并安装 zlib:

commands:
    00_download_zlib:
        command: |
            wget https://github.com/madler/zlib/archive/v1.2.9.tar.gz
            tar xzvf v1.2.9.tar.gz
            cd zlib-1.2.9
            ./configure
            make
            make install
            ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so
            ln -fs /usr/local/lib/libz.so.1.2.9 /lib64/libz.so.1

I saved that file as zlib.config.我将该文件保存为 zlib.config。

When I first ran eb deploy , everything worked great.当我第一次运行eb deploy ,一切都很好。 Deployment was successful, my API responded to requests, and the code that depended on OpenCV worked.部署成功,我的 API 响应了请求,依赖 OpenCV 的代码工作了。 So far so good.到现在为止还挺好。

However, on subsequent deployments, I've gotten the following errors:但是,在后续部署中,我收到了以下错误:

2020-11-18 23:47:44    ERROR   Instance deployment failed. For details, see 'eb-engine.log'.
2020-11-18 23:47:45    ERROR   [Instance: i-XXXXXXXXXXXXX] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2020-11-18 23:47:45    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-11-18 23:47:45    ERROR   Unsuccessful command execution on instance id(s) 'i-XXXXXXXXXXXXX'. Aborting the operation.
2020-11-18 23:47:46    ERROR   Failed to deploy application.

I went in and pulled down the logs from the instance, first looking at eb-engine.log.我进入并从实例中提取日志,首先查看 eb-engine.log。 The only error there is:唯一的错误是:

2020/11/18 23:47:44.131837 [ERROR] An error occurred during execution of command [app-deploy] - [PreBuildEbExtension]. Stop running the command. Error: EbExtension build failed. Please refer to /var/log/cfn-init.log for more details. 

However, looking at cfn-init.log just indicates that everything succeeded:但是,查看 cfn-init.log 只是表明一切都成功了:

2020-11-18 23:47:34,297 [INFO] -----------------------Starting build-----------------------
2020-11-18 23:47:34,306 [INFO] Running configSets: Infra-EmbeddedPreBuild
2020-11-18 23:47:34,309 [INFO] Running configSet Infra-EmbeddedPreBuild
2020-11-18 23:47:34,313 [INFO] Running config prebuild_0_newapi
2020-11-18 23:47:36,512 [INFO] Running config prebuild_1_newapi
2020-11-18 23:47:44,106 [INFO] Command 00_download_zlib succeeded
2020-11-18 23:47:44,108 [INFO] ConfigSets completed
2020-11-18 23:47:44,108 [INFO] -----------------------Build complete-----------------------

I then tried removing the entire .ebextensions directory and re-deploying, and the deployment succeeded.然后我尝试删除整个 .ebextensions 目录并重新部署,部署成功。 Then I tried adding back the .ebextensions directory and adding the files one at a time, and discovered that the deployment worked fine when I added packages.config, but failed again when I added zlib.config.然后我尝试添加回 .ebextensions 目录并一次添加一个文件,发现添加 packages.config 时部署工作正常,但添加 zlib.config 时再次失败。

My question boils down to: why is this happening, and is there anything I can do to resolve it?我的问题归结为:为什么会发生这种情况,我能做些什么来解决它? My understanding is that I need both of these files deployed to my instance in case I migrate to a different enviroment, or AutoScaling migrates my instance, etc.我的理解是,我需要将这两个文件都部署到我的实例,以防我迁移到不同的环境,或者 AutoScaling 迁移我的实例等。

The only thing I can think of is that the instance doesn't like the fact that I keep re-installing zlib, but the cfn-init-cmd.log indicates that all the commands in zlib.config are succeeding, as does cfn-init.log.我唯一能想到的是实例不喜欢我不断重新安装zlib的事实,但是cfn-init-cmd.log表明zlib.config中的所有命令都成功了,cfn也是如此-初始化日志。 So why is eb-engine.log reporting an error?那么为什么 eb-engine.log 会报错呢? Is it telling me to look in the wrong place for logs that may be relevant?它是否告诉我在错误的地方查找可能相关的日志? I've looked in every log file and I don't see anything else indicating any issues.我查看了每个日志文件,但没有看到任何其他表明任何问题的内容。

I did find one tangentially-related possible solution relating to Immutable Environment Updates , which looks like it may work but feels like a bit of unnecessary work.我确实找到了一个与Immutable Environment Updates相关的可能解决方案,它看起来可能有效,但感觉像是一些不必要的工作。 At the very least I'd like to understand why I need to make that change and why Elastic Beanstalk isn't playing nicer with my .ebextensions.至少我想了解为什么我需要进行这种更改以及为什么 Elastic Beanstalk 不能更好地与我的 .ebextensions 配合使用。

Just in case anyone runs across this in the future, I wanted to share the solution.以防万一将来有人遇到这个问题,我想分享解决方案。 I was never able to determine why the zlib install process was failing after the first deployment on an instance, so I ended up using the Immutable Environment Updates settings I linked in my original question.我永远无法确定为什么 zlib 安装过程在实例上第一次部署后失败,所以我最终使用了我在原始问题中链接的不可变环境更新设置。

Deployments take a bit longer to process as the deployment creates an autoscaling group and a new instance on each deployment, but my deployments just work every time now.部署需要更长的时间来处理,因为部署会在每个部署上创建一个自动缩放组和一个新实例,但我的部署现在每次都可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM