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

[WIP] Add content-view version export/import skip-rpms options. #718

Conversation

jeffmcutter
Copy link

Use case:

Two separate Foreman servers which have repositories synchronized from upstream sources need to have the same content-view versions to be able to facilitate consistent life cycle management. For example, one Foreman server may be used for development environments patching and a separate Foreman server may be required to manage production environments patching due to security restrictions.

The new content-view version export/import process works nicely for this, except that if content is synchronized already via a sync plan, the export and import of the RPM repositories can create significant and unnecessary overhead in the export / import / and transfer of the tar ball from the export between export and import systems.

This PR is a work in progress. It is able to export and import content-view versions without including the RPMs using the --skip-rpms option to both content-view version export and import commands. I'm looking for feedback about this idea and implementation.

RFE BZ for this functionality: https://bugzilla.redhat.com/show_bug.cgi?id=1744255

@chris1984
Copy link
Member

Hi @jeffmcutter thanks for your PR :) When you are ready to take it out of WIP let me know and I will test and review this for you.

@jeffmcutter
Copy link
Author

Hi @chris1984. I'm happy with how the functionality works now, I'm just not too familiar with contributing to this project. Do I need to write specs / tests? I'd be interested in testing and review plus feedback. Should I remove the WIP to start that process? Thanks!

Copy link
Member

@akofink akofink left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! A test for this new option would be great. Rubocop also has a few complaints, which is causing the build to fail CI:

lib/hammer_cli_katello/content_view_version.rb:352:101: C: Line is too long. [131/100]
      option '--skip-rpms', :flag, _("Do not include RPMs in export (content must be synchronized to destination prior to import)")
                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/hammer_cli_katello/content_view_version.rb:403:34: C: Do not leave space between ! and its argument.
        if repositories&.any? && ! options['option_skip_rpms']
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/hammer_cli_katello/content_view_version.rb:450:101: C: Line is too long. [106/100]
      option '--skip-rpms', :flag, _("Skip import of RPMs (content must be synchronized prior to import)")
                                                                                                    ^^^^^^

@jeffmcutter
Copy link
Author

Hi @akofink,

I fixed the Rubocop complaints. I will look at writing tests in a week or two.

Thanks,
-Jeff

@chris1984
Copy link
Member

@jeffmcutter we are looking to get this into the next release of hammer, I can write unit tests for you and supply you a patch if you want to rebase and push.

@jeffmcutter
Copy link
Author

@chris1984 That would be fabulous if you could. I'm sorry I've just not had opportunity to get to it, but I would love to get this in there. Thank you!

@jeffmcutter
Copy link
Author

Hmm, looks like that wasn't the right thing to do? I was trying to rebase to get current before attempting to write tests.

@chris1984
Copy link
Member

chris1984 commented Jan 13, 2021

@jeffmcutter hey, so it looks like what you want to do is git log find your commit hash and then do git reset --hard <hash> This will bring it back to before you did this. Then do a git fetch --all git rebase <thisremotename> origin/master

If you need help with any of the tests let me know

@jeffmcutter
Copy link
Author

jeffmcutter commented Jan 19, 2021

@chris1984 I finally got my developer setup going and current. It's a bit tricky for this since hammer needs to run locally but the forklift stuff sets it up on its own VM, but I glued the two together and am currently testing that the changes behave as expectedly on the current version. I think I will submit a PR with that to forklift. Also encountered some difficulties here theforeman/forklift#1277.

Can you suggest some of the sorts of tests I should be thinking about for this change? I've written some tests for a ManageIQ PR before but I'm not yet making sense of https://github.com/Katello/hammer-cli-katello/blob/master/test/functional/content_view/version/export_test.rb and https://github.com/Katello/hammer-cli-katello/blob/master/test/functional/content_view/version/import_test.rb which seems to be the right place for it unless I'm mistaken.

Thanks,
-Jeff

@jeffmcutter
Copy link
Author

Having difficulties with the content-view version in upstream/master:

[vagrant@centos7-katello-hammer-devel-1 hammer-cli-katello]$ hammer content-view version export --id 2 --export-dir /tmp/test2
Warning: An error occured while loading module hammer_cli_csv.
Warning: An error occured while loading module hammer_cli_foreman_admin.
Warning: An error occured while loading module hammer_cli_foreman_remote_execution.
Warning: An error occured while loading module hammer_cli_foreman_virt_who_configure.
Could not export the content view:
  Error: No such file or directory @ dir_chdir - /var/lib/pulp/published/yum/https/repos/

@chris1984
Copy link
Member

@jeffmcutter sorry for the delay, let me try to replicate what you are hitting to give you the next steps.

@jeffmcutter
Copy link
Author

jeffmcutter commented Jan 26, 2021

with -d

Could not export the content view:
  Error: No such file or directory @ dir_chdir - /var/lib/pulp/published/yum/https/repos/
[ERROR 2021-01-26T18:16:46 Exception] 

Errno::ENOENT (No such file or directory @ dir_chdir - /var/lib/pulp/published/yum/https/repos/):
    /home/vagrant/hammer-cli-katello/lib/hammer_cli_katello/content_view_version.rb:400:in `chdir'
    /home/vagrant/hammer-cli-katello/lib/hammer_cli_katello/content_view_version.rb:400:in `create_tar'
    /home/vagrant/hammer-cli-katello/lib/hammer_cli_katello/content_view_version.rb:379:in `execute'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /home/vagrant/.gem/ruby/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /home/vagrant/.gem/ruby/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /home/vagrant/.gem/ruby/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /home/vagrant/.gem/ruby/gems/hammer_cli-2.3.0/lib/hammer_cli/abstract.rb:77:in `run'
    /home/vagrant/.gem/ruby/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /home/vagrant/.gem/ruby/gems/hammer_cli-2.3.0/bin/hammer:147:in `<top (required)>'
    /home/vagrant/.gem/ruby/bin/hammer:23:in `load'
    /home/vagrant/.gem/ruby/bin/hammer:23:in `<top (required)>'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
    /opt/rh/rh-ruby25/root/usr/share/gems/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
    /opt/rh/rh-ruby25/root/usr/bin/bundle:23:in `load'
    /opt/rh/rh-ruby25/root/usr/bin/bundle:23:in `<main>'

@jeffmcutter
Copy link
Author

I created the missing /var/lib/pulp/published/yum/https/repos/ and tried to run the export again in debug mode and got the following error:

tar: Default_Organization/content_views/test1/1.0/content/dist/layered/rhel8/x86_64/sat-tools/6.8/os: Cannot stat: No such file or directory
tar: Default_Organization/content_views/test1/1.0/content/dist/rhel/server/7/7Server/x86_64/ansible/2.9/os: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

In comparing /var/lib/pulp on the current Foreman dev against a Satellite 6.8 server, it appears that /var/lib/pulp has been restructured. Running a find to look for the organization name shows it does not exist on the Foreman dev but does on Satellite 6.8. The actual rpms appear to now be stored under /var/lib/pulp/media/artifact which I do not see on Satellite 6.8.

[root@centos7-katello-hammer-devel-1 artifact]# ls -l /var/lib/pulp/media/artifact/0a/869f21163f44eb9a9092f0d0cf7dcda432975482a9425b72d793b44c8871e2 
-rw-r--r--. 1 pulp pulp 26684004 Jan 19 23:15 /var/lib/pulp/media/artifact/0a/869f21163f44eb9a9092f0d0cf7dcda432975482a9425b72d793b44c8871e2
[root@centos7-katello-hammer-devel-1 artifact]# file /var/lib/pulp/media/artifact/0a/869f21163f44eb9a9092f0d0cf7dcda432975482a9425b72d793b44c8871e2 
/var/lib/pulp/media/artifact/0a/869f21163f44eb9a9092f0d0cf7dcda432975482a9425b72d793b44c8871e2: RPM v3.0 bin i386/x86_64 puppet-agent-6.14.0-1.el8sat

It appears that hammer content-view version export is broken as a result of these changes.

@jeffmcutter
Copy link
Author

I opened an issue:

https://projects.theforeman.org/issues/31735

@chris1984
Copy link
Member

@jeffmcutter for the Katello box, I see you are using master. Are you using a katello devel box from vagrant/forklift or a nightly production install from katello.org?

@jeffmcutter
Copy link
Author

@chris1984 I am using a katello-devel box from forklift which I have modified to include hammer as you can see in this PR:

theforeman/forklift#1279

I'm waiting for clarification, but it seems that content-view version import/export may be deprecated in newer versions of Katello or something along those lines:

https://projects.theforeman.org/issues/31735

Thanks,
-Jeff

@chris1984
Copy link
Member

@jeffmcutter

That is correct, the fixes you are adding are for Pulp 2 Which is for 3.17 and below. Katello 3.18+ is where Pulp3 started being used 100% of the time. For our downstream releases your fix would affect Satellite 6.9 and below.

So we can still keep working on this if you want.

@jeffmcutter
Copy link
Author

Being short on time again lately, and this functionality being short-lived (theforeman/forklift#1279). I will close this out. Thank you for your time and efforts.

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.

4 participants