Issue #9008
closedPulpcoreClient::ExportersPulpExportsApi list results in uninitialized constant PulpcoreClient::AnyType error
Description
There seems to be an issue with the Ruby bindings for listing exports. The error only occurs if you have exports in the Pulpcore DB.
Backtrace from Katello:
19:53:18 rails.1 | 2021-07-02T19:53:18 [E|bac|717773dd] uninitialized constant PulpcoreClient::AnyType (NameError) 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:220:in `const_get' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:220:in `_deserialize' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:173:in `block (2 levels) in build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:173:in `map' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:173:in `block in build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:168:in `each_pair' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:168:in `build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/pulp_export_response.rb:160:in `build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:187:in `_deserialize' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:140:in `block (2 levels) in build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:140:in `map' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:140:in `block in build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:135:in `each_pair' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:135:in `build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/models/paginated_pulp_export_response_list.rb:127:in `build_from_hash' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/api_client.rb:258:in `convert_to_type' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/api_client.rb:219:in `deserialize' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/api_client.rb:94:in `call_api' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/api/exporters_pulp_exports_api.rb:222:in `list_with_http_info' 19:53:18 rails.1 | 717773dd | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/pulpcore_client-3.14.0/lib/pulpcore_client/api/exporters_pulp_exports_api.rb:163:in `list' 19:53:18 rails.1 | 717773dd | /home/vagrant/katello/app/services/katello/pulp3/content_view_version/export.rb:84:in `fetch_export'
Related versions:
pulpcore_client 3.14.0 ... pulp-2to3-migration (0.12.0) pulp-ansible (0.8.0) pulp-certguard (1.4.0) pulp-container (2.7.0) pulp-deb (2.13.0) pulp-file (1.8.1) pulp-python (3.4.0) pulp-rpm (3.13.2) pulpcore (3.14.0)
Related issues
Updated by dkliban@redhat.com over 3 years ago
This regression in the bindings seems to have been introduced when we switched from using openapi-generator-cli v4.2.3 to v4.3.1.
https://github.com/pulp/pulp-openapi-generator/pull/48
The following ruby script reproduced the issue for me:
require 'pulpcore_client'
require 'pulp_file_client'
require 'tempfile'
require 'digest'
PulpcoreClient.configure do |config|
config.host= "http://localhost:24817"
config.username= 'admin'
config.password= 'password'
config.debugging=true
end
PulpFileClient.configure do |config|
config.host= "http://localhost:24817"
config.username= 'admin'
config.password= 'password'
config.debugging=true
end
@exporters_api = PulpcoreClient::ExportersPulpApi.new
@exports_api = PulpcoreClient::ExportersPulpExportsApi.new
@filerepositories_api = PulpFileClient::RepositoriesFileApi.new
@repoversions_api = PulpFileClient::RepositoriesFileVersionsApi.new
@fileremotes_api = PulpFileClient::RemotesFileApi.new
@tasks_api = PulpcoreClient::TasksApi.new
def monitor_task(task_href)
# Polls the Task API until the task is in a completed state.
#
# Prints the task details and a success or failure message. Exits on failure.
#
# Args:
# task_href(str): The href of the task to monitor
#
# Returns:
# list[str]: List of hrefs that identify resource created by the task
completed = []
task = @tasks_api.read(task_href)
until ["completed", "failed", "canceled"].include? task.state
sleep(2)
task = @tasks_api.read(task_href)
end
if task.state == 'completed'
task.created_resources
else
print("Task failed. Exiting.\n")
exit(2)
end
end
def content_range(start, finish, total)
finish = finish > total ? total : finish
"bytes #{start}-#{finish}/#{total}"
end
# Create a File Remote
remote_url = 'https://fixtures.pulpproject.org/file/PULP_MANIFEST'
remote_data = PulpFileClient::FileFileRemote.new({name: 'bar33', url: remote_url})
file_remote = @fileremotes_api.create(remote_data)
# Create a Repository
repository_data = PulpFileClient::FileFileRepository.new({name: 'foo33'})
file_repository = @filerepositories_api.create(repository_data)
# Sync a Repository
repository_sync_data = PulpFileClient::RepositorySyncURL.new({remote: file_remote.pulp_href})
sync_response = @filerepositories_api.sync(file_repository.pulp_href, repository_sync_data)
# Monitor the sync task
created_resources = monitor_task(sync_response.task)
repository_version_1 = @repoversions_api.read(created_resources[0])
# Create an exporter
exporter = @exporters_api.create({name: 'foo7', path: '/tmp/foo', repositories:[file_repository.pulp_href]})
# Create an export
export_response = @exports_api.create(exporter.pulp_href, versions: [repository_version_1.pulp_href])
created_resources = monitor_task(export_response.task)
# List exports
exports = @exports_api.list(exporter.pulp_href)
Updated by dkliban@redhat.com over 3 years ago
I used git bisect to find the commit in openapi-generator which changed the behavior[0]. This commit was introduced in v4.3.1.
We have options for resolving this issue:
-
Use openapi-generator v4.3.0 to generate ruby clients
-
Try to figure out how to fix the ruby templates to support this change (and contribute the change upstream)
-
Change the OpenAPI schema for exports to not use AnyType.
[0] https://github.com/OpenAPITools/openapi-generator/commit/3bbaedd9bc086028e7b1be973a30e04870962e5d
Updated by dkliban@redhat.com over 3 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to dkliban@redhat.com
Updated by dkliban@redhat.com over 3 years ago
I decided that option 3 was the most correct. https://github.com/pulp/pulpcore/pull/1461
Updated by pulpbot over 3 years ago
- Status changed from ASSIGNED to POST
Updated by iballou over 3 years ago
- Copied to Backport #9025: Backport fix for 9008 to 3.14.z -- PulpcoreClient::ExportersPulpExportsApi list results in uninitialized constant PulpcoreClient::AnyType error added
Added by dkliban@redhat.com over 3 years ago
Updated by dkliban@redhat.com over 3 years ago
- Status changed from POST to MODIFIED
Applied in changeset pulpcore|f52ba80e41ebbb532a87b6aa50821911a01348ff.
Updated by dalley over 3 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
released in 3.14.1
Removes ambiguity from OpenAPI schema for Exports.
This patch clearly defines the exported_resources as a list of URI strings. The implementation for the ExportedResourceSerializer is shared with CreatedResource serializer. They now both inherit from a new RelatedResourceField.
fixes: #9008 https://pulp.plan.io/issues/9008