Commit 9ad875a
authored
Set PUMA_PERSISTENT_TIMEOUT for Rails, add Puma version warnings and errors. (heroku#1645)
* Refactor default config vars
* Fix PUMA_PERSISTENT_TIMEOUT not working on Rails
Rails does not inherit from Rack, they both inherit from Ruby.
GUS-W-19585440
* Add test for .profile.d/ (launch/runtime) env
* Set default PUMA_PERSISTENT_TIMEOUT profile.d
* Harden .profile.d check
By checking the full output, it means any change will cause the build to fail rather than needing to explicitly check individual files.
* Fix spelling
* Refactor default_config_vars
Standardize on using `out` as the variable name. Add documentation stating where it's inheriting from.
* Remove outdated comment
The "buildpack-env-args" refers to the ability of customers to have access to their config vars at build time, which used to not be possible. It has been on and the default for many years now. We can remove the comment.
The comment also assumed implementation details of how it would work once implemented. The `||=` here means that any buildpacks that export an environment variable before us will take precedence, which is behavior that we want. These `default_config_vars` should not take precedence over another buildpack explicitly writing an environment variable to their `export`.
* Refactor `default_env_vars` method out
This method is used in a handful of places. We can replace that usage with the literal contents.
* Remove `config_vars` from bin/release
This field is not currently documented at https://devcenter.heroku.com/articles/buildpack-api#bin-release, but it is used for setting config vars for customers. The caveat is that it only affects apps on the first push, which isn't very useful. That's why it's not even documented anymore.
The "correct" way to set an environment variable is:
- `.profile.d/<script>.sh` Sets the value at launch/runtime
- `export` Sets the value at build time for future buildpacks
Previously, the `def default_config_vars` was used in relationship with `bin/release` to set `config_vars`. But, since that's not used (as of this commit) it is repurposed as an interface for writing default values to `.profile.d` scripts. All these values were already being written, but now it's centralized (i.e. this .profile.d part of the change is a literal refactor, it doesn't change any behavior).
There are some implications with the API: Any value that comes out of `def default_config_vars` will be persisted to disk and will take precedent if someone runs `heroku config:unset <env var>` for example. Previously, the values also contained the user's environment variable value i.e. if someone set `heroku config:set RAILS_ENV=my_custom_env` then that change would be propagated to `bin/release`. Now we don't want to write a value like ` export RACK_ENV=${RACK_ENV:-my_custom_env}` otherwise. We want the default to fall back to OUR default. Therefore only literal values should be used in this API. That part is unexpected and unsafe, so I'm likely going to move/change how the interface works. But I will do that in future commits.
* Add a test for the current buildpack `export`
The `export` file writes environment variables that are visible to future buildpacks. This adds a test to assert the current behavior.
* Add default_config_vars to export automatically
* Remove set empty env var
This env var was set for Bundler <= 2.1.4 compat in this commit heroku@655e246 which explains the behavior.
It has since been reduced over the years to no longer set it to a `1` and instead set it to an empty string. It's also only exported and not set for build time, therefore it can be safely removed.
As to **why** it isn't a problem any more. We list our oldest available Ruby version as 3.1:
https://devcenter.heroku.com/articles/ruby-support-reference#unsupported-ruby-versions
And the default bundler version for that version of ruby is 2.3 which is > 2.1
```
$ gem list | grep bundle
bundler (2.6.9, 2.5.22, default: 2.3.27)
```
* Whitespace
* Flatten inheritance
The `default_config_vars` was using inheritance and calling `super`, and it was very difficult to follow what actual behavior was. This commit flattens the behavior and puts it all into `ruby.rb`.
* Remove un-used inheritance
With the `def default_config_vars` logic flattened, these files no longer serve a purpose and can be deleted.
* Remove un-needed method definition
* Introduce isolated DefaultEnvVars.call function
This provides more protection (isolation) than the comment above `def default_config_vars` to help protect future modification from accidentally persisting customer config vars to disk.
* Replace logic with DefaultEnvVars.call function
* Refactor
* Apply suggestions from code review
Signed-off-by: Richard Schneeman <richard.schneeman+no-recruiters@gmail.com>
---------
Signed-off-by: Richard Schneeman <richard.schneeman+no-recruiters@gmail.com>1 parent 0102a10 commit 9ad875a
20 files changed
Lines changed: 533 additions & 157 deletions
File tree
- changelogs/unreleased
- lib
- language_pack
- helpers
- test
- spec
- hatchet
- helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | | - | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | | - | |
62 | | - | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 65 | | |
73 | 66 | | |
74 | 67 | | |
| |||
96 | 89 | | |
97 | 90 | | |
98 | 91 | | |
99 | | - | |
100 | 92 | | |
101 | 93 | | |
102 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 17 | | |
25 | 18 | | |
26 | 19 | | |
| |||
31 | 24 | | |
32 | 25 | | |
33 | 26 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 27 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 26 | | |
42 | 27 | | |
43 | 28 | | |
| |||
76 | 61 | | |
77 | 62 | | |
78 | 63 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
0 commit comments