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

Migration: Perl module check with OTOBO running under Apache #1512

Closed
bschmalhofer opened this issue Dec 16, 2021 · 3 comments
Closed

Migration: Perl module check with OTOBO running under Apache #1512

bschmalhofer opened this issue Dec 16, 2021 · 3 comments
Assignees
Labels
bug Something isn't working as intended
Milestone

Comments

@bschmalhofer
Copy link
Contributor

Tested the migration with OTOBO 10.1.x under Apache as the target. The version check is fine. So the issue can be closed.

But there is another error right after the OTOBO version check. Opening a new issue for that,
Bildschirmfoto vom 2021-12-16 16-21-01

Originally posted by @bschmalhofer in #1510 (comment)

@bschmalhofer bschmalhofer self-assigned this Dec 16, 2021
@bschmalhofer
Copy link
Contributor Author

bschmalhofer commented Dec 16, 2021

The error comes from the effect that bin/otobo.CheckModules.pl exits with an error when run as part of migration.pl under Apache. No problems are encountered when calling the same script on the command line.
The specific error is that the module CGI::PSGI cannot be loaded. CGI::PSGI is a new dependency in rel-10_1, that's why this problem does not occur in rel-10_0. The error hasn't been seen under Docker, this is propably because under Docker the webserver Gazelle is used instead of Apache.

A bit of digging revealed the error produced from require CGI::PSGI.

Can't locate Apache.pm in @inc (you may need to install the Apache module) (@inc contains: /home/bernhard/devel/OTOBO/otobo/Custom /home/bernhard/devel/OTOBO/otobo/Kernel/cpan-lib /home/bernhard/devel/OTOBO/otobo /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /home/bernhard/devel/OTOBO/otobo/Kernel/cpan-lib/CGI.pm line 178.

So the real problem is the module CGI, which is a dependency of CG::PSGI. The relevant code is:

Turn on special checking for Doug MacEachern's modperl

PerlEx::DBI tries to fool DBI by setting MOD_PERL

if (exists $ENV{MOD_PERL} && ! $PERLEX) {

mod_perl handlers may run system() on scripts using CGI.pm;

Make sure so we don't get fooled by inherited $ENV{MOD_PERL}

if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
$MOD_PERL = 2;
require Apache2::Response;
require Apache2::RequestRec;
require Apache2::RequestUtil;
require Apache2::RequestIO;
require APR::Pool;
} else {
$MOD_PERL = 1;
require Apache;
}
}

That MOD_PERL is set is fine, after all the application runs under the mod_perl response handler Plack::Handler::Apache2. The the Apache modules are not available is fine too. After all the beauty of PSGI is that the internals of the web server are not relevant.

Thus, let's create a workaround in bin/otobo.CheckModules.pl . When checking CGI::PSGI let's pretend that we are not running under MOD_PERL. The response handler actually does the same thing when the PSGI app is loaded, https://metacpan.org/dist/Plack/source/lib/Plack/Handler/Apache2.pm.

@bschmalhofer
Copy link
Contributor Author

The "delete local" construct allows temporarily hiding an environment variable, see https://www.effectiveperlprogramming.com/2010/08/temporarily-remove-hash-keys-or-array-elements-with-delete-local/.

@bschmalhofer
Copy link
Contributor Author

A test migration targeting OTOBO 10.1.x running under Apache looked fine. Closing this issue.

bschmalhofer added a commit that referenced this issue Dec 16, 2021
When running otobo.CheckModules under Apache/mod_perl during migration.
bschmalhofer added a commit that referenced this issue Dec 16, 2021
@bschmalhofer bschmalhofer added the bug Something isn't working as intended label Dec 16, 2021
@bschmalhofer bschmalhofer added this to the OTOBO 10.1.1 milestone Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as intended
Projects
None yet
Development

No branches or pull requests

1 participant