Skip to content

Conversation

minli1
Copy link
Member

@minli1 minli1 commented Oct 16, 2018

Job 2288870 passed.

Signed-off-by: Min Li min.li1@citrix.com

jonludlam and others added 2 commits October 16, 2018 11:12
Rather than going over http over the network to fetch the RPMs and yum metadata,
connect to the local xapi and have the requests forwarded over stunnel.

This behaviour is activated by calling the (undocumented) Pool_update.attach
API with the new parameter 'use_localhost_proxy' set to true. The absence of
the parameter is treated as 'false' and xapi will fall back to the old behaviour.

Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage decreased (-0.009%) to 20.875% when pulling b4236e5 on minli1:private/minl1/CA-299944-new into 4bb384c on xapi-project:master.

  1.Adding more log
  2.Catch exception for invalid UUID and close the fd.

Signed-off-by: Min Li <min.li1@citrix.com>
@minli1
Copy link
Member Author

minli1 commented Oct 17, 2018

I have refined the comments, mainly trying to handle the invalid host uuid scenario.
So ask help again to review it. Thanks. @jonludlam @edwintorok @krizex @alexbrett

Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just started reviewing and will continue tomorrow. But here's some feedback already.

  1.Add naples_release.
  2.Do not use 'get_localhost_uuid'.

Signed-off-by: Min Li <min.li1@citrix.com>
Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine apart from the one point below.

|None ->
debug "Caught exception while get Host by uuid %s" host_uuid;
Http_svr.response_badrequest ~req s;
req.Request.close <- true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In spite of the indentation, this line is part of the | None -> case (only). I think that rather than having it here, we should put this line near the top of pool_update_download_handler, because we always want to handle just one request, not matter what the response will be, so we never want to keep the connection alive after the response.

Even before this patch, we don't actually close the connection on the path that calls Http_svr.response_forbidden, which looks wrong to me. Moving the line to the top would fix that as well.

Searching for close <- true reveals that many similar handlers do it this way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both 'forbidden' and 'badrequest' we instruct the client to close the connection, which should cause us to close too (see https://github.com/xapi-project/xen-api-libs-transitional/blob/master/http-svr/http.ml#L30-L33 and https://github.com/xapi-project/xen-api-libs-transitional/blob/master/http-svr/http.ml#L57-L60). However, it's good form for us to close proactively so we should set req.Request.close to true in all cases, as @robhoes suggests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the we may end up handling multiple requests on the one connection - since after the initial headers we proxy all the traffic, any subsequent requests will also be proxied, until either the client or remote server closes the connection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @robhoes @jonludlam
Finally I move the req.Request.close <- true near the top of the handler as Rob suggested, I found other handlers do in this way.

 - Put 'req.Request.close <- true' on the top of the handler

 Signed-off-by: Min Li <min.li1@citrix.com>
@minli1
Copy link
Member Author

minli1 commented Oct 19, 2018

Code updated, please help to take a look again and merge if no other concern. Many thanks, Rob. @robhoes
Also, I rerun the tests with the latest code, 2292688 and 2292615 passed.

@robhoes robhoes merged commit c42a7fe into xapi-project:master Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants