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 #19179 - Add force full sync to proxy syncs #6869

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

johnpmitsch
Copy link
Contributor

This allows users to force full syncs on foreman proxies with
content. This is helpful when the packages on the katello
server do not match the packages on the fpc and the user
wants to force a sync of the repos

@mention-bot
Copy link

@johnpmitsch, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jlsherrill, @iNecas and @tstrachota to be potential reviewers.

@theforeman-bot
Copy link

Issues: #19179

task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content, :environment => @environment)
task = async_task(::Actions::Katello::CapsuleContent::Sync,
capsule_content,
{ :environment => @environment, :skip_metadata_check => params[:capsule_content][:skip_metadata_check] })

Choose a reason for hiding this comment

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

Redundant curly braces around a hash parameter.

def sync
find_environment if params[:environment_id]
task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content, :environment => @environment)
task = async_task(::Actions::Katello::CapsuleContent::Sync,
capsule_content,

Choose a reason for hiding this comment

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

Trailing whitespace detected.

def sync
find_environment if params[:environment_id]
task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content, :environment => @environment)
task = async_task(::Actions::Katello::CapsuleContent::Sync,

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Force full sync will sync all repositories' | translate }}"
tooltip-animation="false"
tooltip-append-to-body="true">
</i>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@waldenraines Any ideas on how to get these to be inline? these

if (!$scope.syncState.is(syncState.SYNCING)) {

$scope.syncErrorMessages = [];
$scope.syncState.set(syncState.SYNC_TRIGGERED);

CapsuleContent.sync({id: capsuleId}).$promise.then(function (task) {
CapsuleContent.sync({id: capsuleId, skip_metadata_check: skipMetadataCheck}).$promise.then(function (task) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@waldenraines this works, but I am not sure if am going about things the right way here, can you take a look?

task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content, :environment => @environment)
task = async_task(::Actions::Katello::CapsuleContent::Sync,
capsule_content,
:environment => @environment, :skip_metadata_check => params[:capsule_content][:skip_metadata_check])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlsherrill should I be using [:capsule_content] with these params? if I do params[:skip_metadata_check] the boolean is returned as a string. What is best practices here?

From: /home/vagrant/katello/app/controllers/katello/api/v2/capsule_content_controller.rb @ line 56 Katello::Api::V2::CapsuleContentController#sync:

    53: def sync
    54:   find_environment if params[:environment_id]
    55:   binding.pry
 => 56:   task = async_task(::Actions::Katello::CapsuleContent::Sync,
    57:                     capsule_content,
    58:                     :environment => @environment, :skip_metadata_check => params[:capsule_content][:skip_metadata_check])
    59:   respond_for_async :resource => task
    60: end

[1] pry(#<Katello::Api::V2::CapsuleContentController>)> params
=> {"id"=>"2-almond-proxy-example-com",
 "skip_metadata_check"=>true,
 "api_version"=>"v2",
 "controller"=>"katello/api/v2/capsule_content",
 "action"=>"sync",
 "capsule_content"=>{"id"=>"2-almond-proxy-example-com", "skip_metadata_check"=>true}}

Copy link
Member

Choose a reason for hiding this comment

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

Best practice would be to use the foreman boolean helper:

::Foreman::Cast.to_bool(params[:skip_metadata_check]

@@ -122,13 +122,13 @@ angular.module('Bastion.capsule-content').controller('CapsuleContentController',

$scope.isTaskInProgress = isTaskInProgress;

$scope.syncCapsule = function () {
$scope.syncCapsule = function (skipMetadataCheck = false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@waldenraines the linter doesn't seem to like this default argument, is there another way I should be writing this?

Running "eslint:target" (eslint) task

app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js
  125:58  error  Unexpected token =

✖ 1 problem (1 error, 0 warnings)

Copy link
Contributor

Choose a reason for hiding this comment

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

That looks like a JS syntax error.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that default functional parameters are valid in es5.

@johnpmitsch johnpmitsch force-pushed the fpc_force_sync branch 3 times, most recently from 1fd3bf0 to bb535c1 Compare July 14, 2017 14:53
@johnpmitsch
Copy link
Contributor Author

[test]

@@ -26,7 +26,6 @@ def plan(repo, pulp_sync_task_id = nil, options = {})
pulp_sync_options = {}
pulp_sync_options[:download_policy] = ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND if validate_contents
pulp_sync_options[:force_full] = true if skip_metadata_check
pulp_sync_options[:auto_publish] = false if skip_metadata_check #skip auto publish, and force it later
Copy link
Member

Choose a reason for hiding this comment

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

Was this removed intentionally? Is this sync action used for proxies or only for the katello server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlsherrill and I found out that this option actually doesn't do anything in pulp and we decided to remove it in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

hang one bit with this, i think something is going here, because I basically used this option to reproduce an issue here: #6830 and it seemed to work for me and the reviewer

Copy link
Member

Choose a reason for hiding this comment

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

nevermind, proceed with this. I chatted with the pulp team and this option won't do anything

Synchronize
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="syncDropdown">
Copy link
Member

Choose a reason for hiding this comment

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

Would it also make sense to offer the 'Validate Content Sync' option that is available as an Advanced Sync option for repositories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbuckingham that one is a bit more difficult to implement so I just added this option for now, I think it would be best to follow up with the validate option in a later PR if we deem it necessary

@bbuckingham
Copy link
Member

Testing of basic scenarios using the new options, behaved as expected and was consistent with the same options provided for a repo sync (e.g. complete & optimized).

task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content.capsule, :environment_id => @environment.try(:id))
skip_metadata_check = ::Foreman::Cast.to_bool(params[:skip_metadata_check])
task = async_task(::Actions::Katello::CapsuleContent::Sync,
capsule_content.capsule,

Choose a reason for hiding this comment

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

Trailing whitespace detected.

@johnpmitsch johnpmitsch force-pushed the fpc_force_sync branch 3 times, most recently from eec01ab to 1c3da65 Compare July 19, 2017 12:48
Copy link
Member

@bbuckingham bbuckingham left a comment

Choose a reason for hiding this comment

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

Reviewed and tested well for me. ACK!

@jlsherrill
Copy link
Member

For skip_metadata_check on repo syncs, we're doing a metadata generate with force_full as well:

https://github.com/Katello/katello/blob/master/app/lib/actions/katello/repository/sync.rb#L46

I think we still need to do that here.

@johnpmitsch johnpmitsch force-pushed the fpc_force_sync branch 2 times, most recently from bea627a to e67106f Compare July 19, 2017 14:06
sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,
repo, capsule_id:
capsule_content.capsule.id,

Choose a reason for hiding this comment

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

Trailing whitespace detected.

sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,
repo, capsule_id:

Choose a reason for hiding this comment

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

Trailing whitespace detected.

plan_action(Pulp::Consumer::SyncCapsule,
capsule_id: capsule_content.capsule.id,
repo_pulp_id: repo_id,
sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,

Choose a reason for hiding this comment

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

Favor a normal if-statement over a modifier clause in a multiline statement.
Trailing whitespace detected.

sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,
repo, capsule_id:
capsule_content.capsule.id,

Choose a reason for hiding this comment

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

Trailing whitespace detected.

sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,
repo, capsule_id:

Choose a reason for hiding this comment

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

Trailing whitespace detected.

plan_action(Pulp::Consumer::SyncCapsule,
capsule_id: capsule_content.capsule.id,
repo_pulp_id: repo_id,
sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
sync_options: pulp_options)
plan_action(Katello::Repository::MetadataGenerate,

Choose a reason for hiding this comment

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

Favor a normal if-statement over a modifier clause in a multiline statement.
Trailing whitespace detected.

This allows users to force full syncs on foreman proxies with
content. This is helpful when the packages on the katello
server do not match the packages on the fpc and the user
wants to force a sync of the repos
@jlsherrill
Copy link
Member

ACK

@johnpmitsch johnpmitsch merged commit 7fddb44 into Katello:master Jul 26, 2017
@johnpmitsch johnpmitsch deleted the fpc_force_sync branch July 26, 2017 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants