Skip to content

Conversation

krizex
Copy link
Member

@krizex krizex commented Apr 12, 2018

When master forward a task to slave, slave will mark the task as completed once
finish processing it, however when master finishing the forwarding, it will also
mark the task as completed. Furthermore, when slave finished the task, that does
not mean the task is done, there may be some stuff that master has to handle, so
we have to ensure the task only complete once the master finish its work.

Signed-off-by: Yang Qian yang.qian@citrix.com

@krizex krizex requested review from jonludlam and robhoes April 12, 2018 07:42
@coveralls
Copy link

coveralls commented Apr 12, 2018

Coverage Status

Coverage increased (+0.001%) to 20.363% when pulling 7c31dd1 on krizex:CA-287863 into 7cea812 on xapi-project:master.

forward ~local_fn:f ~__context
in
(* For forwarded task, we should not complete it here, the server which forward the task will complete it *)
if not (Context.forwarded_task __context) then
Copy link
Contributor

Choose a reason for hiding this comment

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

This code has become dependent on a condition but indentation has not changed to reflect this. Please check the indentation of the code.

@krizex krizex force-pushed the CA-287863 branch 2 times, most recently from 42620dc to 69783da Compare April 12, 2018 10:34
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.

Brilliant! This also finally gets rid of the stupid "the status of xxx is: success; cannot set it to success" log lines :)

@robhoes
Copy link
Member

robhoes commented Apr 12, 2018

Don't merge yet though, because some BST tests seem to be failing. Please check those out first.

if not (Context.forwarded_task __context) then begin
match marshaller with
| None -> TaskHelper.complete ~__context None
| Some fn -> TaskHelper.complete ~__context (Some (fn result))
Copy link
Member Author

Choose a reason for hiding this comment

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

@robhoes I have some concern about this. After this change, the result in the slave won't be updated to the task result, but instead will update with the execution result in the master, will it bring some other issues?

Copy link
Member

Choose a reason for hiding this comment

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

I should hope that the result of the forwarded call is already always returned (unaltered) by the master to the original caller, especially for synchronous calls. So I think this is fine.

@robhoes
Copy link
Member

robhoes commented Apr 12, 2018

The failing test seems to be an import that times out. We should check how the task completion is handled for such calls, which don't come as RPCs through server.ml, but have their own HTTP handlers.

@krizex
Copy link
Member Author

krizex commented Apr 12, 2018

Seems the installation of the build is failed, so all BST & BVT failed. I have updated with the latest specs of team/ring3/master and has started rerun the test again.
Privately I have tested this fix by uploading xapi to my hosts and the error messages gone.

@robhoes
Copy link
Member

robhoes commented Apr 12, 2018

Well, the installation was OK, but the 62-create-guest-templates firstboot script failed:

Load /usr/share/xapi/vm-templates/sles-11-sp4-64bit.json
Load /usr/share/xapi/vm-templates/ubuntu-12.04-64bit.json
Load /usr/share/xapi/vm-templates/base-windows-8.json
Insert 11fd3dc9-96cc-49af-b091-a2ca7e94c589
Traceback (most recent call last):
  File "/usr/bin/create-guest-templates", line 17, in <module>
    loader.insert_templates()
  File "/usr/lib/python2.7/site-packages/guesttemplates/loader.py", line 181, in insert_templates
    self._insert_template(i)
  File "/usr/lib/python2.7/site-packages/guesttemplates/loader.py", line 165, in _insert_template
    raise RuntimeError("Template import timeout")
RuntimeError: Template import timeout

This does a VM metadata import.

@krizex
Copy link
Member Author

krizex commented Apr 12, 2018

Hmm, I will take a look at that tomorrow.

krizex added 2 commits April 13, 2018 14:38
Move `exec` into `exec_with_context` to simplify the code.

Signed-off-by: Yang Qian <yang.qian@citrix.com>
When master forward a task to slave, slave will mark the task as completed once
finish processing it, however when master finishing the forwarding, it will also
mark the task as completed. Furthermore, when slave finished the task, that does
not mean the task is done, there may be some stuff that master has to handle, so
we have to ensure the task only complete once the master finish its work.

For the task forwarded from client, which called with
`exec_with_forwarded_task`, we also have to complete it once it finished.

Signed-off-by: Yang Qian <yang.qian@citrix.com>
@krizex
Copy link
Member Author

krizex commented Apr 13, 2018

BST & BVT passed, please have a look again @robhoes , thanks.

@robhoes
Copy link
Member

robhoes commented Apr 13, 2018

Hmm... I wonder why exec_with_forwarded_task is used in Xapi_http.with_context. That looks odd to me. In this patch, I don't quite like the new ~has_task param. I'll look a bit further...

@krizex
Copy link
Member Author

krizex commented Apr 13, 2018

@robhoes The name of has_task comes from the original comment https://github.com/xapi-project/xen-api/blob/master/ocaml/xapi/server_helpers.ml#L59
I meant to introduce a new param ~need_complete ;-)

@robhoes
Copy link
Member

robhoes commented Apr 13, 2018

Ah, that was another mysterious comment indeed :)

@robhoes
Copy link
Member

robhoes commented Apr 13, 2018

I think that it is declared a forwarded task, to make sure that the task is not destroyed when the operation completes; the task is created by the client, and should be destroyed by the client.

I also notice that the "forwarded task destroyed" log lines that we often see actually mean that the forwarded task was not destroyed...

@robhoes
Copy link
Member

robhoes commented Apr 13, 2018

We are on the right track here, but before we continue, I am going to make an overview about how tasks and contexts are used in xapi right now, because it is too confusing.

@krizex
Copy link
Member Author

krizex commented Apr 16, 2018

@robhoes Yes, it takes more than half a day to understand how context/task works.
Besides this change, I think the Server_helpers.exec_with_forwarded_task is a bad name, for every reference, it is not with a forwarded task, instead it's a task created by client side. So how about rename it to exec_with_existed_task to make it clearer?

@robhoes
Copy link
Member

robhoes commented Apr 16, 2018

Well that is indeed the problem and one of the sources of confusion: the word forwarded is used to different things, or at least the function is "abused" for different things. I think that we should reserve the term "forwarding" for the action of passing a call from the master to a slave (as in "message_forwarding").

I have some ideas now to simplify some of this area, and will do that in follow-up PRs. I'll accept this PR now, because it already fixes a real issue.

@robhoes robhoes merged commit 40fce3e into xapi-project:master Apr 16, 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.

4 participants