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

Add Cache Manager support for Accept header #70

Closed
wants to merge 1 commit into from

Conversation

yadij
Copy link
Contributor

@yadij yadij commented Oct 5, 2017

This completes the support in cachemgr Action classes for
incremental addition of report formats other than text/plain
(historic cachemgr.cgi accepted syntax).

Reporters (class Action children) can now determine their
content-type support dynamically based on request
Accept header.

Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

This PR intentionally excludes adding special formatter class(es) for use by the report generator.

I believe that we must start with the right API, including formatting classes, instead of making actions YAML-aware and adding YAML-specific formatting code to hand-picked actions.

IIRC, the topic of introducing YAML support has been discussed on squid-dev at some point. If so, please reference that discussion in the PR description.

@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Oct 24, 2017
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Feb 5, 2018
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 10, 2019
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 20, 2019
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 3, 2019
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 13, 2019
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 21, 2019
@yadij yadij added the feature maintainer needs documentation updates for merge label Dec 23, 2019
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Apr 25, 2020
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 2, 2020
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 1, 2021
@yadij yadij added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label Dec 27, 2021
@yadij yadij requested a review from rousskov December 27, 2021 10:36
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

As a workaround for a GitHub UI limitation, I am attaching two "global" change requests to the first (and innocent) line in the PR instead of listing them here, in this review comment, because change requests in such review comments are often ignored and their discussion is difficult to follow.

src/mgr/Action.h Outdated Show resolved Hide resolved
src/cache_manager.cc Show resolved Hide resolved
@@ -248,6 +248,8 @@ CacheManager::ParseHeaders(const HttpRequest * request, Mgr::ActionParams &param

Copy link
Contributor

Choose a reason for hiding this comment

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

This PR assumes that future Actions should react to Accept request header values, presumably producing output of two (or more) different Content-Types. Why is that a good idea? Should not all Actions simply respond using YAML instead, disregarding the Accept request header value (or validating it centrally, before the Action is even created and forwarded to workers)? If we have already agreed to proceed with this design, please feel free to point me to that agreement, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ad-hoc format accepted by cachemgr.cgi is not fully compliant YAML. So to retain support for tools expecting that syntax we should only send YAML when it is indicated by the client Accept header.

IIRC, we agreed to the principal of moving to YAML, but still have disagreement on the specifics.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ad-hoc format accepted by cachemgr.cgi is not fully compliant YAML.

Not sure why you are talking about cachemgr.cgi as if it specifies what output Squid does or should produce. That CGI script is just a hack that we fully control. It will accept whatever we make it accept. It does not and should not determine Squid output format(s). I do agree that Squid output is not YAML today, of course, but that fact has nothing to do with cachemgr.cgi.

So to retain support for tools expecting that syntax we should only send YAML when it is indicated by the client Accept header.

IMO, we do not want to add code that works towards retaining support for tools requiring non-YAML syntax because we do not want to create and maintain code that generates responses in two different formats, especially when one of those formats is an undefined/unstructured/ad-hoc/custom/informal format. We want to move towards YAML, not towards YAML+informal. We cannot get to YAML immediately, of course, but I see no value (and quite a bit of harm) in enabling this kind of Action code:

if (clientAcceptsYaml)
    generateYamlResponse();
else
    generateInformalResponse();

And if the above is not what we want, then I see no value in telling Actions what formats the client accepts.

IIRC, we agreed to the principal of moving to YAML

Yes, that matches my recollection as well.

but still have disagreement on the specifics.

That is probably true, but this change request disagreement appears to be about the very target/direction of that move rather than any move specifics. If we target just one format, then Actions do not need to know what formats the client accepts.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Dec 27, 2021
@rousskov
Copy link
Contributor

I do not understand the current description1 of the feature label, but perhaps this PR does not need that mysterious label?

Footnotes

  1. maintainer needs documentation update for merge: "For merge" of which PR? Where? It does not sound like we are talking about merging the labeled PR into its target branch... Please update the label name and description to clarify. If this label is about the need to update Squid release notes and such (after the PR is merged), then let's say that explicitly, preferably with a common reusable prefix! For example, todo-release-notes or todo-update-release-docs.

@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels May 3, 2022
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 8, 2022
@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 23, 2022
@yadij yadij requested a review from rousskov September 14, 2022 08:09
@yadij yadij added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Sep 14, 2022
@rousskov rousskov removed their request for review September 16, 2022 21:11
@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Sep 16, 2022
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 27, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 18, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jan 9, 2024
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label Feb 14, 2024
@yadij
Copy link
Contributor Author

yadij commented May 9, 2024

Cache manager is no longer planned to present anything other than YAML. Closing as unneeded

@yadij yadij closed this May 9, 2024
@yadij yadij deleted the mgr-reports branch May 9, 2024 00:30
@rousskov rousskov removed the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature maintainer needs documentation updates for merge S-waiting-for-author author action is expected (and usually required)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants