-
Notifications
You must be signed in to change notification settings - Fork 2.2k
(#9293) Yumrepos should be ensurable #1236
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
Conversation
This change adds a provider to yumrepo that makes it ensurable. So far we needed todo a workaround making each of the individual files that yumrepo creates ensurable, now yumrepo itself does it
This should only go onto master, not onto 2.7.x since it is a new feature. It seems like if a provider is going to be created for yumrepo, there should be some refactoring to move the provider portions of the type into the provider, otherwise we'll end up with another convoluted type/provider arrangement. |
Luke did some work to split the yumrepo type and provider in #8758, but apparently the patch isn't in a working state today. |
…rt for reposdir and fixed bugs
Take a look at the newest changes. In short, it checks reposdir in yum.conf, it looks for a repo in other files aside from its usual location. (i.e repo "epel" might not be in reposdir/epel.repo). It doesn't create a new yumrepo if the properties are different but the repo is there, as stschulte said ("exists? should return true even though enable, baseurl or other properties might not be correct") but honestly this sounds broken to me, if I update my puppet manifests with new information on my yumrepos, wouldn't I always expect them to be updated, regardless if they were there before or not? Is there any easy way we can move the PR to master or should I do it again? |
Thank you for contributing to Puppet!
There isn't unfortunately. A new pull request needs to be submitted, but I notice this pull request is already referring to puppetlabs:master, so you should be good to go already. If you'd like to squash the two commits together, then I'll leave the remaining questions for the other people participating on this pull request; @stschulte and @domcleal have this well in hand. The only comment i have is my boilerplate textexpander comment about tests: Code - missing examplesBefore we merge this into Puppet examples that exercise this change in behavior need to be included in the patch. If you're not comfortable adding RSpec examples, I'm happy to help out. I'm jmccune in #puppet-dev on freenode. Please include examples that will automatically let us know if this problem resurfaces in the future, otherwise we may have a regression as we continue to make changes over time. |
Oh I'm happy about it, in fact I was even feeling bad about not including any specs, I just didn't include any as it looked like I didn't fully grasp the behavior you guys intended to get with this feature! Thanks for the reminder |
Quick question for a sample case: If we have a repository that has already been defined somewhere on reposdir, but we have a new attribute, for instance baseurl we want to modify, should "exists?" really return true just because the repository is in there? If ensurable is really meant to not overwrite the repo even if the configuration is not up-to-date, how should I do this? https://projects.puppetlabs.com/issues/9293 |
That is exactly true because as you said - the repository does exist. The method "baseurl" would have to return :absent in your case so puppet would be like "is the ensure property in sync? Let's check You actually have to define a getter and a setter method for each resourceproperty |
I think mk_resource_methods creates getters and setters automatically. Anyway I noticed that puppet automatically writes back the missing properties using transaction/resource_harness.rb (lines around 40). Is there anything missing other than the specs then? Lines 8 to 30 on type/yumrepo.rb handle when a property is in sync or not, I so if the repository is exists (ensure in sync) and baseurl returns :absent but the user specified something else (baseurl out of sync), it goes ahead and change it. I am clearly missing something if this is a job the provider should do |
Your reference to The method first calls Note if your set methods only update the content of To the yumrepo type: It is not strictly necessary to have a provider at all and the yumrepo type is an example for that. In this case the type has to do all the work of retrieving the actual content. If we now want to migrate to a type <-> provider structure, the type will probably look like this:
So the type will just define the properties of a If you have further questions you can also join the google group |
"So the type will just define the properties of a yumrepo and all the rest should be handled by the provider. Does this make sense?" Yeah, probably this is the bit I was missing. Since my type was already handling fixing missing/broken properties, I thought I wouldn't be necessary to define the flush method. I've noticed there are a few methods on the Puppet type, self.store, flush, section, etc.. that do the job I want to achieve on the provider, I guess moving them over the provider will suffice? What about the insync?/sync/retrieve/inikey methods who don't specifically belong in the type? I'm trying to contact you or anyone else who knows about this over #puppet-dev (IRC) with no luck, will ask on the google puppet-dev group then! |
Hi @elobato, the The current |
I'm taking a look at reviewing this now. As some initial checks, please watch out for whitespace errors which can be checked for using Housekeeping - Whitespace Errors
Also, please keep our commit message guidelines in mind. Here's my canned comment on the subject. I mention this specifically because both commit messages aren't imperative, for example we prefer "(#9293) Make yumrepo resources ensurable" and not "(#9293) Yumrepos should be ensurable". The body of this commit message is OK, but it lacks an explanation of why it's important for you to make the yumrepo ensurable. Why is it that you need to work around the issue today? The commit message in bbb2768 could also be improved. "Modified provider so it doesnt use external dependencies. Added support for reposdir and fixed bugs" doesn't tell me the three pieces of information I really need to understand the change. What is the behavior of Puppet without bbb2768 applied? Why is this a problem? How does bbb2768 change the behavior of Puppet to address the problem? I'll likely have more comments about the code itself as well and will follow up soon with those. The housekeeping issues are definitely next steps, however, and need to be addressed before we'll merge this pull request in. Housekeeping - Commit MessageOn the point of housekeeping, please amend the commit message to include a description of the behavior without the patch applied, why this behavior is a problem, and then describe how the change addresses the problem. If the change addresses an error, please consider including the error message verbatim so it's clear if the problem resurfaces in the future. The first line of the commit message should be an imperative statement in the present tense. Change rather than changed or changing for example. |
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.
This shouldn't be here. Perhaps it was overlooked when committing after doing some debugging?
I've taken a look at the code itself, and things look pretty good overall. As next actions, the existing examples need to pass (please see the comment regarding the examples this change causes to fail), new examples need to be included to exercise the new ensureable behavior, and some housekeeping needs to be performed on the commit message and code style. I'm going to go ahead and close this pull request for the time being. Please re-open this pull request once the next actions are addressed, new information is available, or you have a question related to this pull request. Closing the pull request doesn't mean we don't consider this change valuable, just that there are things that need to be addressed before it can be merged. If you have any questions or concerns, please don't hesitate to ping us in #puppet-dev on irc.freenode.net. |
@elobato could you please finish this patch ? I'd really like to see it merged. |
This change adds a provider to yumrepo that makes it ensurable.
So far we needed todo a workaround making each of the individual files
that yumrepo creates ensurable, now yumrepo itself does it.
This probably should belong in 3.x as well as in 2.7x
https://projects.puppetlabs.com/issues/9293