New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task names do not match task output when running with "strategy: free" #260
Comments
|
Hi @jhampson-dbre and thanks for the issue ! I know what the I don't have time to look into this right now but I will leave the issue opened so we can look at it when we have a chance. |
|
I'll try and do some digging if see if I can turn anything up. From poking around in the db (sqlite), I have found this: task {
"model": "api.task",
"pk": 212,
"fields": {
"created": "2021-04-15T15:25:59.950Z",
"updated": "2021-04-15T15:26:00.026Z",
"started": "2021-04-15T15:25:59.940Z",
"ended": "2021-04-15T15:26:00.014Z",
"duration": "00:00:00.073905",
"name": "debug 3",
"action": "debug",
"lineno": 28,
"tags": "eJyLjgUAARUAuQ==",
"handler": false,
"status": "completed",
"play": 3,
"file": 11,
"playbook": 3
}
},result {
"model": "api.result",
"pk": 205,
"fields": {
"created": "2021-04-15T15:25:59.984Z",
"updated": "2021-04-15T15:25:59.984Z",
"started": "2021-04-15T15:25:59.911Z",
"ended": "2021-04-15T15:25:59.969Z",
"duration": "00:00:00.058667",
"status": "failed",
"changed": false,
"ignore_errors": false,
"content": "eJyrVkrOSMxLT01RslJIS8wpTtVRUMotTgfylFwyUxTy8ksUkvNzC0pLUpVqAUCMDoA=",
"host": 30,
"task": 212,
"play": 3,
"playbook": 3
}
},
{
"model": "api.result",
"pk": 206,
"fields": {
"created": "2021-04-15T15:26:00.004Z",
"updated": "2021-04-15T15:26:00.004Z",
"started": "2021-04-15T15:25:59.955Z",
"ended": "2021-04-15T15:25:59.990Z",
"duration": "00:00:00.035031",
"status": "ok",
"changed": false,
"ignore_errors": false,
"content": "eJyrVkrOSMxLT01RslJIS8wpTtVRUMotTgfylFJSk0rTFYyVagHYFQs7",
"host": 29,
"task": 212,
"play": 3,
"playbook": 3
}
},The top result record (id 205) is the same as the screenshot above. It is associated with task id 212 (debug 3) and host id 30 (serverq01b). However, result id 206 is also associated with task id 212 and host id 29 (serverq01c). From what I can tell, this result/task combination is the correct one. The result id 205 associated with task id 212 is incorrect. If you can point me in the right direction of that code where this task/result mapping occurs, I'll see if i can turn up anything else. Thanks! |
|
Added some extra logging to plugin. My initial thought is that it appears to be some sort of race condition with either how task id's are generated or retrieved: |
|
Thanks for looking into this @jhampson-dbre! In the normal linear strategy, it goes a bit like this in chronological order:
At the beginning of each play and each task, we "end" the previous objects: ara/ara/plugins/callback/ara_default.py Lines 305 to 308 in e4cd215
ara/ara/plugins/callback/ara_default.py Lines 353 to 355 in e4cd215
I suspect that with the free strategy we can get into a situation where the callback ends a task (because it's starting a new one) and then another host later returns a result for a task that was already ended so it ends up being associated to another one. Enabling multi-threading (with ex: Maybe instead of storing/caching the tasks and plays in self.play and self.task, we could store the data in something like |
|
By the way, poking at the DB doesn't provide the best user experience since some fields are serialized by the API or compressed. You might want to browse around using the API browser instead like https://demo.recordsansible.org/api/v1/ for example -- it's available when you run |
|
A couple of thoughts:
|
Yeah, maybe we could use the UUID as the identifier key in place of the ara/ara/plugins/callback/ara_default.py Lines 373 to 385 in e4cd215
I'm not sure if we should store the UUID in the database like for plays but in any case I don't see us doing an API request for every task (or result) to retrieve the task belonging to a UUID, the performance overhead would be significant. We don't do a lookup for plays, it's really just for ara's action plugins so it's fine.
Agreed. The current approach works well for linear, probably need to revisit this to work well with free.
If the UUID is available there, that would be a way, yes. |
|
I have a lightly-tested-but-seems-to-work fix for this. Surely it needs some work, but it might at least generate some better ideas :) Basically, I've added a When a new task is started
This prevents multiple task id's from being generated for the same task uuid When we go to store the result for a particular task/host combination in Now we have the correct task name associated with the result. Are you taking PR's on GitHub yet? If so, I can open one with what I've got so far. |
|
We've transitioned to GitHub pull requests a while ago but I haven't had the chance to update the contributors documentation yet. Feel free to open something and we can discuss it there. |
|
PR #268 is open. Since my last post, I saw the existing host_cache and file_cache and changed the implementation to be similar to that. |
|
PR 268 merged with a fix that will be released as part of 1.5.7. Thanks for the issue and the contribution, much appreciated ! |
jhampson-dbre commentedApr 15, 2021
•
edited
What is the issue ?
When running a playbook with
strategy: freeand multiple hosts, the task names in ARA web UI do not match with the task output and task result that is recorded.Here is an example.
Playbook
ARA problematic record example
command line output from the 2 tasks that are mashed up
The ARA screenshots show
Task: debug 3withStatus: failedandResult: msg Did not computeThe Ansible output shows the correct task to match the status and result is
Task: Simulate a failureThe ARA screenshots do not show a
Task: Simulate a failurefor this server.You can also see in the screenshots that it recorded two
debug 3tasks (there second one is accurately recorded), and twoSimulate successful completion tasks(the first has the wrong result recorded, second is correct)relevant playbook command line debug output
What should be happening ?
All status/results in ARA should have the correct task names associated when the playbook runs.
The text was updated successfully, but these errors were encountered: