#4551 Improve channelinfo, hosts and hostinfo - hosts status
Opened by jcupova. Modified
jcupova/koji issue-4549  into  master

Download 4551.patch

Fixes: https://pagure.io/koji/issue/4549

rebased onto 61e99a84bd38bcf77eae818bf69945bc119af559

Metadata Update from @mfilip:
- Pull-request tagged with: testing-basic

Marked testing-basic for issue tracker testing. Should be reverted after that.

Metadata Update from @mfilip:
- Pull-request untagged with: testing-basic

problematic hosts

I would move all of the logic to the index.py instead of template. So, creating computed field host['state'] should work.

 @safe_return
-def imageTag(name):
+def imageTag(name, title=None):
     """Return an img tag that loads an icon with the given name"""
     name = escapeHTML(name)
+    if not title:
+        title = name
     return '<img class="stateimg" src="%s" title="%s" alt="%s"/>' \
-           % (themePath("images/%s.png" % name), name, name)
+           % (themePath("images/%s.png" % name), title, name)

This is a safe return function in the web ui, but the newly added arg is accepted literally and not escaped. This is an XSS bug waiting to happen.

(datetime.datetime.now() - datetime.timedelta(minutes=15)).timestamp()

This seem overly complex compared to simply time.time() - 15*60.

With the current changes, the default behavior of the hosts page shows all hosts, including disabled. This is definitely not what we want.

It's an interesting idea to also handle these simulated states in the web query, but this was not part of the discussion in #4549. If we're going to do that, we should continue to honor old urls that users may have bookmarked, and we need to be able to accomplish the same selection views as before.

After looking at this in the browser, a couple things jumped out at me:

  1. the word "problem" is not very clear. Perhaps a more descriptive word like: "timeout", "offline", "stale", or "overdue". I'm going to also ask for opinions in the issue .
  2. Having just the icon is not as clear as I would like. Hover text is slow and requires user action. Perhaps text + icon for this? (Especially on the hostinfo page)

Sorting the host list by the simulated state column fails with an error.

Traceback (most recent call last):
  File "/home/mikem/Devel/koji/koji/www/kojiweb/wsgi_publisher.py", line 376, in handle_request
    result = func(environ, **data)
  File "/home/mikem/Devel/koji/koji/www/kojiweb/index.py", line 1808, in hosts
    kojiweb.util.paginateList(values, hosts, start, 'hosts', 'host', order)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikem/Devel/koji/koji/www/lib/kojiweb/util.py", line 448, in paginateList
    data.sort(key=sortByKeyFuncNoneGreatest(order), reverse=reverse)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mikem/Devel/koji/koji/www/lib/kojiweb/util.py", line 424, in internal_key
    v = obj[key]
        ~~~^^^^^
KeyError: 'state'
Metadata