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 document root check for vcl generation #25360

Closed
wants to merge 8 commits into from
Closed

add document root check for vcl generation #25360

wants to merge 8 commits into from

Conversation

torhoehn
Copy link
Contributor

@torhoehn torhoehn commented Oct 29, 2019

Description (*)

#11692

Manual testing scenarios (*)

  1. Set document root to /pub
  2. Create varnish vcl
  3. Path to health_check.php is correct now, so Varnish is started correctly

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 29, 2019

Hi @torhoehn. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Member

@rodrigowebjump rodrigowebjump left a comment

Choose a reason for hiding this comment

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

Hi @torhoehn Please check my comments and fix the failing tests.

Thanks

remove line

fix tests

fix codestyle

fix code style again
@torhoehn
Copy link
Contributor Author

Hi @torhoehn Please check my comments and fix the failing tests.

Thanks

@rodrigowebjump Fixed tests, but couldn‘t find any comments.

@@ -67,6 +74,7 @@ public function __construct(
$accessList,
$gracePeriod,
$sslOffloadedHeader,
DirectoryList $directoryList,
Copy link
Member

Choose a reason for hiding this comment

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

@torhoehn The new param should come as last one.

See: https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/
Add a new constructor param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right. I fixed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rodrigowebjump One of the test says, that arguments with default values must be at the end of the argument list. Should I undo my latest changes or add the DirectoryList as optional parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rodrigowebjump I think everything looks fine now. :)

@@ -67,7 +74,8 @@ public function __construct(
$accessList,
$gracePeriod,
$sslOffloadedHeader,
$designExceptions = []
$designExceptions = [],
DirectoryList $directoryList = null
Copy link
Member

Choose a reason for hiding this comment

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

Hi you also need to add the DirectoryList as optional ?DirectoryList $directoryList

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rodrigowebjump This isn't mentioned in DevDocs (https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/#php), so im not sure about that.

    public function __construct(
        \Old\Dependency\Interface $oldDependency,
        $oldRequiredConstructorParameter,
        $oldOptionalConstructorParameter = null,
        \New\Dependency\Interface $newDependency = null
    ) {
        ...
        $this->newDependency = $newDependency ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\New\Dependency\Interface::class);
    }

Copy link
Member

Choose a reason for hiding this comment

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

Hi @torhoehn

This is a good practice.
I create a PR for this magento/devdocs#6033

It's is supported since PHP 7.1 (https://www.php.net/manual/en/migration71.new-features.php) and is recommended when adding a nullable param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rodrigowebjump Okay, I added it. :)

@rodrigowebjump
Copy link
Member

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, here is your new Magento instance.
Admin access: https://pr-25360.instances.magento-community.engineering/admin
Login: admin Password: 123123q

Copy link
Member

@rodrigowebjump rodrigowebjump left a comment

Choose a reason for hiding this comment

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

Hi @torhoehn

Thanks for your contribution

@rodrigowebjump rodrigowebjump added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Nov 25, 2019
@engcom-Alfa engcom-Alfa self-assigned this Nov 28, 2019
@ghost ghost dismissed sivaschenko’s stale review March 25, 2020 06:28

Pull Request state was updated. Re-review required.

@torhoehn
Copy link
Contributor Author

Hi, @torhoehn.

Unfortunately, the problem described in #25360 (comment) is still reproducible.

Actual Result:
getBaseUrl() return the Base URL and the wrong path .url = "/pub/health_check.php" is written to the varnish.vcl file
Screenshot from 2020-03-24 22-11-50

@torhoehn Could you take a look?

Thanks!

@engcom-Alfa So you configured the document root instead of the Base URL pointing to 'pub' directory?

@sivaschenko Maybe we should check the request and the Base URL if one of them contains 'pub'?

*/
private function getHealthCheck() : string
{
if (strpos($this->url->getBaseUrl(), 'pub') === false) {
Copy link
Member

Choose a reason for hiding this comment

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

@torhoehn missed that during the review, sorry. If base url contains pub - health check should also contain pub and vice-versa

Suggested change
if (strpos($this->url->getBaseUrl(), 'pub') === false) {
if (strpos($this->url->getBaseUrl(), 'pub') !== false) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it.

sivaschenko
sivaschenko previously approved these changes Mar 29, 2020
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-7194 has been created to process this Pull Request

Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

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

Hi @torhoehn.
During testing, we faced the issue.

Problem: If base url contains /pub health check also contain pub and everything works well. But, if base url doesn't contain /pub health check also doesn't contain 'pub' and we will get an 503 error.

Manual testing scenario:

  1. Configure Base URL pointing to 'pub' directory ('http://magento24.loc/pub/' in my case);
  2. Go to Admin->Stores->Configuration->Advanced->System->Full Page Cache;
  3. Choose "Varnish Cache" from "Caching Application" drop-down and click on "Save" button;
  4. Then click on "Export VCL for Varnish 6" button and open it;
    varnish
  5. Copy the file to the /etc/varnish/ directory;
  6. Open home page;

Actual Result: ✔️ 200 OK
varnish 2

  1. Configure Base URL to default ('http://magento24.loc/' in my case);
  2. Repeat steps 2-4;
    varnish3
  3. Copy the file to the /etc/varnish/ directory;
  4. Open home page;

Actual Result: ✖️ 503 Backend fetch failed
Screenshot from 2020-04-01 09-49-26

@torhoehn @sivaschenko Could you take a look?

Thanks!

@ghost ghost dismissed sivaschenko’s stale review April 1, 2020 06:52

Pull Request state was updated. Re-review required.

@torhoehn
Copy link
Contributor Author

torhoehn commented Apr 2, 2020

@engcom-Alfa @sivaschenko So depending on the Base URL the health check should always contain pub, so no dynamic solution is possible?

@sivaschenko
Copy link
Member

@engcom-Alfa have you changed the webserver configuration to be pointed to .../pub on step 7 of verification, is Magento accessible at http://magento24.loc/ on that step?

@engcom-Alfa
Copy link
Contributor

@sivaschenko yes, Magento is accessible at http://magento24.loc/ on 7th step

@VladimirZaets
Copy link
Contributor

@sivaschenko , @engcom-Alfa , @torhoehn guys, any updates on it?

@torhoehn
Copy link
Contributor Author

@sivaschenko Any idea?

@sivaschenko
Copy link
Member

@torhoehn do you have the same test results on your environment?

@engcom-Charlie
Copy link
Contributor

Hi @torhoehn, I'm closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for your collaboration.

@m2-assistant
Copy link

m2-assistant bot commented Jun 30, 2020

Hi @torhoehn, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.