Skip to content

Conversation

@SolidWallOfCode
Copy link
Member

@SolidWallOfCode SolidWallOfCode commented Apr 20, 2022

This also enables a missing "remap.config" to be treated as an empty file (that is, it "parses" successfully and yields no remap rules).

Due to feedback, this now adds a configuration variable, "proxy.config.url_remap.min_rules_required" to control how many rules are need in "remap.config" to be considered a valid configuration. With this a deployment can easily tune whether empty/missing file is acceptable. The PR has been updated with documentation and tests for this. Note the value is dynamic and it is therefore possible to have different behavior on startup vs. runtime (e.g. allow empty on start but not on reload).

Closes #8785

@SolidWallOfCode SolidWallOfCode added this to the 10.0.0 milestone Apr 20, 2022
@SolidWallOfCode SolidWallOfCode self-assigned this Apr 20, 2022
bneradt
bneradt previously approved these changes Apr 20, 2022
@bneradt
Copy link
Contributor

bneradt commented Apr 20, 2022

Thanks for working on this @SolidWallOfCode.

I think we'll want to mark this for the 9.2.x project as well since the patch that introduced the issue went into 9.2.x.


std::error_code ec;
std::string content{ts::file::load(ts::file::path{path}, ec)};
if (ec.value() == ENOENT) { // a missing file is ok - treat as empty, no rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I haven't had enough coffee today, but how is a missing file ok? I know we'd want that to be a failure for our systems.

Copy link
Member Author

Choose a reason for hiding this comment

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

As a general policy for ATS we want to not require the existence of configuration files. If an empty file is acceptable, it shouldn't be required to actually put one there.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a specific setting to not force having a remap.config -- proxy.config.url_remap.remap_required https://docs.trafficserver.apache.org/admin-guide/files/records.config.en.html#proxy-config-url-remap-remap-required, which has existed since the first commit. I'd expect a missing file to need that setting set to 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, that setting means a remap rule is not required to forward the transaction. It has nothing to do with whether there is an actual "remap.config" file.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a specific setting to not force having a remap.config -- proxy.config.url_remap.remap_required https://docs.trafficserver.apache.org/admin-guide/files/records.config.en.html#proxy-config-url-remap-remap-required, which has existed since the first commit. I'd expect a missing file to need that setting set to 0.

This also seems correct to me. Do we at least want a warning in diags.log if remap.config is empty? Do we know of ATS users who don't do any remapping?

Copy link
Contributor

@randall randall left a comment

Choose a reason for hiding this comment

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

Just want some clarification before this is merged.

@ezelkow1
Copy link
Member

Does this still allow a remap to be partially loaded when it's bad? IMHO that's still a very bad issue since it allows problems to crop up that are even worse than just not reloading the file, you could end up with all_services-1 not being able to serve

@SolidWallOfCode
Copy link
Member Author

No. The partial loading still happens during startup, but ATS is then immediately shut down so it's irrelevant. Reloads continue to be atomic (all or nothing of the new configuration).

@zwoop
Copy link
Contributor

zwoop commented Apr 20, 2022

Reading comments, I think we

  1. Should not change behavior in 9.2.x to allow non-existing files. One can argue this is a bug, but the effects of someone deploying this, assuming this is how it works, could be catastrophic.
  2. We can change 10.0.0 to allow no remap.config and allow startup as such.
  3. In 10.0.x, I would urge though to not allow a config reload, if the previous config had a remap.config file, and the reload has lost it. I.e. don't allow for a "rm remap.config" + reload to cause a complete failure.

As such, my strong preference is that we back out this train of PRs from 9.2.x, and roll forward with 10.0.x

@bneradt
Copy link
Contributor

bneradt commented Apr 20, 2022

As such, my strong preference is that we back out this train of PRs from 9.2.x, and roll forward with 10.0.x

In that case, we should revert #7782 from 9.2.x and not cherry-pick this PR to 9.2.x. I'll create a PR to revert #7782 from 9.2.x.

bneradt pushed a commit to bneradt/trafficserver that referenced this pull request Apr 20, 2022
Revert "Short circuit remap reload when a valid remap file is not specified (apache#7782)"

This reverts commit d7847f2.

This is being reverted from 9.2.x because changing remap.config loading
behavior was deemed too big a change to make within the 9.x releases.
See the discussion in apache#8802. These remap.config changes will be pursued
in the 10.x train.
@zwoop
Copy link
Contributor

zwoop commented Apr 20, 2022

I think @SolidWallOfCode has a strong preference to not revert.

@SolidWallOfCode
Copy link
Member Author

I went back and checked. Prior to #7782 a missing "remap.config" was allowed. This is a reversion to previous behavior.

I have checked this in four cases to verify the operation is what is requested.

  1. Valid, empty, missing "remap.config" at start up - successful start.
  2. "remap.config" containing an error at start up - emergency shutdown (no restart).
  3. Valid, empty, missing "remap.config" for reload - remap rules are updated.
  4. "remap.config" containing an error for reload - remap rules are not updated.

This makes "remap.config" loading atomic - all of the file, or none of it.

@bryancall
Copy link
Contributor

bryancall commented Apr 21, 2022

Since ATS prior to #7782 has the features you want, can't we just revert #7782? If not what is the difference in behavior now (after this PR) vs pre-#7782?

@SolidWallOfCode
Copy link
Member Author

This change unifies start up and reload handling of "remap.config". It also changes startup failure to Emergency from Fatal to avoid a restart loop. I've also tested this version and verified it behaves as requested.

However, due to some pushback, I plan to add a configuration variable to enable requiring a minimum number of rules in the "remap.config" to be valid. The default, at least for 9.2, will be 1. This means an empty or missing file won't replace a valid file. That can be changed by adjusting the configuration value. LinkedIn and Apple. I pondered a configuration for requiring a file but decided that was too indirect - a file with just comments is really an empty file. Valid rules are the correct metric for determining the "emptiness" of a file.

@bryancall
Copy link
Contributor

@bneradt is going to review this

Copy link
Contributor

@bneradt bneradt left a comment

Choose a reason for hiding this comment

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

Looks good. Just a few minor suggestions.

Set this variable to ``1`` if you want to retain the client host
header in a request during remapping.

.. ts:cv:: CONFIG proxy.config.url_remap.min_rules_required INT 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we want to use 0 here since that's the default.

zwoop
zwoop previously approved these changes Apr 27, 2022
Copy link
Contributor

@zwoop zwoop left a comment

Choose a reason for hiding this comment

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

Thanks Alan, appreciate you humoring the senile old geyser.

randall
randall previously approved these changes Apr 28, 2022
Copy link
Contributor

@randall randall left a comment

Choose a reason for hiding this comment

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

Thanks ! This is great!

zwoop pushed a commit that referenced this pull request Apr 28, 2022
Revert "Short circuit remap reload when a valid remap file is not specified (#7782)"

This reverts commit d7847f2.

This is being reverted from 9.2.x because changing remap.config loading
behavior was deemed too big a change to make within the 9.x releases.
See the discussion in #8802. These remap.config changes will be pursued
in the 10.x train.

Co-authored-by: bneradt <bneradt@yahooinc.com>
@SolidWallOfCode SolidWallOfCode dismissed stale reviews from randall and zwoop via c16dbb5 April 29, 2022 23:13
@SolidWallOfCode SolidWallOfCode merged commit 692223c into apache:master May 6, 2022
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.

9.2.x: invalid remap.config files are no longer FATAL

8 participants