Giter Club home page Giter Club logo

Comments (1)

r-chris avatar r-chris commented on September 26, 2024

I realise this is a fairly old issue, but I have just made an interesting (for me) observation here. Before I get to my experience, allow me to say that you should provide a log of your pod (assuming this was deployed to Kubernetes) to determine the actual error that caused the "Error 500" reply. You could get that log by doing something like: kubectl logs -f azure-vote-front-USE_YOUR_POD_NAME_HERE which in my case showed this:

[2020-07-28 11:26:34,930] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./main.py", line 57, in index
    vote1 = r.get(button1).decode('utf-8')

Looking at the code here: https://github.com/Azure-Samples/azure-voting-app-redis/blob/master/azure-vote/azure-vote/main.py#L57 we can assume that for some reason r.get(button1) returns None.

Technically, this means that there is no entry in Redis with the key button1 (which equals "Cats" in the default configuration: https://github.com/Azure-Samples/azure-voting-app-redis/blob/master/azure-vote/azure-vote/config_file.cfg#L3)

Why would there be no entry in Redis? After all this line if not r.get(button1): r.set(button1,0) initiallized those values with something: https://github.com/Azure-Samples/azure-voting-app-redis/blob/master/azure-vote/azure-vote/main.py#L48

Turns out - in my case - I had applied the azure-vote-all-in-one-redis.yaml file, then made a change to the azure-vote-back and applied the deployment again. Since I only edited the azure-vote-back (Redis service), the front-end app (azure-vote-front) did not re-initialize, but kept running and assuming that it had in fact already initialized those Redis keys!

Therefore, the underlying issue here is, that you should either use persistent Redis storage if you want to rely upon some pre-initialized values or you should to improve the error handling in those situation. Now I realize this is only a sample app without those considerations, but it would be a good follow up for a tutorial to explain why (and how) persistent storage is added for a database backend.

You could either restart the azure-vote-front pod, which will automatically re-initialize those Redis values or you could manually set them yourself (for example through an interactive shell).

from azure-voting-app-redis.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.