Skip to content

[content_upload] Error while performing update on content_uploads #1862

@EmptyByte

Description

@EmptyByte
SUMMARY

Unable to upload RPMs using the redhat.satellite.content_upload module. The module is able to upload some very small RPMs (19KB ~ 85 KB) but anything larger fails.

Ansible error:

The full traceback is:
  File "/tmp/ansible_redhat.satellite.content_upload_payload_h_ur6pg4/ansible_redhat.satellite.content_upload_payload.zip/ansible_collections/redhat/satellite/plugins/module_utils/foreman_helper.py", line 1165, in resource_action
    result = self.foremanapi.resource_action(resource, action, params, options, data, files, ignore_task_errors)
  File "/tmp/ansible_redhat.satellite.content_upload_payload_h_ur6pg4/ansible_redhat.satellite.content_upload_payload.zip/ansible_collections/redhat/satellite/plugins/module_utils/_apypie.py", line 719, in resource_action
    raise ForemanApiException.from_exception(exc, msg) from exc
failed: [localhost] (item=product: Custom - repository: Custom RHEL9 - RPM: randomrpm.x86_64.rpm) => changed=false
  ansible_loop_var: item
  invocation:
    module_args:
      ca_path: null
      organization: XXX
      ostree_repository_name: null
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      product: Custom
      repository: Custom RHEL9
      server_url: https://XXXXXXX
      src: /root/redhat_satellite-master/files/custom_packages/rhel9/randomrpm.x86_64.rpm
      use_gssapi: false
      username: XXX
      validate_certs: true
  item:
    product: Custom
    repository: Custom RHEL9
    rpm: /root/redhat_satellite-master/files/custom_packages/rhel9/randomrpm.x86_64.rpm
  msg: 'Error while performing update on content_uploads: Error while performing update on content_uploads: 400 Client Error: Bad Request for url: https://XXX/katello/api/repositories/3/content_uploads/0196ddcc-d806-7ff9-a481-54cbc1c9a14b - Bad Request'

In production.log:

2025-05-17T12:31:50 [I|app|5e6eb05b] Processing by Katello::Api::V2::PackagesController#index as JSON
2025-05-17T12:31:50 [I|app|5e6eb05b]   Parameters: {"repository_id"=>"3", "search"=>"name = \"temurin-21-jdk\" and epoch = \"0\" and version = \"21.x.x.x.x\" and release = \"2\" and
arch = \"x86_64\"", "per_page"=>"4294967296", "api_version"=>"v2"}
2025-05-17T12:31:50 [I|app|5e6eb05b]   Rendered /usr/share/gems/gems/katello-4.16.0.2/app/views/katello/api/v2/packages/index.json.rabl within katello/api/v2/layouts/collection (Duratio
n: 1.1ms | Allocations: 666)
2025-05-17T12:31:50 [I|app|5e6eb05b]   Rendered layout /usr/share/gems/gems/katello-4.16.0.2/app/views/katello/api/v2/layouts/collection.json.erb (Duration: 1.3ms | Allocations: 758)
2025-05-17T12:31:50 [I|app|5e6eb05b] Completed 200 OK in 17ms (Views: 1.7ms | ActiveRecord: 4.6ms | Allocations: 6059)
2025-05-17T12:31:50 [I|app|103c08e9] Started POST "/katello/api/repositories/3/content_uploads" for x.x.x.x  at 2025-05-17 12:31:50 +0200
2025-05-17T12:31:50 [I|app|103c08e9] Processing by Katello::Api::V2::ContentUploadsController#create as JSON
2025-05-17T12:31:50 [I|app|103c08e9]   Parameters: {"size"=>174408213, "api_version"=>"v2", "repository_id"=>"3", "content_upload"=>{"size"=>174408213}}
2025-05-17T12:31:50 [I|app|103c08e9] Completed 200 OK in 141ms (Views: 0.2ms | ActiveRecord: 2.4ms | Allocations: 38764)
2025-05-17T12:31:50 [I|app|336db347] Started PUT "/katello/api/repositories/3/content_uploads/0196ddcc-d368-7a37-9eba-52603361793d" for x.x.x.x at 2025-05-17 12:31:50 +0200
2025-05-17T12:31:50 [F|app|336db347]
 336db347 | ActionController::BadRequest (Invalid request parameters: total query size (5141526) exceeds limit (4194304)):
 336db347 |
 336db347 | app/controllers/concerns/foreman/controller/filter_parameters.rb:15:in `process_action'
 336db347 | katello (4.16.0.2) lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 336db347 | katello (4.16.0.2) lib/katello/middleware/event_daemon.rb:10:in `call'
 336db347 | lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 336db347 | lib/foreman/middleware/telemetry.rb:10:in `call'
 336db347 | lib/foreman/middleware/logging_context_session.rb:22:in `call'
 336db347 | lib/foreman/middleware/logging_context_request.rb:11:in `call'
 336db347 | katello (4.16.0.2) lib/katello/prevent_json_parsing.rb:12:in `call'
ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
# ansible --version
ansible [core 2.16.14]
  config file = /root/redhat_satellite-master/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /root/redhat_satellite-master/collections
  executable location = /bin/ansible
  python version = 3.12.9 (main, Feb  4 2025, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-4)] (/usr/bin/python3.12)
  jinja version = 3.1.5
  libyaml = True
COLLECTION VERSION
# ansible-galaxy collection list

# /root/redhat_satellite-master/collections/ansible_collections
Collection        Version
----------------- -------
ansible.posix     1.6.1
community.general 9.5.7
redhat.satellite  5.3.0
KATELLO/FOREMAN VERSION
# rpm -q rubygem-katello foreman ruby
rubygem-katello-4.16.0.2-1.el9sat.noarch
foreman-3.14.0.2-1.el9sat.noarch
ruby-3.0.7-165.el9_5.x86_64
# foreman-rake about
About your application's environment
Rails version             7.0.8.7
Ruby version              ruby 3.0.7p220 (2024-04-23 revision 724a071175) [x86_64-linux]
RubyGems version          3.2.33
Rack version              2.2.14
Middleware                SecureHeaders::Middleware, ActionDispatch::HostAuthorization, ActionDispatch::SSL, Rack::Sendfile, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, Katello::PreventJsonParsing, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Foreman::Middleware::LoggingContextRequest, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::Callbacks, ActionDispatch::Cookies, ActionDispatch::Session::ActiveRecordStore, Foreman::Middleware::LoggingContextSession, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, ActionDispatch::PermissionsPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, Apipie::Middleware::ChecksumInHeaders, Foreman::Middleware::Telemetry, Foreman::Middleware::LibvirtConnectionCleaner, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, ActionDispatch::Static, Apipie::StaticDispatcher, ApipieDSL::StaticDispatcher, ActionDispatch::Static, ActionDispatch::Static, Katello::Middleware::EventDaemon, Katello::Middleware::OrganizationCreatedEnforcer
Application root          /usr/share/foreman
Environment               production
Database adapter          postgresql
Database schema version   20250309121956
STEPS TO REPRODUCE
        - name: Upload RPMs into Custom repositories
          redhat.satellite.content_upload:
            server_url: "{{ satellite_server_url | d(omit) }}"
            validate_certs: "{{ satellite_validate_certs | d(omit) }}"
            username: "{{ satellite_admin_username | d(omit) }}"
            password: "{{ satellite_admin_password | d(omit) }}"
            organization: "{{ satellite_organization }}"
            product: "{{ item.product }}"
            repository: "{{ item.repository }}"
            src: "{{ item.rpm }}"
          loop: "{{ rpm_uploads }}"
          loop_control:
            label: >-
              product: {{ item.product }} -
              repository: {{ item.repository }} -
              RPM: {{ item.rpm | basename }}
EXPECTED RESULTS

Be able to upload RPM using the content_upload module.

Workaround -- I am able to upload all RPMs if I update the CONTENT_CHUNK_SIZE in:
./collections/ansible_collections/redhat/satellite/plugins/modules/content_upload.py

Change this:

CONTENT_CHUNK_SIZE = 2 * 1024 * 1024

to this:

CONTENT_CHUNK_SIZE = 1 * 1024 * 1024

Likely rejected by rails because it goes above the 4MiB limit. Reducing to 1MiB chunk fixed it.

ACTUAL RESULTS

Refer to SUMMARY.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions