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

Fixes #36852 - Allow fetching capsule sync task per env #10779

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

sjha4
Copy link
Member

@sjha4 sjha4 commented Oct 26, 2023

What are the changes introduced in this pull request?

Update Smart Proxy content UI to show env level sync tasks if those exist.

Considerations taken when implementing this change?

We are showing env level records on new smart proxy page. We have a column to show the last sync task for the environments individually. The only way to start an env sync is via hammer/API which starts a capsule sync task with environment_id set in input[:options]

PS: There's a known issue here where if you run a complete sync and then later add a new env to the smart proxy, the complete sync task will appear to have run on the env on the page. Right now we have no way of telling if envs were added before or after a sync was run. Open to ideas. In these cases, even if the env suggests capsule is synced, the expansion aka CV will show not synced cause that information comes from smart_proxy_sync_history record.

What are the testing steps for this pull request?

  1. Add a few env to a capsule and run a complete sync.
  2. In hammer, run a targeted sync for a particular environment: hammer capsule content synchronize --lifecycle-environment-id=4 --id=2
  3. Go to smart proxy UI and confirm if the Sync time for the env changes to the latest task.

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

I'm seeing an error:

Last sync failed: comparison of ActiveSupport::TimeWithZone with nil failed

image

023-10-27T20:29:16 [E|app|cf6ae499] ActionView::Template::Error: comparison of ActiveSupport::TimeWithZone with nil failed
 cf6ae499 | /home/vagrant/katello/app/models/katello/concerns/smart_proxy_extensions.rb:456:in `>'
 cf6ae499 | /home/vagrant/katello/app/models/katello/concerns/smart_proxy_extensions.rb:456:in `last_env_sync_task'
 cf6ae499 | (eval):40:in `block (2 levels) in cached_source_2878749412122931441'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:158:in `node'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:116:in `block in compile_settings'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:115:in `each'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:115:in `compile_settings'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:60:in `block in to_hash'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:253:in `cache_results'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:51:in `to_hash'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/multi_builder.rb:27:in `map'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/multi_builder.rb:27:in `to_a'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:93:in `to_hash'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:51:in `block in render'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:392:in `cache_results'
 cf6ae499 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:50:in `render'
 cf6ae499 | /home/vagrant/foreman/config/initializers/rabl_init.rb:49:in `render'
...

@sjha4 sjha4 force-pushed the env_specific_capsule_sync branch from bf5c415 to 4699f3b Compare October 30, 2023 15:22
@sjha4
Copy link
Member Author

sjha4 commented Oct 30, 2023

I added https://projects.theforeman.org/issues/36873 as an issue..Is a corner case on newly added envs before a sync so we can tackle it in code chill..

@ianballou
Copy link
Member

If I cleanup all of my ForemanTasks I get the following 500 error:

2023-10-30T18:23:47 [E|app|e8eef823] ActionView::Template::Error: undefined method `id' for nil:NilClass
 e8eef823 | (eval):42:in `block (2 levels) in cached_source_3731720242962982329'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:158:in `node'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:116:in `block in compile_settings'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:115:in `each'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:115:in `compile_settings'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:60:in `block in to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:253:in `cache_results'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:51:in `to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/multi_builder.rb:27:in `map'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/multi_builder.rb:27:in `to_a'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:93:in `to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:51:in `block in render'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:392:in `cache_results'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:50:in `render'
 e8eef823 | /home/vagrant/foreman/config/initializers/rabl_init.rb:49:in `render'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:126:in `block (2 levels) in merge_engines_into_result'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:125:in `each'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:125:in `block in merge_engines_into_result'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:121:in `each'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:121:in `merge_engines_into_result'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:57:in `block in to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:253:in `cache_results'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/builder.rb:51:in `to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:91:in `to_hash'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:104:in `to_dumpable'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:113:in `to_json'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:51:in `block in render'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:392:in `cache_results'
 e8eef823 | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/rabl-0.16.1/lib/rabl/engine.rb:50:in `render'
 e8eef823 | /home/vagrant/foreman/config/initializers/rabl_init.rb:49:in `render'
 e8eef823 | /home/vagrant/katello/app/views/katello/api/v2/capsule_content/sync_status.json.rabl:3:in `__home_vagrant_katello_app_views_katello_api_v__capsule_content_sync_status_json_rabl___3846013534983629963_110860'

@ianballou
Copy link
Member

ianballou commented Oct 30, 2023

Looking at the code... maybe that bug already existed?

Edit: nope, it's not reproducible on master, huh

I'm guessing the /home/vagrant/katello/app/views/katello/api/v2/capsule_content/sync_status.json.rabl:3: part of the back trace is misleading then.

@ianballou
Copy link
Member

The 500 aside, it's looking good where there are sync tasks to find

@sjha4 sjha4 force-pushed the env_specific_capsule_sync branch from 4699f3b to 75592c9 Compare October 30, 2023 18:52
@sjha4
Copy link
Member Author

sjha4 commented Oct 30, 2023

The 500 makes sense for when no tasks exist..Added nil check for that..Should show N/A as last sync on UI when tasks are cleaned up.

@ianballou
Copy link
Member

No more 500, but now it shows both "not synced" and "synced" at the same time:

image

@sjha4
Copy link
Member Author

sjha4 commented Oct 30, 2023

No more 500, but now it shows both "not synced" and "synced" at the same time:

image

Hmm..The env sync task info comes from the task but the CV sync info comes from smart proxy sync history object.

@ianballou
Copy link
Member

Hmm..The env sync task info comes from the task but the CV sync info comes from smart proxy sync history object.

Maybe that's just fine, the last sync says N/A instead of not synced I realize.

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

Looking fine to me!

@sjha4 sjha4 merged commit a261146 into Katello:master Oct 31, 2023
4 of 5 checks passed
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.

2 participants