From 7c4128649ea125f799389eb0dec24a847e3b8416 Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Thu, 22 Jun 2023 09:18:59 +0200 Subject: [PATCH] Fixes #36393 - Do not rebuild managed hosts in registration --- app/controllers/api/v2/registration_controller.rb | 6 +++++- .../registration/global_registration.erb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v2/registration_controller.rb b/app/controllers/api/v2/registration_controller.rb index 446aab140b2..9d442f800a4 100644 --- a/app/controllers/api/v2/registration_controller.rb +++ b/app/controllers/api/v2/registration_controller.rb @@ -92,7 +92,11 @@ def host return end - @host.setBuild + # Do not rebuild managed hosts + # Hosts registered with subscription-manager are created + # as a Host::Managed, but have @host.managed? => false + # https://projects.theforeman.org/issues/36393 + @host.setBuild unless @host.managed? safe_render(@template) end diff --git a/app/views/unattended/provisioning_templates/registration/global_registration.erb b/app/views/unattended/provisioning_templates/registration/global_registration.erb index 7bf149aab3d..f9f4af6e274 100644 --- a/app/views/unattended/provisioning_templates/registration/global_registration.erb +++ b/app/views/unattended/provisioning_templates/registration/global_registration.erb @@ -123,8 +123,9 @@ echo "#" register_katello_host(){ UUID=$(subscription-manager identity | grep --max-count 1 --only-matching '\([[:xdigit:]]\{8\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{4\}-[[:xdigit:]]\{12\}\)') curl --silent --show-error --cacert $KATELLO_SERVER_CA_CERT --request POST "<%= @registration_url %>" \ - --data "uuid=$UUID" \ <%= headers.join(' ') %> \ + --data "uuid=$UUID" \ + --data "host[build]=false" \ <%= " --data 'host[organization_id]=#{@organization.id}' \\\n" if @organization -%> <%= " --data 'host[location_id]=#{@location.id}' \\\n" if @location -%> <%= " --data 'host[hostgroup_id]=#{@hostgroup.id}' \\\n" if @hostgroup -%>