Problem during registering host with activation key/"Host has already been taken"

Hello,

As mentioned in the subject, I have a problem during provisioning at the host registering phase.

In the post-installation script’s log I can see following output:

Registering the System

+ subscription-manager register --org=Production --name=server.example.com --activationkey=Katello_activation_key
Task 38aeae2b-80b1-49e1-a94d-9993587a5fdc: ActiveRecord::RecordInvalid: Validation failed: Host has already been taken

Usually, this should looks like the following:

Registering the System

+ subscription-manager register --org=Production --name=server2.example.com --activationkey=Katello_activation_key
The system has been registered with ID: 41260a81-9a39-4562-b022-565c6163bb7a

In the logs I could find something similar to:

2018-02-16 13:27:53  [katello/cp_rest] [D] Resource GET request: /candlepin/activation_keys/?include=id&include=pools.pool.id
2018-02-16 13:27:53  [katello/cp_rest] [D] Headers: {"accept":"application/json","accept-language":"en","content-type":"application/json","cp-user":"foreman_admin"}
2018-02-16 13:27:53  [katello/cp_rest] [D] Body: {}
2018-02-16 13:27:53  [app] [D] Setting current user thread-local variable to nil
2018-02-16 13:27:53  [foreman-tasks/action] [E] Validation failed: Host has already been taken (ActiveRecord::RecordInvalid)
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:79:in `raise_record_invalid'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:43:in `save!'
...

and

...
2018-02-16 13:27:53 12bad314 [katello/cp_proxy] [E] ForemanTasks::TaskError: Task 38aeae2b-80b1-49e1-a94d-9993587a5fdc: ActiveRecord::RecordInvalid: Validation failed: Host has already been taken
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6/lib/foreman_tasks.rb:40:in `block in sync_task'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6/lib/foreman_tasks.rb:39:in `tap'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6/lib/foreman_tasks.rb:39:in `sync_task'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.9.6/lib/foreman_tasks/triggers.rb:22:in `sync_task'

Interesting thing is, that it is not happening every time. This happens once in 3/4 provisioning attempts…

Foreman and Proxy versions:
foreman-proxy-1.15.6-1.el7.noarch
foreman-release-1.15.6-1.el7.noarch

Foreman and Proxy plugin versions:
katello-3.4.5-1.el7.noarch
katello-agent-3.0.2-1.el7.noarch

If there is a need for any other symptoms, just let me know.

I will be glad if anyone of you could help me with this.

Thanks and regards!!

Can it be, that the provisioning template does use the subscription-manager twice? If you search for “38aeae2b-80b1-49e1-a94d-9993587a5fdc” in Content Host, can you find a entry?

Hello Bernhard,

Yup, you are right, whenever registration fails, I got completely different UUID number in the Content Host summary than the one that is suggested during the provisioning.

Do you have any idea where this can be coming from ? As I mentioned before, this only happens in about 20% provisioning cases…

Thanks!!
M.