Cloud Foundry 通过 curl 为应用程序提供超过 10 个端口

Cloud Foundry more then 10 ports for an app by curl

我在 Cloud Foundry 中有 运行 个应用程序。我想继续向此处描述的应用程序添加 10 个以上端口的过程:https://docs.cloudfoundry.org/devguide/custom-ports.html#procedure

当我尝试添加超过 10 个端口时,出现错误:

cf curl /v2/apps/c5476e63-d1d2-4eb7-a757-18cff957bc5a -X PUT -d '{"ports": [2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042]}' 

{
   "description": "The app is invalid: Process must have at most 10 exposed ports.",
   "error_code": "CF-AppInvalid",
   "code": 100001
}

我尝试调整一些配额定义,例如 total_routes (-1) 或 total_reserved_route_ports (-1),但没有任何结果。为什么会出现此错误以及如何通过 cf curl 分配超过 10 个端口?

在撰写本文时,它似乎是一个无法更改的任意硬编码限制。

https://github.com/cloudfoundry/cloud_controller_ng/blob/master/app/models/runtime/constraints/ports_policy.rb#L9:

 def validate
    return if @process.ports.nil? || @process.ports.empty?
    return @errors.add('Process', 'must have at most 10 exposed ports.') if ports_limit_exceeded?
    return @errors.add('Ports', 'must be integers.') unless all_ports_are_integers?
    ...

https://github.com/cloudfoundry/cloud_controller_ng/blob/master/app/models/runtime/constraints/ports_policy.rb#L44,它们定义了限制。

  def ports_limit_exceeded?
    @process.ports.length > 10
  end