Open Grofight opened 2 years ago
This issue highlights a potential thread-safety problem in the OpenStack client. The fact that Request B is using the wrong API endpoint, even after Request A has successfully generated a token with the correct service catalog, suggests that the client is not properly synchronizing access to its internal state.
To fix this issue, I would recommend introducing thread-safe mechanisms to ensure that the client's internal state is properly updated and synchronized across threads. This could involve using thread-safe data structures, such as ConcurrentHashMap or CopyOnWriteArrayList, to store the service catalog and API endpoints.
Additionally, it would be helpful to add some logging or debugging statements to track the API endpoints being used by each request, to better understand the issue and verify the fix.
Current Behavior
Thread A: Makes a request to generate a token.
POST <keystone_endpoint>/tokens
Thread B: Makes a request to get server details.
GET <keystone_endpoint>/servers/<uuid>
Request A is sucessfully finished, token is generated, service catalog contains correct API endpoints. Request B is initiated 1 ms later, but with wrong API endpoint. It uses Identity API
GET <keystone_endpoint>/servers/<uuid>
instead of Compute APIGET <nova_endpoint>/servers/<uuid>
.Expected Behavior
Openstack client should be thread-safe. Requests to different Openstack modules in multiple threads should not affect each other (particulary in terms of API endpoint resolution).
Environment
openstack4j-core - 3.10 openstack4j-httpclient - 3.10 Openstack Pike (via OSClientV2)
Impact
Requests may fail with
404 Not Found
because of wrong API endpoint.Steps to Reproduce