Skip to content

Commit

Permalink
Ensure we close idle connections (if any) in the openshift transport
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jun 29, 2023
1 parent a5f4777 commit bfd6d5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func newOpenshiftClient(ref openshiftReference) (*openshiftClient, error) {
}, nil
}

func (c *openshiftClient) close() {
c.httpClient.CloseIdleConnections()
}

// doRequest performs a correctly authenticated request to a specified path, and returns response body or an error object.
func (c *openshiftClient) doRequest(ctx context.Context, method, path string, requestBody []byte) ([]byte, error) {
requestURL := *c.baseURL
Expand Down
4 changes: 3 additions & 1 deletion openshift/openshift_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func (d *openshiftImageDestination) Reference() types.ImageReference {

// Close removes resources associated with an initialized ImageDestination, if any.
func (d *openshiftImageDestination) Close() error {
return d.docker.Close()
err := d.docker.Close()
d.client.close()
return err
}

func (d *openshiftImageDestination) SupportedManifestMIMETypes() []string {
Expand Down
9 changes: 5 additions & 4 deletions openshift/openshift_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ func (s *openshiftImageSource) Reference() types.ImageReference {

// Close removes resources associated with an initialized ImageSource, if any.
func (s *openshiftImageSource) Close() error {
var err error
if s.docker != nil {
err := s.docker.Close()
err = s.docker.Close()
s.docker = nil

return err
}

return nil
s.client.close()

return err
}

// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
Expand Down

0 comments on commit bfd6d5a

Please sign in to comment.