cannot deploy - ERROR: You cannot have more than 500 Application Versions
cannot deploy - ERROR: You cannot have more than 500 Application Versions
部署到 EB 时出现以下错误:
ERROR: You cannot have more than 500 Application Versions. Either
remove some Application Versions or request a limit increase.
我手动删除了一些版本。
我不希望部署因为这个限制而失败。
Elastic Beanstalk 中有没有办法自动清除未使用的版本?
没有内置方法可以做到这一点,但下面的 ruby 脚本可以做到这一点。只需使用 cron 安排它。
clearnup.rb:
application_name="myApp"
active_versions_shell_output = `aws elasticbeanstalk describe-environments --region=us-east-1 | grep git | awk '{gsub(/.*\:\ \"/,"",[=10=]); print}'`
all_versions_shell_output = `aws elasticbeanstalk describe-applications --region=us-east-1 | grep git | awk '{gsub(/.*\ \"/,"",[=10=]); print}'`
all_versions = all_versions_shell_output.split(/\n/).map{|x| x[0..57]}
active_versions = active_versions_shell_output.split(/\n/).map{|x| x[0..57]}
(all_versions - active_versions).each do |version_to_be_deleted|
puts "deleting #{version_to_be_deleted}"
`aws elasticbeanstalk delete-application-version --delete-source-bundle --application-name #{application_name} --version-label #{version_to_be_deleted}`
end
最近向 eb cli (v3.3) 添加了一个功能来清理旧版本
https://m.reddit.com/r/aws/comments/340ce0/whats_the_thinking_behind_beanstalks_versioning/
正在从 reddit 复制命令 link
$ eb labs cleanup-versions --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
在撰写此答案时,eb labs cleanup-versions
对我不起作用:它返回 No application versions to delete
即使我有应用程序版本。
作为解决方法,我使用了受 this answer 启发的 one-liner(更改 区域 和 应用程序名称 相应地):
aws elasticbeanstalk describe-application-versions --output text --region=us-west-2 --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' | grep my-app-name | while read app ver date; do echo "deleting version $app $ver $date" ; aws elasticbeanstalk delete-application-version --region=us-west-2 --application-name $app --version-label $ver --delete-source-bundle; done
现在,他们添加了一个管理 UI 页面来删除所有应用程序版本:
您现在可以从 AWS 控制台管理生命周期策略。
在您要管理的应用程序右侧的操作下拉列表中,单击查看应用程序版本.
单击右上角的 设置 按钮,您将能够配置要保留的版本数量:
如果您已经达到限制,您必须首先手动删除一些版本以允许此生命周期策略生效(有关解释,请阅读下面的注释)。
备注
来自 Configuring Application Version Lifecycle Settings 文档:
Elastic Beanstalk applies an application's lifecycle policy each time
you create a new application version, and deletes up to 100 versions
each time the lifecycle policy is applied. Elastic Beanstalk deletes
old versions after creating the new version, and does not count the
new version towards the maximum number of versions defined in the
policy.
Elastic Beanstalk does not delete application versions that are
currently being used by an environment, or application versions
deployed to environments that were terminated less than ten weeks
before the policy was triggered.
The application version limit applies across all applications in a
region. If you have several applications, configure each application
with a lifecycle policy appropriate to avoid reaching the limit.
Elastic Beanstalk only applies the policy if the application version
creation succeeds, so if you have already reached the limit, you must
delete some versions manually prior to creating a new version.
我在这里找到了解决方案,简单的解决方案是删除以前的版本,如下所述。
删除应用程序版本
打开 Elastic Beanstalk 控制台,在区域列表中,select 您的 AWS 区域。
在导航窗格中,选择“应用程序”,然后从列表中选择您的应用程序名称。
Note
If you have many applications, use the search bar to filter the
application list.
In the navigation pane, find your application's name and choose
Application versions.
Select 您要删除的一个或多个应用程序版本。
选择操作,然后选择删除。
(可选)要将这些应用程序版本的应用程序源包保留在您的 Amazon Simple Storage Service (Amazon S3) 存储桶中,请清除从 Amazon S3 删除版本复选框。
选择删除。
另一种解决方案
转到版本设置并启用生命周期策略,如下所示。
参考:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-versions.html
部署到 EB 时出现以下错误:
ERROR: You cannot have more than 500 Application Versions. Either remove some Application Versions or request a limit increase.
我手动删除了一些版本。 我不希望部署因为这个限制而失败。 Elastic Beanstalk 中有没有办法自动清除未使用的版本?
没有内置方法可以做到这一点,但下面的 ruby 脚本可以做到这一点。只需使用 cron 安排它。
clearnup.rb:
application_name="myApp"
active_versions_shell_output = `aws elasticbeanstalk describe-environments --region=us-east-1 | grep git | awk '{gsub(/.*\:\ \"/,"",[=10=]); print}'`
all_versions_shell_output = `aws elasticbeanstalk describe-applications --region=us-east-1 | grep git | awk '{gsub(/.*\ \"/,"",[=10=]); print}'`
all_versions = all_versions_shell_output.split(/\n/).map{|x| x[0..57]}
active_versions = active_versions_shell_output.split(/\n/).map{|x| x[0..57]}
(all_versions - active_versions).each do |version_to_be_deleted|
puts "deleting #{version_to_be_deleted}"
`aws elasticbeanstalk delete-application-version --delete-source-bundle --application-name #{application_name} --version-label #{version_to_be_deleted}`
end
最近向 eb cli (v3.3) 添加了一个功能来清理旧版本
https://m.reddit.com/r/aws/comments/340ce0/whats_the_thinking_behind_beanstalks_versioning/
正在从 reddit 复制命令 link
$ eb labs cleanup-versions --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
在撰写此答案时,eb labs cleanup-versions
对我不起作用:它返回 No application versions to delete
即使我有应用程序版本。
作为解决方法,我使用了受 this answer 启发的 one-liner(更改 区域 和 应用程序名称 相应地):
aws elasticbeanstalk describe-application-versions --output text --region=us-west-2 --query 'ApplicationVersions[*].[ApplicationName,VersionLabel,DateCreated]' | grep my-app-name | while read app ver date; do echo "deleting version $app $ver $date" ; aws elasticbeanstalk delete-application-version --region=us-west-2 --application-name $app --version-label $ver --delete-source-bundle; done
现在,他们添加了一个管理 UI 页面来删除所有应用程序版本:
您现在可以从 AWS 控制台管理生命周期策略。
在您要管理的应用程序右侧的操作下拉列表中,单击查看应用程序版本.
单击右上角的 设置 按钮,您将能够配置要保留的版本数量:
如果您已经达到限制,您必须首先手动删除一些版本以允许此生命周期策略生效(有关解释,请阅读下面的注释)。
备注
来自 Configuring Application Version Lifecycle Settings 文档:
Elastic Beanstalk applies an application's lifecycle policy each time you create a new application version, and deletes up to 100 versions each time the lifecycle policy is applied. Elastic Beanstalk deletes old versions after creating the new version, and does not count the new version towards the maximum number of versions defined in the policy.
Elastic Beanstalk does not delete application versions that are currently being used by an environment, or application versions deployed to environments that were terminated less than ten weeks before the policy was triggered.
The application version limit applies across all applications in a region. If you have several applications, configure each application with a lifecycle policy appropriate to avoid reaching the limit. Elastic Beanstalk only applies the policy if the application version creation succeeds, so if you have already reached the limit, you must delete some versions manually prior to creating a new version.
我在这里找到了解决方案,简单的解决方案是删除以前的版本,如下所述。
删除应用程序版本
打开 Elastic Beanstalk 控制台,在区域列表中,select 您的 AWS 区域。
在导航窗格中,选择“应用程序”,然后从列表中选择您的应用程序名称。
Note
If you have many applications, use the search bar to filter the application list.
In the navigation pane, find your application's name and choose Application versions.
Select 您要删除的一个或多个应用程序版本。
选择操作,然后选择删除。
(可选)要将这些应用程序版本的应用程序源包保留在您的 Amazon Simple Storage Service (Amazon S3) 存储桶中,请清除从 Amazon S3 删除版本复选框。
选择删除。
另一种解决方案
转到版本设置并启用生命周期策略,如下所示。
参考:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-versions.html