Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirroring policy breaks repositories #808

Closed
lhellebr opened this issue Jan 21, 2022 · 1 comment
Closed

Mirroring policy breaks repositories #808

lhellebr opened this issue Jan 21, 2022 · 1 comment

Comments

@lhellebr
Copy link
Contributor

Mirroring policy has been added to the API recently in this PR: https://github.com/Katello/katello/pull/9834/files
It causes some failures in Nailgun, e.g.:

$ pytest tests/foreman/cli/test_computeresource_rhev.py::test_positive_provision_rhev_image_based_and_disassociate
[...]
tests/foreman/cli/test_computeresource_rhev.py::test_positive_provision_rhev_image_based_and_disassociate[destroy_vm_on_host_delete] ERROR [100%]

======================================================== ERRORS =========================================================
________ ERROR at setup of test_positive_provision_rhev_image_based_and_disassociate[destroy_vm_on_host_delete] _________

module_org = nailgun.entities.Organization(compute_resource=[], description=None, domain=[], hostgroup=[], label='apnHArWN', medium... default_content_view=nailgun.entities.ContentView(id=12), library=nailgun.entities.LifecycleEnvironment(id=22), id=23)
module_location = nailgun.entities.Location(compute_resource=[], description=None, domain=[], hostgroup=[], medium=[], name='achGpl', or....ProvisioningTemplate(id=25), nailgun.entities.ProvisioningTemplate(id=64)], smart_proxy=[], subnet=[], user=[], id=24)

    @pytest.fixture(scope='module')
    def provisioning(module_org, module_location):
        provisioning.org_name = module_org.name
        provisioning.loc_name = module_location.name
>       provisioning.config_env = configure_provisioning(
            compute=True, org=module_org, loc=module_location, os=None
        )

tests/foreman/cli/test_computeresource_rhev.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
robottelo/api/utils.py:261: in configure_provisioning
    repo = entities.Repository(
../../broker/venv/lib/python3.8/site-packages/nailgun/entity_mixins.py:948: in create
    return self.read(attrs=self.create_json(create_missing))
../../broker/venv/lib/python3.8/site-packages/nailgun/entities.py:6201: in read
    return super().read(entity, attrs, ignore, params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = nailgun.entities.Repository(product=nailgun.entities.Product(description=None, gpg_key=None, label='fnYDeXa', name='fn.../RHEL-7/latest-RHEL-7.9/compose/Server/x86_64/os/', download_policy='immediate', content_type='yum', name='TaafCOScQE')
entity = nailgun.entities.Repository(ansible_collection_auth_url=None, ansible_collection_auth_token=None, ansible_collection_r...apnHArWN/Library/custom/fnYDeXa/TaafCOScQE/', gpg_key=None, ignorable_content=None, label='TaafCOScQE', last_sync=None)
attrs = {'ansible_collection_auth_token': None, 'ansible_collection_auth_url': None, 'ansible_collection_requirements': None, 'arch': 'noarch', ...}
ignore = {'organization', 'upstream_password'}, params = None

    def read(self, entity=None, attrs=None, ignore=None, params=None):
        """Get information about the current entity.
    
        1. Create a new entity of type ``type(self)``.
        2. Call :meth:`read_json` and capture the response.
        3. Populate the entity with the response.
        4. Return the entity.
    
        Step one is skipped if the ``entity`` argument is specified. Step two
        is skipped if the ``attrs`` argument is specified. Step three is
        modified by the ``ignore`` argument.
    
        All of an entity's one-to-one and one-to-many relationships are
        populated with objects of the correct type. For example, if
        ``SomeEntity.other_entity`` is a one-to-one relationship, this should
        return ``True``::
    
            isinstance(
                SomeEntity(id=N).read().other_entity,
                nailgun.entity_mixins.Entity
            )
    
        Additionally, both of these commands should succeed::
    
            SomeEntity(id=N).read().other_entity.id
            SomeEntity(id=N).read().other_entity.read().other_attr
    
        In the example above, ``other_entity.id`` is the **only** attribute
        with a meaningful value. Calling ``other_entity.read`` populates the
        remaining entity attributes.
    
        :param nailgun.entity_mixins.Entity entity: The object to be populated
            and returned. An object of type ``type(self)`` by default.
        :param attrs: A dict. Data used to populate the object's attributes.
            The response from
            :meth:`nailgun.entity_mixins.EntityReadMixin.read_json` by default.
        :param ignore: A set of attributes which should not be read from the
            server. This is mainly useful for attributes like a password which
            are not returned.
        :return: An instance of type ``type(self)``.
        :rtype: nailgun.entity_mixins.Entity
    
        """
        if entity is None:
            try:
                entity = type(self)(self._server_config)
            except TypeError:
                # in the event that an entity's init is overwritten
                # with a positional server_config
                entity = type(self)()
        if attrs is None:
            attrs = self.read_json(params=params)
        if ignore is None:
            ignore = set()
    
        for field_name, field in entity.get_fields().items():
            if field_name in self.ignore_fields and field.entity.__name__ in self.ignore_entities:
                continue
            if field_name in ignore:
                continue
            if isinstance(field, OneToOneField):
                entity_id = _get_entity_id(field_name, attrs)
                if entity_id is None:
                    referenced_entity = None
                else:
                    referenced_entity = field.entity(
                        self._server_config,
                        id=entity_id,
                    )
                setattr(entity, field_name, referenced_entity)
            elif isinstance(field, OneToManyField):
                referenced_entities = [
                    field.entity(self._server_config, id=entity_id)
                    for entity_id in _get_entity_ids(field_name, attrs)
                ]
                setattr(entity, field_name, referenced_entities)
            else:
>               setattr(entity, field_name, attrs[field_name])
E               KeyError: 'mirror_on_sync'

../../broker/venv/lib/python3.8/site-packages/nailgun/entity_mixins.py:811: KeyError
[...]
@lhellebr
Copy link
Contributor Author

#809

omkarkhatavkar pushed a commit that referenced this issue Jan 28, 2022
* Ignore mirror_on_sync

Parameter mirror_on_sync has been added to API
in Katello PR 9834.
This is not returned as part of JSON on entity creation.
Consequently, read() fails.
It could be workarounded by ignoring errors when reading
non-required parameters. Also, this would be fixed if
Satellite started returning that value.
This solves the issue without unnecessary changes
in Nailgun's guts that might break something.

* Update test
jyejare pushed a commit to jyejare/nailgun that referenced this issue Feb 24, 2022
* Ignore mirror_on_sync

Parameter mirror_on_sync has been added to API
in Katello PR 9834.
This is not returned as part of JSON on entity creation.
Consequently, read() fails.
It could be workarounded by ignoring errors when reading
non-required parameters. Also, this would be fixed if
Satellite started returning that value.
This solves the issue without unnecessary changes
in Nailgun's guts that might break something.

* Update test
mshriver pushed a commit that referenced this issue Feb 24, 2022
* Ignore mirror_on_sync

Parameter mirror_on_sync has been added to API
in Katello PR 9834.
This is not returned as part of JSON on entity creation.
Consequently, read() fails.
It could be workarounded by ignoring errors when reading
non-required parameters. Also, this would be fixed if
Satellite started returning that value.
This solves the issue without unnecessary changes
in Nailgun's guts that might break something.

* Update test
@lhellebr lhellebr closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant