latenighttales / alcali

Featureful Saltstack GUI
https://alcali.dev
MIT License
356 stars 62 forks source link

Run page is behaving incorrectly #417

Closed buffman23 closed 2 years ago

buffman23 commented 2 years ago

Describe the bug I goto Run page. I pick a target, ex: I pick a function, ex: test.ping When I hit 'Run' at the bottom of the page, a banner comes up that says: "Running salt --client=local null"

The Job returns: master: 'null' is not available.

I change nothing and click 'Run' again. The banner comes up and says: "Running salt --client=local * test.ping"

It works this time, but now all commands I run are one-command behind.

I keep the same target and change the function to grains.items. I click 'Run'. The banner says: "Running salt --client=local test.ping" even though I specified grains.items. I change nothing and click 'Run' again. The banner says: "Running salt --client=local grains.items". It works this time.

Any command I try and run, It runs the previous command I submitted.

Steps to reproduce the behavior:

  1. Go to run page
  2. Pick any target and any function
  3. Click 'Run'
  4. the function in executing command is null

Screenshots Here I run test.ping for the first time null_target

Here I change nothing and click 'Run' a second time target_worked

Here I change the function to grains.items and click 'Run' a third time. one_command_behind

Desktop:

buffman23 commented 2 years ago

The drop down for Function is also not working. When I click the drop down button nothing appears.

buffman23 commented 2 years ago

What is this.$http.get("api/functions/")? I do not know js or Vue. Is this trying to get a list of functions from the salt-api? Because it is not working on my page

buffman23 commented 2 years ago

Oh I see its a call to Django backend, not salt-api.

buffman23 commented 2 years ago

In my salt database, the salt_functions table is empty. How do I populate it?

buffman23 commented 2 years ago

So I found this page https://alcali.dev/views/settings/#parse-modules telling me how to get the auto-completion which populated salt_functions table in mysql, and now if a run a command that appears in auto-complete then the command works, but if I run a command that is not showing up in auto-complete, like "test.ping", I still get the "running one-command behind" bug.

Why do the salt test functions (ex: test.ping) not appear in the auto-complete drop down even after running Parse modules from Common Settings page? The test functions appear when I run "salt '*' sys.doc" manually.

I also think that this bug should be fixed so that if someone doesn't setup auto-complete that you can still run functions without being buggy.

buffman23 commented 2 years ago

I found out why "Parse modules" was not parsing every salt function. The gunicorn workers' default timeout is 30 seconds and the parsing job takes 143 seconds on my host, so I have to set the worker timeout with the --timeout option when starting gunicorn.

I still have the problem on the Run page of a 'null' function when I manually type a function and don't select it from the auto-complete drop-down.

buffman23 commented 2 years ago

I found the problem causing the "combobox selects previous function" bug!

v-combobox doesn't update it's v-model with user input until it loses focus.

Ex: When I enter a function then immediately click "Run" the combo-box doesn't lose focus in time, so selectedFunction doesn't update until after command is executed. When I enter a function then click another component to lose focus (or pick from drop-down), then click run, it works fine.

Here is a stackoverflow post with the same problem and a solution. https://stackoverflow.com/questions/63896901/problem-with-updating-model-in-vuetify-combobox

Could a developer please implement this to fix the bug?