Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2108719 - Upgrading to Satellite 6.11 fails on db:migrate stage with error "null value in column "created_at" violates not-null constraint"
Summary: Upgrading to Satellite 6.11 fails on db:migrate stage with error "null value ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Organizations and Locations
Version: 6.11.0
Hardware: All
OS: Linux
high
high
Target Milestone: 6.12.0
Assignee: satellite6-bugs
QA Contact: Shweta Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-19 19:07 UTC by Sayan Das
Modified: 2024-10-09 07:50 UTC (History)
9 users (show)

Fixed In Version: foreman-3.3.0.2-1,rubygem-foreman_puppet-4.0.3
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2112393 (view as bug list)
Environment:
Last Closed: 2022-11-16 13:34:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github theforeman foreman_puppet pull 305 0 None Merged Fix the taxable_taxonomies creation 2022-08-25 07:55:21 UTC
Red Hat Issue Tracker SAT-12272 0 None None None 2022-08-18 00:24:45 UTC
Red Hat Knowledge Base (Solution) 6967315 0 None None None 2022-07-19 19:35:07 UTC
Red Hat Product Errata RHSA-2022:8506 0 None None None 2022-11-16 13:34:54 UTC

Description Sayan Das 2022-07-19 19:07:41 UTC
Description of problem:

Upgrading to Satellite 6.11 fails on db:migrate stage with error "null value in column "created_at" violates not-null constraint"


Version-Release number of selected component (if applicable):

Satellite 6.11 [ RHEL 7 ]


How reproducible:

In customer environments 


Steps to Reproduce:
1. Install Satellite 6.10 
2. Upgrade to 6.11 as per documentation
3.

Actual results:

Upgrade fails:
~~
\ Executing installer2022-07-19 10:48:00 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-07-19 10:48:00 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
| Executing installer2022-07-19 10:48:42 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Failed to call refresh: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-07-19 10:48:42 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
~~

Error from logs:
~~
2022-07-19 10:48:00 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2022-07-19 10:48:00 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: Caused by:
2022-07-19 10:48:00 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: PG::NotNullViolation: ERROR:  null value in column "created_at" violates not-null constraint
2022-07-19 10:48:00 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: DETAIL:  Failing row contains (321220, 4, 1, ForemanPuppet::Environment, null, null).
~~


"foreman-rake db:migrate" output:
~~~
== 20220208135305 MigrateEnvironmentIgnoreType: migrating =====================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::NotNullViolation: ERROR:  null value in column "created_at" violates not-null constraint
DETAIL:  Failing row contains (321227, 4, 1, ForemanPuppet::Environment, null, null).
~~~


Expected results:

The upgrade should be successful. 


Additional info:

The issue happens as The schema of taxable_taxonomies table somehow is not correct.

For a satellite having this issue:

~~~
[root@rhsat ~]$ echo "\d+ taxable_taxonomies" | su - postgres -c "psql foreman"
                                                             Table "public.taxable_taxonomies"
    Column    |            Type             | Collation | Nullable |                    Default                     | Storage  | Stats target | Description
--------------+-----------------------------+-----------+----------+------------------------------------------------+----------+--------------+-------------
 id           | integer                     |           | not null | nextval('taxable_taxonomies_id_seq'::regclass) | plain    |              |
 taxonomy_id  | integer                     |           |          |                                                | plain    |              |
 taxable_id   | integer                     |           |          |                                                | plain    |              |
 taxable_type | character varying(255)      |           |          |                                                | extended |              |
 created_at   | timestamp without time zone |           | not null |                                                | plain    |              |
 updated_at   | timestamp without time zone |           | not null |                                                | plain    |              |
Indexes:
    "taxable_taxonomies_pkey" PRIMARY KEY, btree (id)
    "taxable_index" UNIQUE, btree (taxable_type, taxable_id, taxonomy_id)
    "index_taxable_taxonomies_on_taxonomy_id_and_taxable_type" btree (taxonomy_id, taxable_type)
Foreign-key constraints:
    "taxable_taxonomies_taxonomy_id_fk" FOREIGN KEY (taxonomy_id) REFERENCES taxonomies(id)
Access method: heap


[root@rhsat ~]$ echo "select * from taxable_taxonomies where created_at is null;" | su - postgres -c "psql foreman"
 id | taxonomy_id | taxable_id | taxable_type | created_at | updated_at
----+-------------+------------+--------------+------------+------------
(0 rows)
~~~

Expected:

~~~
# echo "\d+ taxable_taxonomies" | su - postgres -c "psql foreman"
                                                             Table "public.taxable_taxonomies"
    Column    |            Type             | Collation | Nullable |                    Default                     | Storage  | Stats target | Description 
--------------+-----------------------------+-----------+----------+------------------------------------------------+----------+--------------+-------------
 id           | integer                     |           | not null | nextval('taxable_taxonomies_id_seq'::regclass) | plain    |              | 
 taxonomy_id  | integer                     |           |          |                                                | plain    |              | 
 taxable_id   | integer                     |           |          |                                                | plain    |              | 
 taxable_type | character varying(255)      |           |          |                                                | extended |              | 
 created_at   | timestamp without time zone |           |          |                                                | plain    |              | 
 updated_at   | timestamp without time zone |           |          |                                                | plain    |              | 
Indexes:
    "taxable_taxonomies_pkey" PRIMARY KEY, btree (id)
    "taxable_index" UNIQUE, btree (taxable_type, taxable_id, taxonomy_id)
    "index_taxable_taxonomies_on_taxonomy_id_and_taxable_type" btree (taxonomy_id, taxable_type)
Foreign-key constraints:
    "taxable_taxonomies_taxonomy_id_fk" FOREIGN KEY (taxonomy_id) REFERENCES taxonomies(id)
Access method: heap
~~~


Workaround:

# su - postgres -c "psql foreman"
ALTER TABLE taxable_taxonomies ALTER COLUMN created_at DROP NOT NULL;
ALTER TABLE taxable_taxonomies ALTER COLUMN updated_at DROP NOT NULL;
exit

# foreman-rake db:migrate --trace


If no issues are reported this time, proceed with re-running the upgrade.

Comment 1 Sayan Das 2022-07-19 19:10:43 UTC
I don't know how it can even happen as Sat 6.10 also does not have the bad schema but I would really expect that installer will be able to handle this issue in a much better way.

Comment 9 Lukas Pramuk 2022-08-23 13:14:23 UTC
I was upgrading from 6.11.1.1 to 6.12.0 (due to another BZ 2120632) and didn't hit this bug.

Comment 22 errata-xmlrpc 2022-11-16 13:34:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.12 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:8506

Comment 23 agilmore2 2024-10-08 22:56:05 UTC
This isn't really a "resolved" bug. Still have to manually fix this in the 6.11 upgrade before the "fixed" 6.12 release can be applied.

Comment 24 Adam Ruzicka 2024-10-09 07:50:26 UTC
Hi, thank you for bringing this to our attention. I'm afraid we're not planning on having any updates to the 6.11 line, but this might help those who might be in the same situation.

On a more general note, we moved from Bugzilla to Jira some time ago and Bugzilla is considered to be archived at this point. Comments posted to the linked jira issue ([1] in the case of this BZ) have a better chance of being seen by more people.

[1] - https://issues.redhat.com/browse/SAT-12272


Note You need to log in before you can comment on or make changes to this bug.