rackspace / php-opencloud

The PHP SDK for OpenStack clouds
developer.rackspace.com
Other
451 stars 249 forks source link

Endpoint factory times out if any of the URLs in the service catalog are inaccessible #716

Open ghost opened 7 years ago

ghost commented 7 years ago

I'm trying to connect to the networking service, whose service catalog entry looks like this:

1 => CatalogItem {#319 
      -name: "neutron"
      -type: "network"
      -endpoints: array:1 [
        0 => {#278 
          +"adminURL": "http://10.105.1.0:9696"
          +"region": "RegionOne"
          +"id": "15cf585068254cfb8d0ab528d7bb6536"
          +"internalURL": "http://10.105.1.0:9696"
          +"publicURL": "http://10.109.0.10:9696"
        }
      ]
    }

My code looks like this:

$this->stack = new OpenStack(MY_ENDPOINT,
            [
                    'username' =>MY_USER,
                    'password' => MY_PASSWORD,
                    'tenantId' =>MY_TENANT_ID

            ]);
$neutron= $this->stack->networkingService("neutron", "RegionOne", "publicURL");

I can't reach the 10.105 subnet, but that's fine because I just want to use the public endpoints. But I get a timeout from the factory as it tries to contact the internalURL. Looking more closely, the timeout is happening within the getVersionedURL call from within the factory, because the code is trying to make a GET request against the URL (even though I don't want to call it). This doesn't seem right to me - it implies that any API consumer should have a network route to all possible URLs. The decision as to whether to call getVersionedURL appears to be driven by the existence of a configured URL in the service catalog, rather than by the URL that the consumer wants to call.

Is there a good reason why the Endpoint class factory should assume all URLs in the service catalog are reachable by all API consumers?