cloud-foundrycf-cli

Cloud Foundry more then 10 ports for an app by curl


I have running app in Cloud Foundry. I would like to proceed the procedure of adding more then 10 ports to the app described here: https://docs.cloudfoundry.org/devguide/custom-ports.html#procedure

When I am trying to add more then 10 ports, I am getting an error:

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
}

I tried to adjust some quota definitions like total_routes (-1) or total_reserved_route_ports (-1) but without any result. Why do I get this error and how can I assign more then 10 ports by cf curl?


Solution

  • As of writing this, it would appear to be an arbitrary and hardcoded limit that cannot be changed.

    See 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?
        ...
    

    and https://github.com/cloudfoundry/cloud_controller_ng/blob/master/app/models/runtime/constraints/ports_policy.rb#L44, which defines the limit.

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