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

WEBUI & hasher app not going through #634

Open
eliassal opened this issue Jan 3, 2024 · 10 comments
Open

WEBUI & hasher app not going through #634

eliassal opened this issue Jan 3, 2024 · 10 comments

Comments

@eliassal
Copy link

eliassal commented Jan 3, 2024

Hi Jermoe, the videos regarding "Deploying and Scaling Microservices
with Docker and Kubernetes" are really fantastic. and I learned a lot. However, when I try to run
Docker compose up
in bitcoins directory, all containers start and work fine except the webui one which errors as follows (myabe because latest images used are not compatible with code, I am really not expert in node nor in ruby)

Hasher error

hasher-1  | == Sinatra (v3.2.0) has taken the stage on 80 for development with backup from Thin
hasher-1  | 127.0.0.1 - - [03/Jan/2024:13:00:33 +0000] "GET / HTTP/1.1" 200 31 0.0026
worker-1  | INFO:__main__:0 units of work done, updating hash counter
worker-1  | ERROR:__main__:In work loop:
worker-1  | Traceback (most recent call last):
worker-1  |   File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 203, in _new_conn
worker-1  |     sock = connection.create_connection(
worker-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1  |   File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection

then webui error

webui-1   | /node_modules/redis/dist/index.js:31
webui-1   |     ...bloom_1.default,
webui-1   |     ^^^
webui-1   |
webui-1   | SyntaxError: Unexpected token ...
webui-1   |     at exports.runInThisContext (vm.js:53:16)
webui-1   |     at Module._compile (module.js:373:25)
webui-1   |     at Object.Module._extensions..js (module.js:416:10)

Thanks for your help

@jpetazzo
Copy link
Owner

jpetazzo commented Jan 4, 2024

Hi!

I have checked the code and it should work fine without any modifications.

Regarding the worker, I suggest waiting for a few minutes to see if it reconnects automatically and succeeds. Sometimes, the end of the traceback can provide more useful information about the issue.

Similarly, for the hasher, I believe there might be additional details in the rest of the traceback that could help you understand the problem better.

@eliassal
Copy link
Author

eliassal commented Jan 4, 2024

Merci Jerome. This morning, I came across the other session at https://www.youtube.com/watch?v=broMJgUmPG8&list=PLBAFXs0YjviJwCoxSUkUPhsSxDJzpZbJd&index=49
and using the tag v0.1

kubectl create deployment rng --image=dockercoins/rng:v0.1
kubectl create deployment hasher --image=dockercoins/hasher:v0.1
kubectl create deployment worker --image=dockercoins/worker:v0.1
kubectl create deployment webui --image=dockercoins/webui:v0.1

all pods were up and running and I was able to access the webui. I tried again the docker compose up version, still getting the same errors, on ubuntu as well as Dockerdesktop on windows.
Thnaks for all thos wonderful videos you made available, ils sont vraiement utiles :-)

@eliassal
Copy link
Author

eliassal commented Jan 4, 2024

When using docker compose up version, Yes the hasher starts working after sometime but not webui

@jpetazzo
Copy link
Owner

jpetazzo commented Jan 5, 2024

Note that the webui can show some error logs, but it might still work (i.e. if you connect to it with a web browser, you will see the graph).

@conradwt
Copy link

conradwt commented Jan 5, 2024

@jpetazzo I confirm that I'm also seeing a lot of errors on startup of the various containers but things appear to work as expected from the WebUI. If I find the time this weekend, I'll try to refactor the Docker Compose.

@jpetazzo
Copy link
Owner

jpetazzo commented Jan 5, 2024

Hi!

The errors are expected :-)

This is because the various components are connecting immediately to their dependencies - for instance, worker tries to connect immediately to rng, hasher, redis, before these dependencies have started. The initial connection attempt fails (because the dependency isn't up and running yet). But there is a (very crude) retry logic, so the next connection attempt typically succeeds, and then everything is fine.

I haven't fixed the code because when I teach a class, I use this as an example, and we discuss how it can be addressed (e.g. with healthchecks, init containers, etc.)

@eliassal
Copy link
Author

eliassal commented Jan 5, 2024

@conradwt as I said, all containers start fine and can see communications between them except in my case webui which fails to start (it exits) with the error

webui-1   | /node_modules/redis/dist/index.js:31
webui-1   |     ...bloom_1.default,
webui-1   |     ^^^
webui-1   |
webui-1   | SyntaxError: Unexpected token ...

@conradwt
Copy link

conradwt commented Jan 5, 2024

@eliassal I'm not able to reproduce the issue that you're seeing and I have tried it on both my Intel and Apple Silicon MacBook Pros.

@conradwt
Copy link

conradwt commented Jan 5, 2024

@jpetazzo You make a very good point here because a distributed application tends to start its services in a nondeterministic order. I definitely need to review adding healthchecks for my K8s pods.

@eliassal
Copy link
Author

eliassal commented Jan 5, 2024

@conradwt well I cant add anything more than the error message webui is sending. If you like I can let you see the error by yourself if you accpet through a visio session :-)

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

No branches or pull requests

3 participants