Subject: pgadmin healthcheck-url

From: Wilhelm Wurzer <[email-masked]>
Date: Tue, 27 Mar 2018 13:44:23 +0200 (CEST)

Hi, 

we are using pgadmin in a docker container on aws. To ensure that the container is up and running, a healthcheck is periodically checking via http, restarting the container if neccessary. 

When checking the filesystem, we found that for each request, a session file is created. Healthcheck is done twice every 30secs, so we have about 5600 session files a day. (about 100k after a few days..)

I looked at the sourcecode and found that in session.py, line 259 it looks like cookies should not be created for static resources

-

def open_session(self, app, request): 
cookie_val = request.cookies.get(app.session_cookie_name) 

if not cookie_val or '!' not in cookie_val: 
# Don't bother creating a cookie for static resources 
for sp in self.skip_paths: 
if request.path.startswith(sp): 
return None

-

unfortunately, in __init__.py, when setting up the session interface, skip_paths is empty and so a cookie gets created also for static resources (i'm no python hacker, so maybe i'm missing something)

So my question is - is there an url that can be used for healthchecking, that does not create a session file on every check ?

thanks a lot,

Wilhelm Wurzer 
twyn group GmbH

---

From: Murtuza Zabuawala <[email-masked]>
Date: Tue, 27 Mar 2018 17:21:56 +0530

You can use '/misc/ping' route to check if pgAdmin4 is running.

Example: http://localhost:5050/misc/ping

On Success you will get,
Status code: 200
Response text: PING

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Tue, Mar 27, 2018 at 5:14 PM, Wilhelm Wurzer <[email-masked]>
wrote:

> Hi,
>
> we are using pgadmin in a docker container on aws. To ensure that the
> container is up and running, a healthcheck is periodically checking via
> http, restarting the container if neccessary.
>
> When checking the filesystem, we found that for each request, a session
> file is created. Healthcheck is done twice every 30secs, so we have about
> 5600 session files a day. (about 100k after a few days..)
>
>
> I looked at the sourcecode and found that in session.py, line 259 it looks
> like cookies should not be created for static resources
>
> -
>
> unfortunately, in __init__.py, when setting up the session interface,
> skip_paths is empty and so a cookie gets created also for static resources
> (i'm no python hacker, so maybe i'm missing something)
>
>
> So my question is - is there an url that can be used for healthchecking,
> that does not create a session file on every check ?
>
>
> thanks a lot,
>
> Wilhelm Wurzer
> twyn group GmbH
>
>

---

From: Wilhelm Wurzer <[email-masked]>
Date: Tue, 27 Mar 2018 14:24:26 +0200 (CEST)

Hi, 

thanks, but a cookie / session-file is still created: 

Request URL: http://xxx.com/misc/ping 
Request Method: GET 
Status Code: 200 OK 

Response: 
Date: Tue, 27 Mar 2018 12:17:55 GMT 
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 
Set-Cookie: pga4_session="23068f07-c448-4054-9654-95a9cf1f700f!rK2x2rU/eIy5kQqoGUU+QD8+VRo="; Expires=Wed, 28-Mar-2018 12:17:55 GMT; HttpOnly; Path=/ 

FileSystem: 

4 -rw-r--r-- 1 48 48 162 27. Mär 12:17 23068f07-c448-4054-9654-95a9cf1f700f 

best regards, 
Wilhelm Wurzer 

Von: "Murtuza Zabuawala" <[email-masked]> 
An: "Wilhelm Wurzer" <[email-masked]> 
CC: "pgadmin-hackers" <[email-masked]> 
Gesendet: Dienstag, 27. März 2018 13:51:56 
Betreff: Re: pgadmin healthcheck-url 

You can use ' /misc/ping ' route to check if pgAdmin4 is running. 

On Success you will get, 
Status code: 200 
Response text: PING 

On Tue, Mar 27, 2018 at 5:14 PM, Wilhelm Wurzer < [email-masked] > wrote: 

Hi, 

- 

- 

thanks a lot, 

Wilhelm Wurzer 
twyn group GmbH

---

From: Murtuza Zabuawala <[email-masked]>
Date: Tue, 27 Mar 2018 18:00:27 +0530

What is the pgAdmin4 version?

On Tue, Mar 27, 2018 at 5:54 PM, Wilhelm Wurzer <[email-masked]>
wrote:

> Set-Cookie: pga4_session="23068f07-c448-4054-9654-95a9cf1f700f!rK2x2rU/eIy5kQqoGUU+QD8+VRo=";
> Expires=Wed, 28-Mar-2018 12:17:55 GMT; HttpOnly; Path=/
>
> FileSystem:
>
> ------------------------------
> *Von: *"Murtuza Zabuawala" <[email-masked]>
> *An: *"Wilhelm Wurzer" <[email-masked]>
> *CC: *"pgadmin-hackers" <[email-masked]>
> *Gesendet: *Dienstag, 27. März 2018 13:51:56
> *Betreff: *Re: pgadmin healthcheck-url
>
>> I looked at the sourcecode and found that in session.py, line 259 it
>> looks like cookies should not be created for static resources
>>
>> -
>>

---

From: Murtuza Zabuawala <[email-masked]>
Date: Tue, 27 Mar 2018 20:10:35 +0530

I'm not able to re-produce the behaviour when using browser.

- Could you let us know the exact steps to re-produce the issue?
- How did you trigger http request to hit '/ping' url?

On Tue, Mar 27, 2018 at 6:05 PM, Wilhelm Wurzer <[email-masked]>
wrote:

> From the about dialog:
>
> Version 2.1
> Python Version 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623
> (Red Hat 4.8.5-16)]
> Flask Version 0.11.1
>
> Wilhelm Wurzer
>
> *Gesendet: *Dienstag, 27. März 2018 14:30:27

---

From: Wilhelm Wurzer <[email-masked]>
Date: Wed, 28 Mar 2018 06:17:40 +0200 (CEST)

Hi, 

i did the test in the browser (chrome), but it can as well be reproduced using "curl". The logging ('-v') shows that the session cookies is sent with the response. 

[ec2-user@ip-10-0-7-174 ~]$ curl -v http://10.0.7.174:8084/misc/ping 

* Trying 10.0.7.174... 
* TCP_NODELAY set 
* Connected to 10.0.7.174 (10.0.7.174) port 8084 (#0) 
> GET /misc/ping HTTP/1.1 
> Host: 10.0.7.174:8084 
> User-Agent: curl/7.53.1 
> Accept: */* 
< HTTP/1.1 200 OK 
< Date: Wed, 28 Mar 2018 04:13:14 GMT 
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 
< Set-Cookie: pga4_session="3fe44565-2f57-49f0-8674-df6f710fae07!kHKTBGuk+SBKUy+TN2r6XlAyKAI="; Expires=Thu, 29-Mar-2018 04:13:14 GMT; HttpOnly; Path=/ 
< Content-Length: 4 
< Content-Type: text/html; charset=utf-8 
< 
* Connection #0 to host 10.0.7.174 left intact 
PING 

Wilhelm Wurzer 

Gesendet: Dienstag, 27. März 2018 16:40:35 

On Tue, Mar 27, 2018 at 6:05 PM, Wilhelm Wurzer < [email-masked] > wrote: