Skip to content

Commit a9231eb

Browse files
committed
Improve error messaging for creating a Deployment that will violate quotas with high max-in-flight
Update from code review comments and cleanup
1 parent b22f394 commit a9231eb

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

app/actions/deployment_create.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,21 @@ def create(app:, user_audit_info:, message:)
8787
end
8888

8989
def handle_deployment_create_error(e, app)
90-
space_quota_errors = [:space_quota_exceeded.to_s, :space_app_instance_limit_exceeded.to_s]
91-
org_quota_errors = [:quota_exceeded.to_s, :app_instance_limit_exceeded.to_s]
90+
space_quota_errors = %w(space_quota_exceeded space_app_instance_limit_exceeded)
91+
org_quota_errors = %w(quota_exceeded app_instance_limit_exceeded)
92+
space_error_msg = " for space #{app.space.name}. This space's quota may not be large enough to support rolling deployments or your configured max-in-flight."
93+
org_error_msg_1 = " for organization #{app.organization.name}. "
94+
org_error_msg_2 = "This organization's quota may not be large enough to support rolling deployments or your configured max-in-flight."
95+
org_error_msg = org_error_msg_1 + org_error_msg_2
96+
error_message = e.message
97+
9298
if space_quota_errors.any? { |substring| e.message.include?(substring) }
93-
space_error_msg = " for space #{app.space.name}. This space's quota may not be large enough to support rolling deployments or your configured max-in-flight."
94-
error = DeploymentCreate::Error.new(e.message + space_error_msg)
99+
error_message += space_error_msg
95100
elsif org_quota_errors.any? { |substring| e.message.include?(substring) }
96-
org_error_msg_1 = " for organization #{app.organization.name}. "
97-
org_error_msg_2 = "This organization's quota may not be large enough to support rolling deployments or your configured max-in-flight."
98-
error = DeploymentCreate::Error.new(e.message + org_error_msg_1 + org_error_msg_2)
99-
else
100-
error = DeploymentCreate::Error.new(e.message)
101+
error_message += org_error_msg
101102
end
103+
104+
error = DeploymentCreate::Error.new(error_message)
102105
error.set_backtrace(e.backtrace)
103106
error
104107
end

0 commit comments

Comments
 (0)