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

Fix transition of GpgKey to ContentCredential #79

Merged
merged 2 commits into from Dec 6, 2021

Conversation

m-bucher
Copy link
Member

@m-bucher m-bucher commented Oct 5, 2021

This fix breaks compatibility with Katello <4.2

fixes #77

@nadjaheitmann
Copy link
Collaborator

I am reluctant to break Scc Manager for all Katello versions < 4.2 (given that Katello 4.2 has not even been released, yet). So I would prefer to have a solution which takes into account the current Katello version and picks the relevant commands based on that. Luckily, it is not a lot of commands so might be manageable.

@nadjaheitmann nadjaheitmann marked this pull request as ready for review December 1, 2021 08:31
@SGetovski
Copy link

Hello,
I am not sure how exactly to apply those changes that is why I have modified all 4 files manually but I still see an error message:
Oops, we're sorry but something went wrong undefined method `katello_gpg_key_id' for #SccAccount:0x000000000fee0b88

/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_scc_manager-1.8.10/app/controllers/scc_accounts_controller.rb
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_scc_manager-1.8.10/app/lib/actions/scc_manager/subscribe_product.rb
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_scc_manager-1.8.10/db/migrate/20201119084201_add_gpg_key_to_scc_account.rb
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_scc_manager-1.8.10/lib/foreman_scc_manager/engine.rb

@nadjaheitmann
Copy link
Collaborator

@SGetovski Did you do a fresh install or did you do an upgrade?

@SGetovski
Copy link

@nadjaheitmann I have done a fresh install a couple of months ago and then I faced this issue. The installation was done by me as a proof of concept in order to show the management what we could achieve with a tool as Foreman. Today I have changed the files but maybe I have to change/do something more.

@nadjaheitmann
Copy link
Collaborator

@SGetovski There is a database migration which is failing due to unmet dependencies. So you need to run foreman-rake db:migrate to apply the changes to the database. You also might need to restart your foreman instance, e.g. by foreman-maintain service restart. If that still does not work, I need to look a more detailed backtrace. Don't forget to backup first :)

@SGetovski
Copy link

Hello,
I have performed foreman-rake db:migrate and foreman-maintain service restart but unfortunately the error still persists:
Oops, we're sorry but something went wrong undefined method `katello_gpg_key_id' for #SccAccount:0x000000000df3a0e0

foreman-rake db:migrate --trace
Rubocop not loaded.
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment
** Execute plugin:refresh_migrations
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke dynflow:migrate (first_time)
** Invoke environment
** Execute dynflow:migrate
[root ~]#

@nadjaheitmann
Copy link
Collaborator

@SGetovski I have retested the patch that we have and it works just fine for me. So I am not sure what is wrong with your system. Can you verify that you have applied the patch correctly?

@nadjaheitmann nadjaheitmann merged commit d9e3abd into master Dec 6, 2021
@maximiliankolb maximiliankolb deleted the fix_gpgkey_contentcredential branch December 6, 2021 13:42
@nadjaheitmann
Copy link
Collaborator

@SGetovski We have merged the fix and I will bump a new version of the SCC manager, shortly. You can try to install the newest version once the packaging is done.

@SGetovski
Copy link

@nadjaheitmann Maybe I am doing something wrong. Could you please provide me some instructions how to apply the patch after I download the source.

@nadjaheitmann
Copy link
Collaborator

@SGetovski I had to do another patch because the one we have here did not work on Foreman >= 3.0. https://github.com/ATIX-AG/foreman_scc_manager/pull/87/files
Although the packaging has been merged, it looks like it will take a little bit more time until the package is available for download.

If you need to use Foreman Scc Manager, you could probably install Foreman 2.5 for your showcase while we wrap up the patching. Is that an option for you?

@SGetovski
Copy link

@nadjaheitmann thank you very much for your help and explanation. I can wait up to 3, 4 weeks more because I would like to continue with Foreman 3.0. Then if the patch still does not work on Foreman >= 3.0 I will make a clean installation using Foreman 2.5 - yes this is an option for me.

@SGetovski
Copy link

I have applied v1.8.16 and performed foreman-rake db:migrate and foreman-maintain service restart but unfortunately the error still persists.

On my system when I click on the button "Add SCC account" the fallowing error still appears:
Oops, we're sorry but something went wrong undefined method `katello_gpg_key_id' for #SccAccount:0x00007fe7a590f0a8

Maybe it is not related to no one of both fixes - Fix transition of GpgKey to ContentCredential #79 and Fix db migration for Katello 4.2 #87

and I have to make a fresh install with Foreman 2.5.

Foreman version: 3.0.0
Plugins:

foreman-tasks 5.0.0
foreman_puppet 1.0.0.rc.2
foreman_remote_execution 4.7.0
foreman_scc_manager 1.8.16
katello 4.2.0.rc1

@nadjaheitmann
Copy link
Collaborator

@SGetovski Any progress? Have you run foreman-installer after installing the plugin?

@SGetovski
Copy link

@nadjaheitmann yes I have run foreman-installer after I have installed the plugin.
2022-01-18 16:43:54 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-01-18 16:44:00 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-01-18 16:44:00 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-01-18 16:44:09 [NOTICE] [configure] Starting system configuration.
2022-01-18 16:44:23 [NOTICE] [configure] 250 configuration steps out of 1999 steps complete.
2022-01-18 16:44:28 [NOTICE] [configure] 500 configuration steps out of 1999 steps complete.
2022-01-18 16:44:28 [NOTICE] [configure] 750 configuration steps out of 2003 steps complete.
2022-01-18 16:44:31 [NOTICE] [configure] 1000 configuration steps out of 2007 steps complete.
2022-01-18 16:44:33 [NOTICE] [configure] 1250 configuration steps out of 2011 steps complete.
2022-01-18 16:44:59 [NOTICE] [configure] 1500 configuration steps out of 2011 steps complete.
2022-01-18 16:44:59 [NOTICE] [configure] 1750 configuration steps out of 2011 steps complete.
2022-01-18 16:45:08 [NOTICE] [configure] 2000 configuration steps out of 2011 steps complete.
2022-01-18 16:45:10 [NOTICE] [configure] System configuration has finished.
Executing: foreman-rake upgrade:run
Rubocop not loaded.
Upgrade Step 1/2: katello:correct_repositories. This may take a long while.
Processing Repository 1/29: base_x86_64 (1)
Processing Repository 2/29: extras_x86_64 (2)
Processing Repository 3/29: updates_x86_64 (3)
Processing Repository 4/29: docker-ce_x86_64 (5)
Processing Repository 5/29: epel_x86_64 (6)
Processing Repository 6/29: base_x86_64 (7)
Processing Repository 7/29: extras_x86_64 (8)
Processing Repository 8/29: updates_x86_64 (9)
Processing Repository 9/29: base_x86_64 (10)
Processing Repository 10/29: extras_x86_64 (11)
Processing Repository 11/29: updates_x86_64 (12)
Processing Repository 12/29: extras_x86_64 (13)
Processing Repository 13/29: updates_x86_64 (14)
Processing Repository 14/29: base_x86_64 (15)
Processing Repository 15/29: base_x86_64 (16)
Processing Repository 16/29: docker-ce_x86_64 (17)
Processing Repository 17/29: epel_x86_64 (18)
Processing Repository 18/29: extras_x86_64 (19)
Processing Repository 19/29: updates_x86_64 (20)
Processing Repository 20/29: base_x86_64 (21)
Processing Repository 21/29: docker-ce_x86_64 (22)
Processing Repository 22/29: epel_x86_64 (23)
Processing Repository 23/29: extras_x86_64 (24)
Processing Repository 24/29: updates_x86_64 (25)
Processing Repository 25/29: extras_x86_64 (26)
Processing Repository 26/29: epel_x86_64 (27)
Processing Repository 27/29: docker-ce_x86_64 (28)
Processing Repository 28/29: updates_x86_64 (29)
Processing Repository 29/29: base_x86_64 (30)
Upgrade Step 2/2: katello:clean_backend_objects. This may take a long while.
0 orphaned consumer id(s) found in candlepin.
Candlepin orphaned consumers: []
Success!

Then I have run:
[root@~]# foreman-rake db:migrate
Rubocop not loaded.
[root@ ]# foreman-rake db:seed
Rubocop not loaded.
[root@]# foreman-maintain service restart

and again when I click on the button "Add SCC account" the fallowing error still appears:
Oops, we're sorry but something went wrong undefined method `katello_gpg_key_id' for #SccAccount:0x00007fa554a1d640

@nadjaheitmann
Copy link
Collaborator

nadjaheitmann commented Jan 19, 2022

@SGetovski I am sorry that you are having a hard time with the new patch. I have tested again on Foreman 3.0.0 and Katello 4.2.0.1 rc3, and I cannot reproduce your error. I did the following:

  1. Install package
  2. foreman-installer
  3. foreman-maintain service restart

The error you get is definitely related to the new patch - looks like it was not applied correctly, at least I cannot reproduce. Maybe, you can try creating an SCC account via API and see if you still get errors:

curl -X POST -k -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW46Y2hhbmdlbWU=' -i 'https://URL/api/v2/scc_accounts ' --data '{ "scc_account": {
"name" : "test",
"login" : "test",
"password" : "test"
}
}'

Edit: There is also an SCC manager plugin for Hammer CLI, if you are familiar with that.

@SGetovski
Copy link

@nadjaheitmann I think we have made some progress. First I have installed the SCC manager plugin for Hammer CLI.
Then I have managed to add an SCC account using hammer:
hammer scc_manager scc_accounts create --base-url https://scc.suse.com --name SUSE_Repo --login (Organization Credentials) --password --location

Now I am able to see the created account:
hammer scc_manager scc_accounts list --location
-------------------------|---------------------|----------------------------|------------------ --|-------------------|--------------

SCC ACCOUNT NAME SCC ACCOUNT ID ORGANIZATION NAME BASE URL SYNC INTERVAL SYNC DATE
SUSE_Repo 1 https://scc.suse.com never 2022-01-114:37:05UTC
------------------------- --------------------- ------------------------------ ----------------- - ------------------- ------------------------

Unfortunately I am not able to manage them. When I click on some button - Add SCC Account or even on the already created SUSE_Repo the error still appears:
Oops, we're sorry but something went wrong undefined method `katello_gpg_key_id' for #SccAccount:0x00007fa7116c9d40

@SGetovski
Copy link

Hello again,
Here are some messages from the dynflow:

Label: Actions::SccManager::SubscribeProduct
Status: stopped
Result: error

undefined method katello_gpg_key_id' for #<SccAccount:0x000000001415c868> (NoMethodError) /opt/theforeman/tfm/root/usr/share/gems/gems/activemodel-6.0.3.7/lib/active_model/attribute_methods.rb:432:in method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_scc_manager-1.8.16/app/lib/actions/scc_manager/subscribe_product.rb:14:in block in plan' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan.rb:384:in switch_flow'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:423:in `sequence'

-------- cut ----------

@nadjaheitmann
Copy link
Collaborator

@SGetovski I tried again on a 3.1 system and it worked just fine. I think that there is something wrong with your installation.

@SGetovski
Copy link

@nadjaheitmann can you advise me how I could update to 3.1? Or maybe it would be better to re-install the whole server or just the foreman service?

@nadjaheitmann
Copy link
Collaborator

@SGetovski I don't think that the problem is about the Foreman version. If it is not too much effort for you, you can try to set up a new system. Here is also the upgrade manual: https://theforeman.org/manuals/3.1/index.html#3.6Upgradeto3.1

@SGetovski
Copy link

@nadjaheitmann I have tried creating an SCC account via API:

[root@bgsofore001 ~]# curl -X POST -k -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW46Y2hhbmdlbWU=' -i 'https://bgsofore001/api/v2/scc_accounts ' --data '{ "scc_account": {
"name" : "test",
"login" : "test",
"password" : "test"
}
}'
HTTP/1.1 400 Bad Request
Date: Thu, 27 Jan 2022 07:08:29 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<title>400 Bad Request</title> Bad Request Your browser sent a request that this server could not understand.

Also I have uninstalled tfm-rubygem-foreman_scc_manager. Then

  1. downloaded the source file of v1.8.16 and installed it using rpm.
    2, foreman-installer
  2. foreman-maintain service restart

For now I get the same error.

@nadjaheitmann
Copy link
Collaborator

nadjaheitmann commented Jan 27, 2022

@SGetovski You might need to run foreman-rake apipie:cache to get the API up-to-date. Although I would expect that either foreman-maintain or foreman-installer take care of this, automatically. We recommend

yum install tfm-rubygem-foreman_scc_manager
foreman-installer

for installation (see https://github.com/ATIX-AG/foreman_scc_manager/blob/master/README.md)

@SGetovski
Copy link

@nadjaheitmann I am running with katello 4.2.0.rc1 and when I use yum install tfm-rubygem-foreman_scc_manager it is going to install foreman_scc_manager 1.8.12 that is why I have installed it with
yum install https://yum.theforeman.org/katello/4.3/katello/el7/x86_64/tfm-rubygem-foreman_scc_manager-1.8.16-1.fm3_1.el7.noarch.rpm

then I have executed foreman-installer but again the issue is still there.

I think I have to make a new installation fallowing these guide:
https://docs.theforeman.org/3.1/Installing_Server_on_Red_Hat/index-katello.html

@nadjaheitmann
Copy link
Collaborator

@SGetovski You are right, the repo was not yet available in the repositories - should be by now, though.

https://yum.theforeman.org/katello/4.2/katello/el7/x86_64/tfm-rubygem-foreman_scc_manager-1.8.16-1.fm3_0.el7.noarch.rpm

@SGetovski
Copy link

@nadjaheitmann thank you :)
now it is available in the repo.
Yesterday I have added another SCC account using hammer cli and another SCC account via API as you have advised me and the accounts were successfully created....but from the web I am still getting the same error.

I am wondering if could be a database mismatch/corruption but I am not sure how to prove it. That is why I think to upgrade to 3.1 and then if I still have the same issue the only option would be to re-install the whole server. :)

@nadjaheitmann
Copy link
Collaborator

@SGetovski The new package is finally available:
https://yum.theforeman.org/katello/nightly/katello/el7/x86_64/tfm-rubygem-foreman_scc_manager-1.8.17-1.fm3_2.el7.noarch.rpm

@SGetovski
Copy link

@nadjaheitmann, thanks a lot for this information and your help. I am going to install and try it.

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.

DB-migration fails with Katello 4.2
3 participants