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

MODULES-5426 : Add support for all mod_passenger server config settings #1665

Merged
merged 10 commits into from Oct 5, 2017

Conversation

dacat
Copy link
Contributor

@dacat dacat commented Aug 6, 2017

Support for the available server configuration settings is currently incomplete. The changes I've will:

  • Add support for all currently documented server config settings
  • Maintain support for the current set of apache::mod::passenger settings
  • Check if the user provided version of passenger supports, deprecated or removed the server config setting, Note: only works if passenger_installed_version is set.
  • Add basic rspec tests for the changes
  • Add basic acceptances tests to validate the support, deprecated, and removed functionality

Items from the guidlines for contributing:

  • Acceptance tests pass
  • Rspec tests pass
  • Documentation updated

* Parsed https://www.phusionpassenger.com/library/config/apache/reference for all options
* Took care of maintaining older options
* Add specs for all options
* added warnings a failures if passenger_installed_version is set
* Remove the RubyMine formatter configuration from the ERB template
* Remove pending message from spec/acceptance/mod_passenger_spec
  The message is not needed any more because puppet manages the
  passenger.conf file now
* validates the passenger_installed_version options fires the
  version checking for each option
* Fix a few linting errors
The code generator was using the introduction version number as the removed verison number.
@dacat
Copy link
Contributor Author

dacat commented Aug 7, 2017

I am finished making changes to this branch.

@HAIL9000
Copy link
Contributor

Hey @jbondpdx, would you mind taking a looking at these README changes and seeing what you think? They don't match the standard format we usually use for parameters but seem like an improvement with respect to readability and not duplicating documentation.

}
}
if $passenger_app_root {
if (versioncmp($passenger_installed_version, '4.0.0') < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be easier to sort the parameters based on their version instead of duplicating the versioncmp logic a bunch?

    if (versioncmp($passenger_installed_version, '4.0.0') < 0) {
      if $passenger_allow_encoded_slashes {
        fail("Passenger config option :: passenger_allow_encoded_slashes is not introduced until version 4.0.0 :: ${passenger_installed_version} is the version reported")
      }
      if $passenger_app_env {
        fail("Passenger config option :: passenger_app_env is not introduced until version 4.0.0 :: ${passenger_installed_version} is the version reported")
      }
      if $passenger_app_group_name {
        fail("Passenger config option :: passenger_app_group_name is not introduced until version 4.0.0 :: ${passenger_installed_version} is the version reported")
      }
      if $passenger_app_root {
        fail("Passenger config option :: passenger_app_root is not introduced until version 4.0.0 :: ${passenger_installed_version} is the version reported")
      }
    }

Copy link
Contributor Author

@dacat dacat Aug 19, 2017

Choose a reason for hiding this comment

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

You are right, I should of lumped together the checks. I thought about but I rationalized to keep it the way it was written -- why? I don't recall. I will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do recall now why it its that way. It was to keep all the passenger options in alphabetical order. Keep it as is, or lump them together?

Copy link
Contributor

Choose a reason for hiding this comment

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

Normally we keep these alphabetized just to make things easier to find. If sorting by version in this case works better, then I'm fine with it.

:concat_basedir => '/dne',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why indent extra here?

:concat_basedir => '/dne',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

:concat_basedir => '/dne',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

:concat_basedir => '/dne',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

:id => 'root',
:kernel => 'FreeBSD',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
:is_pe => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

@@ -25,7 +204,7 @@
it { is_expected.to contain_file('passenger.conf').with({
'path' => '/etc/apache2/mods-available/passenger.conf',
}) }
describe "with passenger_root => '/usr/lib/example'" do
describe "with passenger_root => '/usr/lib/example'" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All white space issues are either copy/paste or code generation issues. I will fix.

}) }

passenger_config_options = {
'passenger_allow_encoded_slashes' => {Type: 'OnOff', PassOpt: :PassengerAllowEncodedSlashes},
Copy link
Contributor

@eputnam eputnam Aug 16, 2017

Choose a reason for hiding this comment

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

It looks like you're using capitalized key names whereas in ruby this is not canonical.

e.g. Type would be type, PassOpt would be pass_opt

Also, I'm curious, is there a particular reason the values for PassOpt are symbols instead of strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason :) Just generated code, I will make it more canonical.

PassengerErrorOverride <%= @passenger_error_override %>
<%- end -%>
<%- if @passenger_file_descriptor_log_file -%>
PassengerFileDescriptorLogFile "<%= @passenger_file_descriptor_log_file %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand why some values get quotes and some don't. Could you expand on this decision?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the values may have white space. The passenger docs is not quote explicit on which ones can and can't. The passenger docs specify in the syntax the kind of value and from there I wrote a conversion chart. Copy-paste from my script below:

type_conversion_chart = {
    'dir-path' => 'FullPath',
    'file-path' => 'FullPath',
    'on|off' => 'OnOff',
    'uri' => 'URI',
    'path-to-ruby-interpreter' => 'FullPath',
    'path-to-python-interpreter' => 'FullPath',
    'path-to-node-js' => 'FullPath',
    'path-to-json-settings-file' => 'FullPath',
    'name' => 'String',
    'path' => 'FullPath',
    'relative-path' => 'RelPath',
    'absolute-or-relative-path' => 'Path',
    'smart|direct' => %w(smart direct),
    'username' => 'String',
    'groupname' => 'String',
    'scheme://user:password@proxy_host:proxy_port' => 'URI',
    'integer' => 'Integer',
    'seconds' => 'Integer',
    'number' => 'Integer',
    'process|thread' => %w(process thread),
    'megabytes' => 'Integer',
    'url' => 'URI',
    'bytes' => 'Integer',
    'filename' => 'FullPath',
    'path-to-socket' => 'FullPath',
    'your_application_key' => 'String',
    '"string"' => 'QuotedString',
    'gateway_hostname' => 'URI',
    'gateway_port' => 'Integer',
    'gateway_pinned_certificate_file' => 'FullPath'
}


Here is the bit where at I decided what was what.
quoted_types = ['QuotedString', 'FullPath', 'Path', 'RelPath']
non_quoted_types = ['OnOff','Integer','String','URI']

Things I mapped as non_quoted_types are the only settings in which the passenger documentation made evident the value would not contain white space, everything else may contain white space.

The apache documetation states

Arguments to directives are separated by whitespace. If an argument contains spaces, you must enclose that argument in quotes.

I also left in whatever quoting existed before my changes. I didn't want to change anyone's module configuration who was using existing options with or without quotes.

passenger_config_options.each do |config_option, config_hash|
puppetized_config_option = config_option
valid_config_values = []
case config_hash[:Type]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about the sorting of these tests into cases by the Type. Is this just a semantic thing to make the test cases more organized or does it serve a functional purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

During the code generator work, I had a different case for each "type" then slowly consolidated. When I saw that some of the existing apache::mod::passenger options had types associated with them, ex. $passenger_log_file and $passenger_spawn_method, my thought was to lay down some ground to maybe force type checking and allow unhappy-path testing. its probably too early for that, i'll will consolidate and remove duplicate code.

Copy link
Contributor

@jbondpdx jbondpdx left a comment

Choose a reason for hiding this comment

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

Awesome change, thank you!

README.md Outdated
Default: `undef`.

* `passenger_max_pool_size`: Sets the [`PassengerMaxPoolSize`](https://www.phusionpassenger.com/library/config/apache/reference/#passengermaxpoolsize).
The current set of server configurations settings were taking directly from the [`Passenger Reference`](https://www.phusionpassenger.com/library/config/apache/reference/). Deprecation warning and removal failure messages can be enabled by setting the passenger_installed_version to
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest changing the first sentence to "These server configuration settings are based on the Passenger Reference". Passenger Reference doesn't need to be in backticks.

Also, passenger_installed_version is a parameter, so should be in backticks.

README.md Outdated
|union_station_key|undef|[`UnionStationKey`](https://www.phusionpassenger.com/library/config/apache/reference/#UnionStationKey)||
|union_station_proxy_address|undef|[`UnionStationProxyAddress`](https://www.phusionpassenger.com/library/config/apache/reference/#UnionStationProxyAddress)||
|union_station_support|undef|[`UnionStationSupport`](https://www.phusionpassenger.com/library/config/apache/reference/#UnionStationSupport)||
|wsgi_auto_detect|undef|WsgiAutoDetect|These options have been removed in version 4.0.0 as part of an optimization. You should use PassengerEnabled instead.|
Copy link
Contributor

Choose a reason for hiding this comment

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

holy cow, this table is a heroic effort, go you! Huge improvement.

@dacat
Copy link
Contributor Author

dacat commented Aug 19, 2017

@hunner @HAIL9000 @jbondpdx @eputnam My apologies for not getting back to you sooner, I was out of the country. About 90% of the code and documentation is being generated by a script I wrote. This effort started as just adding support for the server config settings. It sort of snowballed as I kept adding to the code generator. I will fix the issues with the generator and formatting as you have pointed out. However, before I left I started on a branch to combine all the changes for Vhost, Directory and Server configurations. With that I have a few questions.

  1. Would you prefer I decline these pull requests and request one that adds all the features combining https://tickets.puppetlabs.com/browse/MODULES-5426 https://tickets.puppetlabs.com/browse/MODULES-5428 and https://tickets.puppetlabs.com/browse/MODULES-5430?
    However you prefer is fine with me.
  2. In regards to documentation, edits I made to my code/doc generator which adds in which apache directives the passenger options are available. This adds another column to the table. Is that acceptable or do you prefer something else?

Thanks for taking the time to review my pull request.

@eputnam
Copy link
Contributor

eputnam commented Aug 21, 2017

@dacat keeping the PRs separate works best. And I don't mind an extra column but I'm not sure I understand what it would be for.

* Remove whitespace added by auto-formatter
* Make hash keys more canonical
* Remove UnionStation options
  - UnionStation is no longer supported/offered by phusion.
  - All options are being removed from the passenger source
* Add white space at the end of the the passenger.conf.erb
  template
* Update the README to remove UnionStation as well as to
  add the context column.
@dacat
Copy link
Contributor Author

dacat commented Aug 21, 2017

@eputnam I added the column in the README for you to look at. All of the passenger options are available in the context of a "server config". From there subsets are available in "vhost", "directory" and "htaccess" Since all the passenger options are available, as of today, in the "server config" context, it made sense in my head to list the other context's which can contain the option.

Copy link
Contributor

@jbondpdx jbondpdx left a comment

Choose a reason for hiding this comment

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

Just this one little fix needed.

README.md Outdated
Default: `undef`.

* `passenger_max_pool_size`: Sets the [`PassengerMaxPoolSize`](https://www.phusionpassenger.com/library/config/apache/reference/#passengermaxpoolsize).
The current set of server configurations settings were taking directly from the [Passenger Reference](https://www.phusionpassenger.com/library/config/apache/reference/). Deprecation warning and removal failure messages can be enabled by setting the `passenger_installed_version` to
Copy link
Contributor

Choose a reason for hiding this comment

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

Change "taking" to "taken"

Optional bonus points if you make the "Deprecation warnings..." sentence active while you're in there: "To enable deprecation warnings and removal failure messages, set the..."

@dacat
Copy link
Contributor Author

dacat commented Sep 29, 2017

My apologies for the delay.

@HAIL9000 HAIL9000 dismissed jbondpdx’s stale review October 5, 2017 17:26

I've verified requested changes have been made, Jean is real busy so we'll just check this off for her

@HAIL9000 HAIL9000 merged commit 12b366c into puppetlabs:master Oct 5, 2017
cegeka-jenkins pushed a commit to cegeka/puppet-apache that referenced this pull request Jul 15, 2020
…tions

MODULES-5426 : Add support for all mod_passenger server config settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants