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

Add support for debian repository creation #1203

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

dosas
Copy link
Collaborator

@dosas dosas commented Jul 2, 2024

Description of changes

Add support for debian repository creation

Functional demonstration

All tests are green

Additional Information

I'm not sure if there should be explicit tests for debian repo creation?

@dosas dosas added CherryPick PR needs CherryPick to previous branches 6.13.z 6.14.z 6.15.z labels Jul 2, 2024
@omkarkhatavkar
Copy link
Contributor

Can one of the admins verify this patch?

nailgun/entities.py Outdated Show resolved Hide resolved
@dosas dosas force-pushed the add-support-for-debian-repos branch from 3f99bfe to 7490f03 Compare July 3, 2024 08:13
@dosas dosas force-pushed the add-support-for-debian-repos branch from 7490f03 to f605750 Compare July 10, 2024 12:23
@dosas dosas marked this pull request as draft July 17, 2024 13:58
@dosas dosas marked this pull request as ready for review July 18, 2024 09:12
@dosas dosas marked this pull request as draft July 18, 2024 09:13
@dosas dosas marked this pull request as ready for review July 18, 2024 09:14
@dosas
Copy link
Collaborator Author

dosas commented Jul 29, 2024

@omkarkhatavkar Should I ping someone for review?

nailgun/entities.py Outdated Show resolved Hide resolved
Copy link
Member

@ogajduse ogajduse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting situation here. I checked out your code and tried to create a repository.

[ins] In [1]: from robottelo.hosts import ContentHost, Satellite, Capsule, IPAHost

[ins] In [2]: sat = Satellite.get_host_by_hostname('mysatellite.acme.com')

[ins] In [8]: org = sat.api.Organization(id=1).read()

[ins] In [12]: product = sat.api.Product(organization=org).create()

[ins] In [13]: sat.api.Repository(product=product).create()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[13], line 1
----> 1 sat.api.Repository(product=product).create()

File ~/repos/nailgun/nailgun/entity_mixins.py:987, in EntityCreateMixin.create(self, create_missing)
    961 def create(self, create_missing=None):
    962     """Create an entity.
    963 
    964     Call :meth:`create_json`, use the response to populate a new object
   (...)
    985 
    986     """
--> 987     return self.read(attrs=self.create_json(create_missing))

File ~/repos/nailgun/nailgun/entities.py:6948, in Repository.read(self, entity, attrs, ignore, params)
   6946 ignore.add('upstream_password')
   6947 ignore.add('mirror_on_sync')
-> 6948 return super().read(entity, attrs, ignore, params)

File ~/repos/nailgun/nailgun/entity_mixins.py:846, in EntityReadMixin.read(self, entity, attrs, ignore, params)
    844         setattr(entity, field_name, referenced_entities)
    845     else:
--> 846         setattr(entity, field_name, attrs[field_name])
    847 return entity

KeyError: 'deb_errata_url'

The above happens when you run nailgun with your patch against a Satellite/Foreman instance that does not have the patch you referenced applied. The fix here is to add deb_errata_url to ignore as follows:

diff --git a/nailgun/entities.py b/nailgun/entities.py
index e20055a..ae2d070 100644
--- a/nailgun/entities.py
+++ b/nailgun/entities.py
@@ -6942,6 +6942,9 @@ class Repository(
         """
         if ignore is None:
             ignore = set()
+        if 'deb_errata_url' not in attrs:
+            ignore.add('deb_errata_url')
+
         ignore.add('organization')
         ignore.add('upstream_password')
         ignore.add('mirror_on_sync')

Although it is not nice, I believe that this is the only way around it with the current nailgun structure/design.

@ogajduse
Copy link
Member

ogajduse commented Aug 1, 2024

I believe that we should remove all labels that are currently set on this PR and use NoCherryPick as this looks like something that will not be backported to any of the released versions. Can you please confirm, @dosas?
However, if we add that ignore as I suggested and it does not break on the older versions, I do not see a problem in merging it to the other .z branches.

@ogajduse
Copy link
Member

ogajduse commented Aug 1, 2024

Adding @SatelliteQE/team-phoenix since the patch is related to Repositories component of the product.

@ogajduse ogajduse requested a review from a team August 1, 2024 14:25
@dosas
Copy link
Collaborator Author

dosas commented Aug 5, 2024

@ogajduse Thanks for the review. That is a good catch, I did not consider that. I will remove the deb_errata_url until the above mentioned PR is merged.

@dosas dosas force-pushed the add-support-for-debian-repos branch from f605750 to 5f83b55 Compare August 5, 2024 06:30
@dosas dosas requested a review from ogajduse August 5, 2024 06:31
@ogajduse
Copy link
Member

ogajduse commented Aug 7, 2024

I believe that we should remove all labels that are currently set on this PR and use NoCherryPick as this looks like something that will not be backported to any of the released versions. Can you please confirm, @dosas? However, if we add that ignore as I suggested and it does not break on the older versions, I do not see a problem in merging it to the other .z branches.

@dosas Can you please comment on this one?

@dosas
Copy link
Collaborator Author

dosas commented Aug 7, 2024

I believe that we should remove all labels that are currently set on this PR and use NoCherryPick as this looks like something that will not be backported to any of the released versions. Can you please confirm, @dosas? However, if we add that ignore as I suggested and it does not break on the older versions, I do not see a problem in merging it to the other .z branches.

@dosas Can you please comment on this one?

Since I'm using 6.15.z downstream I would like to backport it to this branch but the other labels can be removed.

@ogajduse ogajduse merged commit fb1370d into SatelliteQE:master Aug 16, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.15.z CherryPick PR needs CherryPick to previous branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants