HomePhorge

(PUP-744) Retrieve Net::HTTP objects from the current pool
7c870311db75Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-744) Retrieve Net::HTTP objects from the current pool

Previously, the puppet connection owned a ruby http connection, and
could create it lazily in a number of different ways, e.g. #address.

If an HTTP request resulted in a redirect, the @connection instance
variable would be overwritten with a new ruby http object. This made
it difficult to reason about the lifecycle of ruby http objects.

The commit associates a site with each puppet connection. As a result
it is trivial to ask the puppet connection what its #address is and
do so without creating a ruby http object.

This commit also removes the @connection instance variable. Instead
connections are obtained from the pool for the duration of the request,
e.g. Connection#get.

The Connection#connection private method is retained for now, as a
number of tests rely on it, via send(:connection). Currently it
delegates to the factory to return a new connection, but will be deleted
in a future commit.

Finally, the redirect loop relied on a non-local jump. This exposed a
bug in the pool implementation, because the connection wasn't returned
to the pool. That bug was fixed in a preceding commit, but to ensure
these sorts of things don't happen in the future, this commit returns
the response outside of the with_connection block.

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPUe43a423c9f43: (PUP-744) Ensure connections do not leak
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPU7c870311db75: (PUP-744) Retrieve Net::HTTP objects from the current pool (authored by Josh Cooper <josh@puppetlabs.com>).Jul 25 2014, 6:36 PM