Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

Flask Uwsgi - Kubernetes "master disconnect"

I am running a little flask app inside my kubernetes cluster. It is there to generate batch request out of csv files.

The app consists of the gui, for user input - and the workers (HPA) - "connected" via nats/ stand messaging

the gui is currently not usable due to an uwsgi problem (i guess) which I cant seem to solve.

The mainpage / entrypage returns - as well as the /healthz and /readiness - HTTP/1.1 200 so far so good.

any other endpoint returns a 503 and following output:

00.119.0.0 - - [28/Jan/2021:14:12:32 +0000] "GET /healthz HTTP/1.1" 200 0 "-" "kube-probe/1.18" "-"
Thu Jan 28 14:12:32 2021 - uWSGI worker 1 screams: UAAAAAAH my master disconnected: i will kill myself !!!
2021-01-28 14:12:32,722 INFO exited: uwsgi (terminated by SIGKILL; not expected)
2021-01-28 14:12:32,772 INFO spawned: 'uwsgi' with pid 414
2021-01-28 14:12:32,795 INFO reaped unknown pid 412
[uWSGI] getting INI configuration from /app/uwsgi.ini
[uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini

;uWSGI instance configuration
[uwsgi]
cheaper = 2
processes = 16
ini = /app/uwsgi.ini
module = main
callable = app
ini = /etc/uwsgi/uwsgi.ini
socket = /tmp/uwsgi.sock
chown-socket = nginx:nginx
chmod-socket = 664
hook-master-start = unix_signal:15 gracefully_kill_them_all
need-app = true
die-on-term = true
show-config = true
;end of configuration

*** Starting uWSGI 2.0.18 (64bit) on [Thu Jan 28 14:12:32 2021] ***
compiled with version: 8.3.0 on 09 May 2020 21:28:19
os:  #30-Ubuntu SMP Tue Oct 20 10:06:38 UTC 2020
nodename: ***********
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /usr/src/app
detected binary path: /usr/local/bin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.8.2 (default, Apr 23 2020, 14:22:33)  [GCC 8.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55741294aa10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1239640 bytes (1210 KB) for 16 cores
*** Operational MODE: preforking ***
2021/01/28 14:12:33 [error] 11#11: *1188624 upstream prematurely closed connection while reading response header from upstream, client: 100.108.0.1, server: , request: "GET /getpageendpoint HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.sock:", host: "**********", referrer: "https://pagetitle.placeholder/"
2021-01-28 14:12:33,273 INFO reaped unknown pid 413
100.108.0.1 - USERNAME [28/Jan/2021:14:12:33 +0000] "GET /getpageendpoint HTTP/1.1" 502 560 "https://pagetitle.placeholder/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36" "213.61.145.186"
2021-01-28 14:12:34,276 INFO success: uwsgi entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x55741294aa10 pid: 414 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 414)
spawned uWSGI worker 1 (pid: 419, cores: 1)
spawned uWSGI worker 2 (pid: 420, cores: 1)
running "unix_signal:15 gracefully_kill_them_all" (master-start)...
100.119.0.0 - - [28/Jan/2021:14:12:37 +0000] "GET /readiness HTTP/1.1" 200 0 "-" "kube-probe/1.18" "-"
[pid: 420|app: 0|req: 1/1] 100.119.0.0 () {34 vars in 390 bytes} [Thu Jan 28 14:12:37 2021] GET /readiness => generated 0 bytes in 4 msecs (HTTP/1.1 200) 2 headers in 78 bytes (0 switches on core 0)

I am using the https://github.com/tiangolo/uwsgi-nginx-flask-docker image for the gui.

spec for the container:

containers:
        - name: gui
          image: myImageInMyRegistry
          imagePullPolicy: Always
          resources:
            requests:
              cpu: 100m
              memory: 80Mi
            limits:
              cpu: 500m
              memory: 100Mi
          readinessProbe:
            httpGet:
              port: 80
              path: /readiness
            periodSeconds: 10
          livenessProbe:
            httpGet:
              port: 80
              path: /healthz
            periodSeconds: 10
          ports:
            - containerPort: 80
              name: web
question from:https://stackoverflow.com/questions/65939190/flask-uwsgi-kubernetes-master-disconnect

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...