如何避免AWS Elastic Beanstalk上的TooManyApplicationVersion异常?

时间:2012-03-06 18:17:06

标签: amazon-web-services elastic-beanstalk

最近有人目击了

TooManyApplicationVersions Exception
部署新应用程序版本(战争)时,在AWS Elastic Beanstalk控制台上

?看到这条消息是非常烦人的,因为只有在你完成上传战争后它才出现。

我很想知道为什么会发生这种异常以及应该采取哪些预防措施来避免这种情况?

5 个答案:

答案 0 :(得分:19)

这是一个使用AWS CLI的单行程序,它将帮助您清除旧的应用程序版本:

aws elasticbeanstalk describe-application-versions --output text --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' | grep "2014-02" | while read app ver date; do aws elasticbeanstalk delete-application-version --application-name $app --version-label $ver --delete-source-bundle; done

将grep替换为您认为合适的日期,(2013,2014-01,2014-02-0等)。

答案 1 :(得分:18)

原因

您所看到的例外源于达到AWS Elastic Beanstalk的相应帐户限制,请参阅CreateApplicationVersion [释义] 中的错误部分:< / p>

  
      
  • TooManyApplicationVersions - 来电者已超出限制   与其帐户关联的应用程序版本数。
  •   
  • TooManyApplications - 来电者已超出与其帐户关联的应用数量限制。
  •   

目前的限制在各自的常见问题How many applications can I run with AWS Elastic Beanstalk?中列出:

  

您最多可以创建25个应用程序和 500个应用程序版本。通过   默认情况下,您可以在所有人中运行多达10个环境   应用。如果您还在Elastic Beanstalk之外使用AWS,   您可能不是[...] 如果您需要更多资源,请填写AWS Elastic   Beanstalk请求表格和您的请求将被及时评估。 [强调我的]

解决方案

正如所强调的那样,AWS提供了常用的升级选项,如果您确实需要许多应用程序版本仍可供重用,则允许您提交Request to Increase AWS Elastic Beanstalk Limits。否则你可能会删除不再使用的旧版本,问题应该相应消失。

祝你好运!

答案 2 :(得分:12)

从EB CLI 3.3开始,您现在可以运行以下命令来清除旧版本:

$ eb labs cleanup-versions

默认情况下,这将清除最近10个版本和/或超过60天。添加--help,输出以下内容:

usage: eb labs cleanup-versions [options...]

Cleans up old application versions.

optional arguments:
--num-to-leave NUM    number of versions to leave DEFAULT=10
--older-than DAYS     delete only versions older than x days DEFAULT=60
--force               don't prompt for confirmation

答案 3 :(得分:9)

您接近最大版本数量,需要删除旧的或未使用的版本。

在当前的Web控制台中,您只需在Beanstalk环境的“应用程序版本”选项卡上执行此操作即可。

enter image description here

答案 4 :(得分:1)

这是我们在部署脚本中用来删除最早的应用程序版本的代码段。

console.log('Deleting oldest application version.');
params = {};
local.waitFor(function(done) {
    eb.describeApplicationVersions(params, function(err, data) {
        if (err) {
            console.error(err, err.stack);
            local.abort('Could not retrieve the list of application version.');
        } else {
            // This is probably not needed as the list is already sorted but it is
            // not written anywhere that this will always be the case
            function compare(a,b) {
                if (a.DateCreated > b.DateCreated)
                    return -1;
                if (a.DateCreated < b.DateCreated)
                    return 1;
                return 0;
            }
            var applicationsVersion = data['ApplicationVersions'].sort(compare),
                oldestApplication   = applicationsVersion[applicationsVersion.length - 1],
                applicationName     = oldestApplication['ApplicationName'],
                versionLabel        = oldestApplication['VersionLabel'];
            params = {
                ApplicationName: applicationName, /* required */
                VersionLabel:    versionLabel,    /* required */
                DeleteSourceBundle: false /* Do not delete source bundle from S3 */
            };
            eb.deleteApplicationVersion(params, function(err, data) {
                if (err) {
                    console.error(err, err.stack);
                    local.abort('Could not delete the oldest application version. (' + versionLabel + ')')
                } else {
                    console.log('Successfully deleted the oldest application version. (' + versionLabel + ')');
                }
            });
        }
    });
});

Elastic Beantalk API(js)的文档:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ElasticBeanstalk.html

相关问题