-
Notifications
You must be signed in to change notification settings - Fork 297
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
Fixes #13485 - API: Allow user to set sync type per repository #5749
Conversation
@@ -84,6 +84,8 @@ class Repository < Katello::Model | |||
:allow_blank => false, | |||
:message => ->(_, _) { _("must be one of the following: %s") % Katello::RepositoryTypeManager.repository_types.keys.join(', ') } | |||
} | |||
validates :download_policy, inclusion: { in: ::Runcible::Models::Importer::DOWNLOAD_POLICIES }, if: :yum? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be
NameError: uninitialized constant Runcible::Models::YumImporter::DOWNLOAD_POLICIES
I presume tests are getting added.. |
@parthaa - yes I have a p-r opened against his branch that will add tests and show download_policy for yum repos only. |
@@ -0,0 +1,5 @@ | |||
class AddDownloadPolicyToKatelloRepositories < ActiveRecord::Migration | |||
def change | |||
add_column :katello_repositories, :download_policy, :string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to set a default in the migraiton?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlsherrill Probably not if only valid for yum repos, right?
class AddDownloadPolicyToKatelloRepositories < ActiveRecord::Migration | ||
def change | ||
add_column :katello_repositories, :download_policy, :string | ||
update "UPDATE katello_repositories SET download_policy = 'on_demand' WHERE content_type = 'yum'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be done through the ORM? We recently had a similar discussion around this on #5709 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the advantage here of using ORM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Prevent database specific sequel from being used and letting the ORM handle things properly for us
- That's how we tend to do things everywhere else unless they can't be accomplished through the ORM
@@ -6,6 +6,9 @@ extends 'katello/api/v2/common/timestamps' | |||
attributes :content_type | |||
attributes :docker_upstream_name | |||
attributes :unprotected, :full_path, :checksum_type, :container_repository_name | |||
if (@object && @object.yum?) || (@resource.is_a?(Katello::Repository) && @resource.yum?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehelms @cfouant had to fix this as @resource
could be defined as something other than Repository (e.g. ContentViewFilter). Also, @object
isn't defined when the controller renders this directly. Are you cool with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer we just show download policy on all repos. @ehelms your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine.
I'd ACK this except I wrote a bunch of it myself. I have tested it a bunch and seems to work for me 👍 |
Looks like this is going to need a rebase after the cassette regeneration. |
end | ||
def change | ||
add_column :katello_repositories, :download_policy, :string | ||
DownloadPolicyRepository.where(content_type: 'yum').update_all(download_policy: 'immediate') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need an upgrade task to change all existing repositories in Pulp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Pulp defaults to immediate.
I tried to create a repository and ran into:
|
Waiting on #5754 |
I am a bit confused -- if I need all of these PRs for repository creation to work, shouldn't they be combined together? |
The scope of this PR is to get the API working. If we want everything to work (API, UI, etc) it seems like we might as well just create a feature branch? |
I don't think we need a feature branch, and best to avoid those where possible. This is how I look at it, if a single PR goes in and breaks basic functionality that's bad. Further, if I need to cherry pick I might end up in a broken state. So I am all in favor of adding in lazy sync changes but where it keeps the lights on. |
It sounds easy in theory but having to address comments across a list of commits is a huge pain. If we get feedback or we need to change something, we either end up with new commits or we have to somehow rebase it into the old commit. Dealing with one or two commits per PR is much easier. Plus we're also dealing with being dependent on the nodes work which we could just merge into our branch even if it's not done. I agree with your idea in theory but in practice it's not as easy. |
Let me backup, as you are right I should look at this from the API perspective. Which, fails with the same error as the UI. You argue I need to include |
Ok I'll add it in. You will need to test from the API unless you check out this commit locally: |
unprotected = unprotected.nil? ? false : unprotected | ||
download_policy = Setting[:default_download_policy] if download_policy.blank? && yum? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
in this context is a product not a repository thus yum?
fails here with no method error. I think you'll need to check the repo_type
parameter passed in.
ACK |
LOL this is your own PR.... however ACK |
Fixes #13485 - API: Allow user to set sync type per repository
Requires Katello/runcible#165