cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
11.2k stars 1.11k forks source link

metrics: remove re-login requirement for loading PCP metrics #21075

Closed jelly closed 2 weeks ago

jelly commented 4 weeks ago

With the switch to the python PCP implementation the metrics page no longer needs to re-login to load the new pcp manifest. The Python bridge will re-attempt import the PCP module and then load metrics as expected with one minor issue that uninstalling python3-pcp keeps the PCP module in memory.

jelly commented 4 weeks ago

The test failures seem to be due to a re-render which closes the metrcis dialog.

jelly commented 3 weeks ago

This is a literal cluster f*ck, there are seemingly two "races".

now we install redis
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("#metrics-header-section button.pf-m-secondary:not([disabled]):not([aria-disabled=true])"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 108]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("#metrics-header-section button.pf-m-secondary:not([disabled]):not([aria-disabled=true])"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 109]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_mouse("#metrics-header-section button.pf-m-secondary:not([disabled]):not([aria-disabled=true])","click",0,0,0,false,false,false,false)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 110]
> info: show PCP dialog
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("#pcp-settings-modal"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 111]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("#pcp-settings-modal"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 112]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("#switch-pmproxy:not(:checked)"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 113]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_visible("#switch-pmproxy:not(:checked)"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 114]
INFO:bidi.command:→ {'realm': '3513036822434277294.-241120618329685527', 'result': None, 'type': 'success'}
INFO:bidi.command:← script.evaluate({'expression': 'ph_wait_cond(() => ph_is_present("#switch-pmproxy:not([disabled]):not([aria-disabled=true])"), 15000, null)', 'awaitPromise': True, 'target': {'context': '7FFA2352A90AFCF212B31BC0976BBF8D'}}) [id 115]
> info: close in save false
> debug: console.trace
> info: Object(4)
Traceback (most recent call last):
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/./test/verify/check-metrics", line 1360, in testBasic
    b.click("#switch-pmproxy")
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 576, in click
    self.mouse(selector + ":not([disabled]):not([aria-disabled=true])", "click")
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 507, in mouse
    self.wait_visible(selector)
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 815, in wait_visible
    self._wait_present(selector)
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 806, in _wait_present
    self.wait_js_func('ph_is_present', selector)
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 800, in wait_js_func
    self.wait_js_cond("%s(%s)" % (func, ','.join(map(jsquote, args))))
  File "/home/jelle/projects/cockpit/pcp-drop-re-login/test/common/testlib.py", line 797, in wait_js_cond
    raise Error(f"timeout\nwait_js_cond({cond}): {last_error.msg}") from None
testlib.Error: timeout
wait_js_cond(ph_is_present("#switch-pmproxy:not([disabled]):not([aria-disabled=true])")): Error: condition did not become true

Here the dialog is closed for some mysterious reason. We aren't clicking on the save button, so how did we end up logging close in save.

We do get a close not-supported message from the bridge, which re-renders, the metrics history pane but that should not have an influence?

jelly commented 3 weeks ago

Firefox seems to keep failing.

martinpitt commented 2 weeks ago

I can completely reliably reproduce the firefox error (albeit not with TEST_SHOW_BROWSER). Interactively, I see that the tooltip stays around for maybe 0.2s after moving the mouse away from it, and with some practice I mange to click on the config button to open the dialog. But it always goes away. In that failing test, the tooltip stays around forever. :exploding_head: This is a fun PF bug..

I fined-tuned your hack so that it actually works.

jelly commented 2 weeks ago

Also good to merge from my side :)