Bug 2154734

Summary: Getting 'null value in column \"image_manifest_id\" violates not-null constraint' when syncing openstack container repos
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: sganar
Severity: medium Docs Contact:
Priority: medium    
Version: 6.10.7CC: ahumbe, aperotti, arahaman, ashipati, bbuckingham, dalley, dkliban, ggainey, ipanova, jalviso, juwatts, pcreech, rchan, satellite6-bugs, saydas
Target Milestone: 6.13.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pulp-container-2.10.11 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2174984 (view as bug list) Environment:
Last Closed: 2023-05-03 13:23:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hao Chang Yu 2022-12-19 03:02:34 UTC
Description of problem:
Capsules failed to sync the openstack container repositories with the following error:
----------------------------------
  error:
    traceback: |2
        File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 342, in _perform_task
          result = func(*args, **kwargs)
        File "/usr/lib/python3.6/site-packages/pulp_container/app/tasks/synchronize.py", line 44, in synchronize
          return dv.create()
        File "/usr/lib/python3.6/site-packages/pulpcore/plugin/stages/declarative_version.py", line 151, in create
          loop.run_until_complete(pipeline)
        File "/usr/lib64/python3.6/asyncio/base_events.py", line 484, in run_until_complete
          return future.result()
        File "/usr/lib/python3.6/site-packages/pulpcore/plugin/stages/api.py", line 225, in create_pipeline
          await asyncio.gather(*futures)
        File "/usr/lib/python3.6/site-packages/pulpcore/plugin/stages/api.py", line 43, in __call__
          await self.run()
        File "/usr/lib/python3.6/site-packages/pulp_container/app/tasks/sync_stages.py", line 457, in run
          objs=manifest_to_list_list, ignore_conflicts=True, batch_size=1000
        File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
          return getattr(self.get_queryset(), name)(*args, **kwargs)
        File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 474, in bulk_create
          ids = self._batched_insert(objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts)
        File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 1211, in _batched_insert
          self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
        File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert
          return query.get_compiler(using=using).execute_sql(return_id)
        File "/usr/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1377, in execute_sql
          cursor.execute(sql, params)
        File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
          return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
        File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
          return executor(sql, params, many, context)
        File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
          return self.cursor.execute(sql, params)
        File "/usr/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
          raise dj_exc_value.with_traceback(traceback) from exc_value
        File "/usr/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
          return self.cursor.execute(sql, params)
    description: |
      null value in column "image_manifest_id" violates not-null constraint
      DETAIL:  Failing row contains (105527, amd64, linux, , , , , null, d55659df-811f-452e-a9a1-cc07205daa9b).
  worker: "/pulp/api/v3/workers/275806b5-c56b-42e8-b170-09bce2b290e9/"
-----------------------------------


This issue seems to be related to bug #2026277 but on different table and column.

Capsules failed to sync the following but not limited to the below RHOSP repositories.
------------------------
openstack-cinder-api
openstack-neutron-server
openstack-neutron-dhcp-agent
openstack-neutron-server
------------------------


Below are the installed Pulp rpms for Satellite 6.10.7.
---------------------
libmodulemd-1.7.0-1.pulp.el7sat.x86_64
pulpcore-selinux-1.2.7-1.el7pc.x86_64
python3-pulpcore-3.14.16-1.el7pc.noarch
python3-pulp-ansible-0.9.0-1.el7pc.noarch
python3-pulp-certguard-1.4.0-1.el7pc.noarch
python3-pulp-container-2.8.4-0.1.el7pc.noarch
python3-pulp-file-1.8.2-1.el7pc.noarch
python3-pulp-rpm-3.14.14-1.el7pc.noarch
tfm-rubygem-smart_proxy_pulp-3.0.0-1.el7sat.noarch
-----------------------


Additional Info:

Looking at the hotfix PR (https://github.com/pulp/pulp_container/pull/568). It seems like we also need a "await list_dc.resolution()"
after line 121 (https://github.com/pulp/pulp_container/pull/535/files#diff-b702cbd3ebdff19bf8e4dfc14688aa3fb36e1a47ef6cf84d24e0f75b61247d36R121)
to make sure "list_dc" is resolved before man_dc.

sync_stages.py has been refactored in upstream Pulp "https://github.com/pulp/pulp_container/pull/608" which might fix the issue but it is not even included in 6.12 yet.

Comment 1 Daniel Alley 2022-12-19 23:52:30 UTC
i

Comment 2 Ina Panova 2022-12-22 16:57:55 UTC
This is a one liner fix https://github.com/pulp/pulp_container/issues/1190

Please specify pulp-container versions this fix needs to be included.

Comment 16 sganar 2023-03-03 13:37:06 UTC
Verified.

Tested on Satellite 6.13.0 Snap 12.0
python39-pulp-container-2.14.0-2.el8pc.noarch

Steps followed: 
1. Create a custom product.
2. Add some OSP repos and sync them and check sync status (I added openstack-cinder-api, openstack-neutron-server,openstack-neutron-dhcp-agent, openstack-nova-api)
3. Configure a capsule and trigger optimized sync.

Observation: 
The Synchronisation is successful and no issues are found.

Comment 19 errata-xmlrpc 2023-05-03 13:23:43 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.13 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-2023:2097

Comment 20 Red Hat Bugzilla 2023-11-29 04:25:05 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days