]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
add simple hack to work in GKE
authorDylan William Hardison <dylan@hardison.net>
Mon, 15 Oct 2018 22:51:57 +0000 (18:51 -0400)
committerGitHub <noreply@github.com>
Mon, 15 Oct 2018 22:51:57 +0000 (18:51 -0400)
Bugzilla/Quantum/Plugin/Hostage.pm

index 63fad2be24143f1e68dec258598ac9a608abe005..d9f0f218da4bf4ae114e1f333dabba36cfff78ef 100644 (file)
@@ -3,6 +3,10 @@ use 5.10.1;
 use Mojo::Base 'Mojolicious::Plugin';
 use Bugzilla::Logging;
 
+my %HEALTH_CHECK_UA = (
+  "GoogleHC/1.0" => 1,
+);
+
 sub _attachment_root {
   my ($base) = @_;
   return undef unless $base;
@@ -40,9 +44,15 @@ sub _before_routes {
   my $req   = $c->req;
   my $url   = $req->url->to_abs;
 
-  return if $stash->{'mojo.static'};
-
   my $hostname = $url->host;
+
+  my $ua = $req->headers->user_agent;
+  if ($ua && $HEALTH_CHECK_UA{ $ua }) {
+    $c->render(text => "Hello, $ua, I am healthy.", status => 200);
+    return;
+  }
+
+  return if $stash->{'mojo.static'};
   return if $hostname eq $urlbase_host;
 
   my $path = $url->path;