-
-
Notifications
You must be signed in to change notification settings - Fork 548
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
Fix uniq for nil:NilClass error introduced in 3.2.2 #422
Conversation
brentm5
commented
Apr 14, 2016
- Add default values for listen_ports and listen_addresses
- Add attribute to test for the error introduced
- Add default values for listen_ports and listen_addresses - Add test case in test cookbook
Why is it even getting in there unless you have some values in |
@@ -34,8 +34,8 @@ def self.converted_listen_ports_and_addresses(node) | |||
return [] unless node['apache']['listen_ports'] || node['apache']['listen_addresses'] |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Not entirely sure what we are doing to cause this, but I know this caused everything that includes apache2 to fail in our infrastructure. I simply went back to 3.2.1 to resolve the issue for now. I can only assume we arent the only other ones to run into this issue. I mean by default both of those values are nil so we should either check them both with an && or there should be default attribute for this. If either of them are empty array then nothing happens anyway... |
In the cookbook versions less than 3.2, the ports and addresses were each in their own array and what the ports.conf had was a combination of every port on every address. In 3.2 there's a new array {
"apache": {
"listen": [
"*:80",
"*:443",
"127.0.0.1:12345"
]
}
} that My guess is that the reason it's failing for you is you have some override attributes that are setting either just the ports or just the attributes. On an existing node that still shouldn't be a problem since the old default attributes wouldn't have gone away (unless you did a |
Also, there should probably be some tests that fail because of this. I'd like this PR better if it had some tests that show the bug and expected behavior. |
Mea culpa on not testing in all conditions for this PR. The situation I Next time I'll do a more thorough job....
|
I did add an attribute in the test cookbook so that this code path is now hit and tested @b-dean I wasn't sure of the exact fix that was wanted, I assumed that since this was an older syntax the reason there were no health defaults was because the new syntax was used in favor of this and people didn't want to add default values to confuse people. Thats why I just added a way to not have the nil class, but added an attribute in the test cookbook so the code path was executed. |
When I first changed from the old So when it was changed to be an |
Then maybe it shouldn't be an |
@bigbam505 I did that because it was valid to only have one of node['apache']['listen_ports'] or node['apache']['listen_addresses'] in a cookbook. For instance in the case I was working on node['apache']['listen_ports'] was set but node['apache']['listen_addresses'] was not and relied on the apache2 cookbook defaults and so the self conversion to node['apache']['listen'] never occurred. As mentioned above, I did fail to look at all circumstances but && has problems. Just replacing with || was an over simplification on my part but if we're trying to be backwardly compatible with 3.1.x then && does not fully work either. If we're presenting backward compatibility we need to move forward with something that does work for all circumstances - I realize in retrospect || breaks things but it did fix my particular circumstance where && failed. Hope that explains the reasoning... |
I think we understand the reasoning, just with the current code its broken for that use case that you are referring to however so the next question is how do we want to go about fixing it. I have supplied one way which simply has no default values as was the current implementation. I think added in default values (whether in the attributes or hidden in this library method) changes the behavior so its not a very safe change for people using this cookbook. The logical sense for me was above which would keep the existing behavior of a no op. When one value wasn't specified other than making assumptions of what everyone using this cookbook would want. Maybe @svanzoest should be the one to answer this question? |
The apache default has always been In the majority of cases using |
So from what I see we should just let this be nothing by default and the config would have no entry and therefore use the default apache config. If I am understanding you correctly then the above solution that I have provided is correct. If there has to be a value in the config file then what @b-dean stated (copied below) might make sense so that the attributes are not listed and confusing people but we provide the default value apache would use.
|
It feels fine to me also if we don't know of any addresses to just set the default to |
- Sets the address to * if not specified in attributes - Sets the ports to 80 & 443 if not specifid in attributes
@svanzoest Assumed you meant adding some sane defaults in the library instead of in the attributes like @b-dean suggested. Went ahead and made those changes and added a comment because its sort of hidden by not being in the attributes. |
@svanzoest does this look good from your perspective / can be merged or are there other things I should change before that point? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |