Skip to content
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

delegate_to is not reflected in report #282

Closed
noonedeadpunk opened this issue Jun 30, 2021 · 8 comments
Closed

delegate_to is not reflected in report #282

noonedeadpunk opened this issue Jun 30, 2021 · 8 comments
Labels
api Related to the API enhancement UI Related to the built-in user interface
Milestone

Comments

@noonedeadpunk
Copy link

What is the issue ?

Delegated tasks are not displayed in any way in ara report.
For instance, task is shown to be executed against infra1 host:
https://storage.bhs.cloud.ovh.net/v1/AUTH_dcaab5e32b234d56b626f72581e3644c/zuul_opendev_logs_725/798638/5/check/openstack-ansible-functional-ubuntu-bionic/7254c25/logs/ara-report/results/445.html

However, whole block is delegated to localhost: https://storage.bhs.cloud.ovh.net/v1/AUTH_dcaab5e32b234d56b626f72581e3644c/zuul_opendev_logs_725/798638/5/check/openstack-ansible-functional-ubuntu-bionic/7254c25/logs/ara-report/files/121.html#line-20

Which is eventually what happening according to the output log:

2021-06-29 14:43:13.217383 \| ubuntu-bionic \| TASK [pki : Initialise the serial number for RabbitMQRoot] *********************
--
4684 | 2021-06-29 14:43:13.217440 \| ubuntu-bionic \| 2021-06-29 14:43:13,217 INFO ansible: TASK [pki : Initialise the serial number for RabbitMQRoot] *********************
4685 | 2021-06-29 14:43:13.966321 \| ubuntu-bionic \| changed: [infra1 -> localhost]
4686 | 2021-06-29 14:43:13.966857 \| ubuntu-bionic \| 2021-06-29 14:43:13,966 INFO ansible: changed: [infra1 -> localhost]

Env:

  • py6
  • ansible 2.10.9
  • ara[server] 1.5.6 instaled from pypi

What should be happening ?

There should be some representation in report about real host against which tasks are executed and respect delegated tasks. Otherwise report is pretty misleading.

@dmsimard
Copy link
Contributor

o/ thanks for the issue !

For what it's worth, I found an openstack-ansible example of delegated task that we already had recorded on the demo instance: https://demo.recordsansible.org/results/435852.html and it's API response: https://demo.recordsansible.org/api/v1/results/435852

So, you're right, ara's callback currently simply doesn't verify if the task is delegated or not and there's no field for it in the API but it seems possible to do according to this snippet upstream: https://github.com/ansible/ansible/blob/60c9f045cc9195e9c8b3b90027dc19b72f9c579d/lib/ansible/plugins/callback/__init__.py#L100-L113

Adding support for this would be a good improvement.

In terms of potential implementation between the callback and the API, I can see it working this way:

  1. Add a delegated_to field to the result model, much like the original host:
    host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name="results")
  2. From the callback, determine if a result was delegated or not (like the snippet from ansible/ansible)
  3. If it is, do a get_or_create_host with the delegated host name to get it's ID and add it to delegated_to (the delegated hostname is /probably/ already locally cached so likely not a significant performance hit)

From a UI perspective, if the delegated_to field is empty, we would do like before as usual but if it's not, we display the delegated_to host instead -- probably highlighting it in some way. Since we keep the original host, we can display it as well as a reference.

@dmsimard dmsimard added api Related to the API enhancement UI Related to the built-in user interface labels Jun 30, 2021
@dmsimard dmsimard added this to the 1.5.7 milestone Jul 20, 2021
@dmsimard
Copy link
Contributor

I tried the approach I suggested and got it to work, for example -- a normal task:
Selection_168

And then a delegated one:
Selection_170

I still need to write some API-level tests for it but it will land in time for 1.5.7 which is getting closer to release.

Thanks for the issue !

@dmsimard
Copy link
Contributor

I've pushed a PR of my WIP so far: #293

@dmsimard
Copy link
Contributor

The PR has been merged and it will be released in 1.5.7.

Thanks for creating an issue about this !

@dmsimard
Copy link
Contributor

I felt that showing it in the details wasn't sufficient and it will also now be highlighted in the result tables like this:
delegate

@dmsimard
Copy link
Contributor

For the record, the feature had to be largely re-implemented and even required additional fixes due to a bug in Ansible under certain circumstances:

@noonedeadpunk
Copy link
Author

Sorry for bringing so much trouble with that. For me it looked really more trivial, alike with the initial implementation....

@dmsimard
Copy link
Contributor

Sorry for bringing so much trouble with that. For me it looked really more trivial, alike with the initial implementation....

I thought so too ! No worries, I'm happy that it works now and I learned a bit in the process :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the API enhancement UI Related to the built-in user interface
Projects
None yet
Development

No branches or pull requests

2 participants