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

Reorganize templates for clearer understanding #970

Merged
merged 1 commit into from
Nov 14, 2016
Merged

Reorganize templates for clearer understanding #970

merged 1 commit into from
Nov 14, 2016

Conversation

zachfi
Copy link
Contributor

@zachfi zachfi commented Nov 13, 2016

Without this change, the structure of the templates for locations are
bit rigid and hard to understand. Each component of a location uses an
isolated template which means that much of the common logic is hard
coded to a particular location style, the deployment of which is chosen
based on a somewhat arbitrary idea of what it means to be a location,
and in some cases, the module gets it wrong. In cases where there is
seeming correctness, modifications to a particular selection of logic
are duplicated among the nested templates.

This work is the results of what was necessary for me to understand what
the templates were doing, and to deploy a fastcgi PHP application. As
such, the templates have been centralized and conditions about their
functionality have been moved into the template to determine if
rendering needs to be taken. This allows a more complete, and leaves
potential for more complex examples easier to understand and reason
about.

Also here is the addition of a new param fastcgi_index on the location
class.

This work should result in on-disk configurations that are functionally
equivalent to what was in place before, except in places where the
module was masking conflicting options that were not being rendered in
the templates.

@wyardley
Copy link
Collaborator

I think we were talking about this online, and this is roughly the direction I was hoping this part would head in.

I'd like some input from @bastelfreak or @3flex, but I think it might make more sense to use concat() for some or all of the template joining (as is done in most of the rest of the module) vs. including templates from within another template, but curious to see what other folks think.

Obviously, quite a few tests will need to be reworked to get this going.

Note that the server -> vhost change is in progress; will probably need to rebase after that gets merged.

@jyaworski
Copy link
Member

Big fan of concat.

@zachfi
Copy link
Contributor Author

zachfi commented Nov 13, 2016

@jyaworski I too am a fan of concat, but I don't think it applies here. The location blocks may be of arbitrary count, and with arbitrary options within each block. To use concat, the order would be a nightmare, and perhaps simply not possible.

@wyardley I thought I'd toss up the PR to generate discussion. I've not looked at the tests yet, but I think of we can agree about a direction here, that would certainly make this module easier to work with. I care about locations at the moment, but this pattern could be extended elsewhere.

@3flex
Copy link
Contributor

3flex commented Nov 13, 2016

I've only skimmed over this, but I'm 100% in support of this change, it's long overdue.

I agree that concat isn't the right choice here for the reasons @xaque208 outlined above. There are very few order-dependent directives that can be set within a location block (I think just directives from the rewrite and access modules?) so concat would add a lot of complexity for little gain. Better to treat those two module's directives specially instead. Using conditionals like in the PR is a better way to go IMHO.

Without this change, the structure of the templates for locations are
bit rigid and hard to understand.  Each component of a location uses an
isolated template which means that much of the common logic is hard
coded to a particular location style, the deployment of which is chosen
based on a somewhat arbitrary idea of what it means to be a location,
and in some cases, the module gets it wrong.  In cases where there is
seeming correctness, modifications to a particular selection of logic
are duplicated among the nested templates.

This work is the results of what was necessary for me to understand what
the templates were doing, and to deploy a fastcgi PHP application.  As
such, the templates have been centralized and conditions about their
functionality have been moved into the template to determine if
rendering needs to be taken.  This allows a more complete, and leaves
potential for more complex examples easier to understand and reason
about.

Also here is the addition of a new param fastcgi_index on the location
class.

This work should result in on-disk configurations that are functionally
equivalent to what was in place before, except in places where the
module was masking conflicting options that were not being rendered in
the templates.
@zachfi
Copy link
Contributor Author

zachfi commented Nov 14, 2016

I've updated the primary template and the tests pass. Each template render call now is within its own <%= %> block.

@jyaworski jyaworski merged commit 50cced9 into voxpupuli:master Nov 14, 2016
@zachfi zachfi deleted the templates branch November 14, 2016 03:57
@zachfi
Copy link
Contributor Author

zachfi commented Nov 14, 2016

Thank you.

@wyardley
Copy link
Collaborator

Was hoping to get #968 merged before we merged anything else, but no worries, we can re-do it this week probably.

@@ -1,3 +1,4 @@
<% if @proxy -%>
proxy_pass <%= @proxy %>;
proxy_read_timeout <%= @proxy_read_timeout %>;
proxy_connect_timeout <%= @proxy_connect_timeout %>;

Choose a reason for hiding this comment

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

Is there a reason why proxy_send_timeout is not part of this if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ubellavance Only oversight. Feel free to send a PR for any change that needs to be made here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ubellavance
This PR is already merged, so no point adding a review / feedback here.
I don't think the issue is that proxy_send_timeout isn't part of the template; it's not a parameter for the location resource at all. As things in the past have tended to be added piecemeal as people needed them, there's not a lot of consistency in terms of which supported parameters are allowed in which contexts. As best I can tell, proxy_send_timeout isn't currently directly supported as a parameter for server blocks either; it's just supported at the top level nginx config. This could be because most people don't need to set different values for this for different sites, and / or that the people who do just use the location_cfg_append or similar directives.

That said, it's not a big limitation usually, because you can generally use the various custom directives to add those parameters if they're needed in server or location contexts. As @xaque208 says, PRs (with tests) are welcome.

Copy link

@ubellavance ubellavance Jan 26, 2017

Choose a reason for hiding this comment

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

No problem. I saw that yesterday while browsing the code to make changes in my environment. I think I'll pass for the PR this time (mostly because I don't have much time, but also because this module is a bit too complex for me) and I realize that I'm already using the parameter in the global directive.

I must say, though, that this module rocks and it's very nice to see how many people invest that much time into it.

cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this pull request Sep 13, 2019
Without this change, the structure of the templates for locations are
bit rigid and hard to understand.  Each component of a location uses an
isolated template which means that much of the common logic is hard
coded to a particular location style, the deployment of which is chosen
based on a somewhat arbitrary idea of what it means to be a location,
and in some cases, the module gets it wrong.  In cases where there is
seeming correctness, modifications to a particular selection of logic
are duplicated among the nested templates.

This work is the results of what was necessary for me to understand what
the templates were doing, and to deploy a fastcgi PHP application.  As
such, the templates have been centralized and conditions about their
functionality have been moved into the template to determine if
rendering needs to be taken.  This allows a more complete, and leaves
potential for more complex examples easier to understand and reason
about.

Also here is the addition of a new param fastcgi_index on the location
class.

This work should result in on-disk configurations that are functionally
equivalent to what was in place before, except in places where the
module was masking conflicting options that were not being rendered in
the templates.
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this pull request Oct 19, 2020
Without this change, the structure of the templates for locations are
bit rigid and hard to understand.  Each component of a location uses an
isolated template which means that much of the common logic is hard
coded to a particular location style, the deployment of which is chosen
based on a somewhat arbitrary idea of what it means to be a location,
and in some cases, the module gets it wrong.  In cases where there is
seeming correctness, modifications to a particular selection of logic
are duplicated among the nested templates.

This work is the results of what was necessary for me to understand what
the templates were doing, and to deploy a fastcgi PHP application.  As
such, the templates have been centralized and conditions about their
functionality have been moved into the template to determine if
rendering needs to be taken.  This allows a more complete, and leaves
potential for more complex examples easier to understand and reason
about.

Also here is the addition of a new param fastcgi_index on the location
class.

This work should result in on-disk configurations that are functionally
equivalent to what was in place before, except in places where the
module was masking conflicting options that were not being rendered in
the templates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants