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

When publishing a ContentViewVersion to a LifeCycleEnvironment it would be helpful to have a way to wait for SmartProxy/Capsule synchronization to finish #1609

Open
dabelenda opened this issue May 23, 2023 · 9 comments

Comments

@dabelenda
Copy link

SUMMARY

In a use-case where we use a load-balanced setup of SmartProxies to distribute content, we want to use a single playbook to manage the ContentViewVersion promotion and the update of the machines to have a consistent and reproducible way to perform updates on clusters.
This way we can perform all preparations for update, safety checks, and reboots in the playbook, and not need manual validation that the SmartProxies are synchronized.

However, since the Capsule Synchronization task is asynchronous to ContentViewVersion Promotions.

ISSUE TYPE

Currently there is no "native" way to chain ContentViewVersion Promotion and updating of the machines automatically when SmartProxies are involved.

A helper action to wait for completion of SmartProxy synchronization (or a generic way to wait for Foreman Task(s) completion) would help greatly in that case. It is involved to wait this in pure ansible, so I personnally think that it makes sense to have it in this repository.

@evgeni
Copy link
Member

evgeni commented May 23, 2023

We have code for waiting for tasks:

def wait_for_task(self, task, ignore_errors=False):
duration = self.task_timeout
while task['state'] not in ['paused', 'stopped']:
duration -= self.task_poll
if duration <= 0:
self.fail_json(msg="Timeout waiting for Task {0}".format(task['id']))
time.sleep(self.task_poll)
resource_payload = self._resource_prepare_params('foreman_tasks', 'show', {'id': task['id']})
task = self._resource_call('foreman_tasks', 'show', resource_payload)
if not ignore_errors and task['result'] != 'success':
self.fail_json(msg='Task {0}({1}) did not succeed. Task information: {2}'.format(task['action'], task['id'], task['humanized']['errors']))
return task

So we could expose that as a wait_for_task module and that part would be solved.

However, the problem will be to find out which task to wait for. As far as I know, the "sync proxies" task is triggered asynchronously from the publish/promote tasks, so there is no reference when the publish task is done what to wait on next.

Ideally, Katello would tell us what it spawned, so we can optionally wait on that. If it doesn't, we'd have to resort to a search, but that can be unreliable :/

@dabelenda
Copy link
Author

From what I can see in the API, nothing tells us where the CapsuleSync tasks originate from...

{"parent_task_id":null,"start_at":"2023-05-23 15:57:24 +0200","start_before":null,"external_id":"f8be7b6b-815d-4db1-8eed-0aa9d0363081","id":"d2e946c0-e30a-439e-a7b6-913187f4e82d","label":"Actions::Katello::ContentView::CapsuleSync","pending":false,"action":"Sync Content View on Capsule(s)","username":"satellite-svc-accnt","started_at":"2023-05-23 15:57:24 +0200","ended_at":"2023-05-23 15:57:38 +0200","duration":"00:00:14.575","state":"stopped","result":"success","progress":1.0,"input":{"current_request_id":"4fafbba8-e670-4191-a401-0998404166ff","current_timezone":"UTC","current_organization_id":null,"current_location_id":null,"current_user_id":26},"output":{},"humanized":{"action":"Sync Content View on Capsule(s)","input":"","output":"","errors":[]},"cli_example":null,"available_actions":{"cancellable":false,"resumable":false},"execution_plan":{"state":"stopped","cancellable":false},"failed_steps":[],"running_steps":[],"help":null,"has_sub_tasks":true,"locks":[],"links":[],"username_path":"<a href=\"/users/26-satellite-svc-accnt/edit\">satellite-svc-accnt</a>","dynflow_enable_console":true}

The Promote task does not tell us which CapsuleSync task it spawned either...

{"parent_task_id":null,"start_at":"2023-05-23 15:57:11 +0200","start_before":null,"external_id":"ae8c9b71-035e-4c44-af44-8784f750829c","id":"055fe458-6b1d-44ee-a634-0c6051661256","label":"Actions::Katello::ContentView::Promote","pending":false,"action":"Promote content view 'RHEL7 ldap'; organization 'EXOP-GE'","username":"satellite-svc-accnt","started_at":"2023-05-23 15:57:11 +0200","ended_at":"2023-05-23 15:57:24 +0200","duration":"00:00:13.091","state":"stopped","result":"success","progress":1.0,"input":{"content_view":{"id":182,"name":"RHEL7 ldap","label":"RHEL7_ldap"},"organization":{"id":1,"name":"EXOP-GE","label":"EXOP-GE"},"environments":["ldap_rhel7-test"],"services_checked":["pulp3","candlepin","candlepin_auth"],"current_request_id":"4fafbba8-e670-4191-a401-0998404166ff","current_timezone":"UTC","current_organization_id":null,"current_location_id":null,"current_user_id":26},"output":{},"humanized":{"action":"Promote","input":[["content_view",{"text":"content view 'RHEL7 ldap'","link":"/content_views/182/versions"}],["organization",{"text":"organization 'EXOP-GE'","link":"/organizations/1/edit"}]],"output":"","errors":[]},"cli_example":null,"available_actions":{"cancellable":false,"resumable":false},"execution_plan":{"state":"stopped","cancellable":false},"failed_steps":[],"running_steps":[],"help":null,"has_sub_tasks":false,"locks":[],"links":[{"resource_type":"Katello::ContentView","resource_id":182,"exclusive":false},{"resource_type":"Organization","resource_id":1,"exclusive":false}],"username_path":"<a href=\"/users/26-satellite-svc-accnt/edit\">satellite-svc-accnt</a>","dynflow_enable_console":true}

The ContentViewVersion has a reference to the latest task associated with it, but it is the Promote Task not the CapsuleSync...

So wherever I look in the API the information does not seem to be present...

@evgeni
Copy link
Member

evgeni commented May 24, 2023

I've opened https://projects.theforeman.org/issues/36434 as an RFE for Katello.

@dabelenda
Copy link
Author

Ok, that would indeed be the best possible way to search for the capsule sync task.
While waiting for this RFE to be implemented, would it be possible to get an ansible module to wait on a task by ID?

This would allow to search for all capsule sync tasks running after the Promote and wait on all of them. My guess is that after the RFE implemented the search could be refined to have more pin-point waiting.

@dabelenda
Copy link
Author

Hello,

is there a way to know what is the status of this?
Are you working on it or is it in a backlog ?

@dabelenda
Copy link
Author

Hello @evgeni

no news about the state of this request ?

@evgeni
Copy link
Member

evgeni commented Jun 26, 2023

There would be news in here, if I'd have any to share ;-)

That said, it is on my todo list, but not in the "today" or "this week" buckets :(

@dabelenda
Copy link
Author

The reason I am asking is because I could get my employer to assign someone to make a PR for this feature.
But the process itself takes time, and the person would need to learn how to contribute to this project.
If I don't have a vision on the time it would take for this feature to get there without our involvement, I cannot decide if it is worth starting this process.

This RFE served two purposes:

  • one is to get your interest in that feature, if you consider it completely useless then a PR might even be rejected (my guess here is that you find it a valid use-case).
  • the second is to determine when this feature would come "naturally" and if I need my employer to get involved for a PR

@evgeni
Copy link
Member

evgeni commented Aug 11, 2023

#1656 has been merged and we now have a module for waiting on tasks, thanks @JGodin-C2C!

Now my question would be: should we consider this issue sufficiently done, or shall we add an explicit "wait on proxy sync" example, or even wait until https://projects.theforeman.org/issues/36434 is implemented?

(I personally lean towards the example route, but I am no BDFL ;))

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 a pull request may close this issue.

2 participants