There's a possible issue related to importing Ansible roles (and creating new versions/releases) through travis-ci.org using the Notifications API
I'm not entirely certain about how to reproduce this. I suppose you could try to create a new tag on an existing role and see if this imports correctly when notifying Galaxy from Travis CI. In any case, here's the relevant information in this case.
This is the notification received by Ansible Galaxy after this Travis build passed.
The notification should have triggered an import, which would have created the 2.4.3 release.
Nothing happened. 2.4.2 remains the latest release.
See versions in https://galaxy.ansible.com/geerlingguy/homebrew
Looks like it started the import, but there was an error. Here's a link to the import log:
Not sure why it got a duplicate key error though. Investigating...
Here's the traceback:
2018-07-01 00:59:57,226 ERROR tasks: duplicate key value violates unique constraint "main_content_namespace_id_repository__d7de6a83_uniq"
--
聽 | DETAIL: Key (namespace_id, repository_id, name, content_type_id)=(1609, 34981, docker, 11) already exists.
聽 | Traceback (most recent call last):
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/galaxy/worker/tasks.py", line 59, in import_repository
聽 | _import_repository(import_task, logger)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
聽 | return func(*args, **kwargs)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/galaxy/worker/tasks.py", line 128, in _import_repository
聽 | content_obj = importer.do_import()
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/galaxy/worker/importers/base.py", line 38, in do_import
聽 | content = self.make_content()
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/galaxy/worker/importers/base.py", line 75, in make_content
聽 | 'is_valid': False,
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
聽 | return getattr(self.get_queryset(), name)(*args, **kwargs)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/query.py", line 466, in get_or_create
聽 | return self._create_object_from_params(lookup, params)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/query.py", line 506, in _create_object_from_params
聽 | six.reraise(*exc_info)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/query.py", line 498, in _create_object_from_params
聽 | obj = self.create(**params)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/query.py", line 394, in create
聽 | obj.save(force_insert=True, using=self.db)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/base.py", line 808, in save
聽 | force_update=force_update, update_fields=update_fields)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/base.py", line 838, in save_base
聽 | updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/base.py", line 924, in _save_table
聽 | result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/base.py", line 963, in _do_insert
聽 | using=using, raw=raw)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method
聽 | return getattr(self.get_queryset(), name)(*args, **kwargs)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/query.py", line 1076, in _insert
聽 | return query.get_compiler(using=using).execute_sql(return_id)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1112, in execute_sql
聽 | cursor.execute(sql, params)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
聽 | return self.cursor.execute(sql, params)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
聽 | six.reraise(dj_exc_type, dj_exc_value, traceback)
聽 | File "/var/lib/galaxy/venv/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
聽 | return self.cursor.execute(sql, params)
聽 | IntegrityError: duplicate key value violates unique constraint "main_content_namespace_id_repository__d7de6a83_uniq"
聽 | DETAIL: Key (namespace_id, repository_id, name, content_type_id)=(1609, 34981, docker, 11) already exists.
Somehow I think we're creating new content records, and the new content record of course has '-' converted to '_'.
The unique key on Content is: 'namespace', 'repository', 'name', 'content_type'
During import, in galaxy/worker/importers/base, the get_or_create() is:
obj, is_created = models.Content.objects.get_or_create(
namespace=ns,
repository=repo,
content_type=models.ContentType.get(self.data.content_type),
original_name=original_name,
defaults={
'name': self.translate_content_name(name),
'is_valid': False,
}
Was able to reproduce this in local development.
In the case of geerlingguy.homebrew, a content row already exists where the name is 'homebrew', and the original_name is 'homebrew'. During import the original_name being searched for is 'ansible-role-homebrew'.
I think in the above, we need to put name in the search, and move original_name to 'defaults'.
@chouseknecht Thanks for the quick response!
Fixed deployed to https://galaxy-qa.ansible.com - our public QA site. An import in QA should work now, and it should not change '-' to '_'.
The patch will be deployed to production tomorrow morning, btw.
@chouseknecht will this be a retroactive fix as well (i.e. will travis_lxc get renamed back to travis-lxc?)?
@lae travis_lxc is fixed.
Thanks!
Closing this issue, as the duplicate key error is fixed, and Travis builds are working. We're still working on NOT renaming existing repo names. See issue #775
@chouseknecht What linter is used for roles during the import ? How can I check role locally before releasing ?
Why galaxy UI does not provide easy way for authors to spot roles with problems in import (especially one via travis hook) ?
Most helpful comment
The patch will be deployed to production tomorrow morning, btw.