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

[BUG] divisionerror & assignments.html stacktrace on new installs with no hosts/schedules defined #532

Closed
sadsfae opened this issue Sep 27, 2024 · 2 comments

Comments

@sadsfae
Copy link
Member

sadsfae commented Sep 27, 2024

On fresh quads-dev-2.1.0-20240926.noarch with no hosts created there is an initial stacktrack of quads-web:

Sep 27 13:22:11 host-03 gunicorn[2723]: Traceback (most recent call last):
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
Sep 27 13:22:11 host-03 gunicorn[2723]:     response = self.full_dispatch_request()
Sep 27 13:22:11 host-03 gunicorn[2723]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
Sep 27 13:22:11 host-03 gunicorn[2723]:     rv = self.handle_user_exception(e)
Sep 27 13:22:11 host-03 gunicorn[2723]:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
Sep 27 13:22:11 host-03 gunicorn[2723]:     rv = self.dispatch_request()
Sep 27 13:22:11 host-03 gunicorn[2723]:          ^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
Sep 27 13:22:11 host-03 gunicorn[2723]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
Sep 27 13:22:11 host-03 gunicorn[2723]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/quads/web/app.py", line 175, in assignments
Sep 27 13:22:11 host-03 gunicorn[2723]:     daily_utilization = cloud_operation.get_daily_utilization()
Sep 27 13:22:11 host-03 gunicorn[2723]:                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:22:11 host-03 gunicorn[2723]:   File "/usr/lib/python3.12/site-packages/quads/web/controller/CloudOperations.py", line 60, in get_daily_utilization
Sep 27 13:22:11 host-03 gunicorn[2723]:     _daily_utilization = _schedules * 100 // _host_count
Sep 27 13:22:11 host-03 gunicorn[2723]:                          ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
Sep 27 13:22:11 host-03 gunicorn[2723]: ZeroDivisionError: division by zero

I can get past this by creating a test host and cloud:

quads --define-cloud --cloud cloud01
quads --define-host --host testhost01 --host-type general --model R630 --default-cloud cloud01

Then I hit another issue in that wiki/assignments.html is not being rendered.

Sep 27 13:27:02 host-03 gunicorn[2787]: Traceback (most recent call last):
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
Sep 27 13:27:02 host-03 gunicorn[2787]:     response = self.full_dispatch_request()
Sep 27 13:27:02 host-03 gunicorn[2787]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
Sep 27 13:27:02 host-03 gunicorn[2787]:     rv = self.handle_user_exception(e)
Sep 27 13:27:02 host-03 gunicorn[2787]:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
Sep 27 13:27:02 host-03 gunicorn[2787]:     rv = self.dispatch_request()
Sep 27 13:27:02 host-03 gunicorn[2787]:          ^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
Sep 27 13:27:02 host-03 gunicorn[2787]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
Sep 27 13:27:02 host-03 gunicorn[2787]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/quads/web/app.py", line 179, in assignments
Sep 27 13:27:02 host-03 gunicorn[2787]:     return render_template(
Sep 27 13:27:02 host-03 gunicorn[2787]:            ^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/templating.py", line 149, in render_template
Sep 27 13:27:02 host-03 gunicorn[2787]:     template = app.jinja_env.get_or_select_template(template_name_or_list)
Sep 27 13:27:02 host-03 gunicorn[2787]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/jinja2/environment.py", line 1084, in get_or_select_template
Sep 27 13:27:02 host-03 gunicorn[2787]:     return self.get_template(template_name_or_list, parent, globals)
Sep 27 13:27:02 host-03 gunicorn[2787]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/jinja2/environment.py", line 1013, in get_template
Sep 27 13:27:02 host-03 gunicorn[2787]:     return self._load_template(name, globals)
Sep 27 13:27:02 host-03 gunicorn[2787]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/jinja2/environment.py", line 972, in _load_template
Sep 27 13:27:02 host-03 gunicorn[2787]:     template = self.loader.load(self, name, self.make_globals(globals))
Sep 27 13:27:02 host-03 gunicorn[2787]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/jinja2/loaders.py", line 126, in load
Sep 27 13:27:02 host-03 gunicorn[2787]:     source, filename, uptodate = self.get_source(environment, name)
Sep 27 13:27:02 host-03 gunicorn[2787]:                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/templating.py", line 65, in get_source
Sep 27 13:27:02 host-03 gunicorn[2787]:     return self._get_source_fast(environment, template)
Sep 27 13:27:02 host-03 gunicorn[2787]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 27 13:27:02 host-03 gunicorn[2787]:   File "/usr/lib/python3.12/site-packages/flask/templating.py", line 99, in _get_source_fast
Sep 27 13:27:02 host-03 gunicorn[2787]:     raise TemplateNotFound(template)
Sep 27 13:27:02 host-03 gunicorn[2787]: jinja2.exceptions.TemplateNotFound: wiki/assignments.html

version quads-dev-2.1.0-20240926.noarch

Solution for first stack trace

  • Let's render a "No hosts defined" string in the rendered /assignments page if no hosts are defined

For the second issue something else is keeping wiki/assignments.html from being rendered.

For curiosity I created a fake future cloud and schedule but we're just not rendering / finding that file.

root@host-03:~# quads --define-cloud --cloud cloud02 --description "testiiing" --cloud-owner wfoster --cloud-ticket 12345
Assignment created.
root@host-03:~# quads --add-schedule --schedule-start "2025-09-22 22:00" --schedule-end "2025-09-25 22:00" --schedule-cloud cloud02 --schedule-cloud cloud02 --host testhost01
Schedule created
@sadsfae
Copy link
Member Author

sadsfae commented Sep 27, 2024

On a fresh quads-dev-2.1 install on a new host the RPM isn't dropping our wiki/templates into %python3_sitelib

root@host-03:~# rpm -ql quads-dev | grep .html
/usr/lib/python3.12/site-packages/quads/web/templates/_formhelpers.html
/usr/lib/python3.12/site-packages/quads/web/templates/base.html
/usr/lib/python3.12/site-packages/quads/web/templates/dropdown.html
/usr/lib/python3.12/site-packages/quads/web/templates/links.html
/usr/lib/python3.12/site-packages/quads/web/templates/modal_no_footer.html
/usr/lib/python3.12/site-packages/quads/web/templates/navbar.html

I would also expect to see these files too unless they should be dynamically generated.

[root@quads2-stage wiki]# pwd
/usr/lib/python3.12/site-packages/quads/web/templates/wiki

[root@quads2-stage wiki]# ls
assignments.html  available.html  inventory.html  vlans.html

sadsfae added a commit that referenced this issue Sep 27, 2024
* Set _daily_utilization to zero if no hosts defined (new installs)
* Fix QUADS HTML asset templates from not landing

Other small fixes:

* Remove chcon for /var/www/html
* Small clarification on seeing quads-web on first install.
* Add R660/R760 to is_supported
* Expand supported models with R660/R760 for example conf.

fixes: #532

Change-Id: I8d7cf304cf4cbd6423e49ec211f1369ccca51a98
@sadsfae
Copy link
Member Author

sadsfae commented Sep 27, 2024

Resolved in 7f94aae

@sadsfae sadsfae closed this as completed Sep 27, 2024
@sadsfae sadsfae self-assigned this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant