latenighttales / alcali

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

Minions not listed in ui, but exists #272

Closed vskubriev closed 3 years ago

vskubriev commented 3 years ago

Describe the bug Fresh install of alcali(3000.1.0) from pip. Fresh install of salt (3001.1)

One clarification. Firefox reports an Uncaught (in promise) TypeError: Error in body stream

Expected behavior WebUI should list minions, but api/minions endpoint returns empty response. Despite http://salt/api/userssettings/1/ returns valid response.

Screenshots image image

Desktop (please complete the following information):

That's may be misconfiguration.

vskubriev commented 3 years ago

Keys page returns minion keys installed on master properly. Refresh minions is also called successfully.

image

vskubriev commented 3 years ago

Done some debug by added code like follows (used pickle):

class MinionsViewSet(viewsets.ModelViewSet):
    queryset = Minions.objects.all()

    with open('queryset.pkl', 'wb') as output:
        pickle.dump(queryset, output, pickle.HIGHEST_PROTOCOL)

    serializer_class = MinionsSerializer
    lookup_field = "minion_id"
    lookup_value_regex = "[^/]+"

    @action(detail=False, methods=["post"])
    def refresh_minions(self, request):

queryset in

class KeysViewSet(viewsets.ReadOnlyModelViewSet):
    queryset = Keys.objects.all()
    serializer_class = KeysSerializer

exists. so in web there is minions keys

queryset in MinionsViewSet is empty. There are no minions in queryset dumped in MinionsViewSet

mattLLVW commented 3 years ago

Have you used the action button and refresh all minions on the minions view?

https://alcali.dev/views/minions/

Can you please check what the network tab says?

vskubriev commented 3 years ago

Have you used the action button and refresh all minions on the minions view?

https://alcali.dev/views/minions/

Can you please check what the network tab says?

Sure. I did it many times. Suppose there are misconfiguration in setup. But network tab in browser doesn't have and issues now.

Console tab sometimes shows very strange Uncaught (in promise) TypeError: Error in body stream error. But sometimes.

Here's what I noticed additionally at minions page. After a while, errors appear on the console tab on the minions page like below:

image

I did a little research on this issue, but unfortunately cannot understand where is my issue appears. What is its reason

rosscdh commented 3 years ago

I had the same issue there is an error in the codebase.. I patched it myself will try find the fix I used this in my branch at

https://github.com/rosscdh/alcali/blob/feature/django-extensions/api/models.py#L160

will make a PR if this is interesting for anyone else (the branch above implements dango-extensions which is very useful set of helpers for auto loading models and whatnot in shell_plus also enabled runserver_plus which uses Werkzeug which is good fro debugging in dev

basically caused by the system erroring out when a bad reference to nonexisting or not expected key is made; when looping over minion results.

vskubriev commented 3 years ago

@rosscdh perfect. Thank you for a reply. It would be great to see a PR.

To be honest we chose a pip version. There is no time to redo the assembly of containers and selected flow now.

It's enough patch ?

Or Jun 13 Commits is also contain some necessary fixes of this bug?

rosscdh commented 3 years ago

Try https://github.com/latenighttales/alcali/pull/281

vskubriev commented 3 years ago

Excellent! Will wait for a maintainer.

mattLLVW commented 3 years ago

new version published.

rosscdh commented 3 years ago

You're welcome :) keep up the good work..

just noticed things get hairy with salt-syndics

ThEWiZ76 commented 3 years ago

Sorry to bump this, but just updated the docker container to latest, confirmed running Alcali version 3003.1.0, Salt master 3003 but no minions appear. I see the jobs, I have a green OK in Salt Websocket, but after refresh still no minions.

n48e0mvluevrj9
mattLLVW commented 3 years ago

Hey @ThEWiZ76 first, thanks for the sponsoring :) I just tried with the new docker image and it works on my laptop What's in your screenshot seems related only to the salt websocket.

Do you have accepted minions in your keys? Otherwise Alcali won't refresh Minions.(https://alcali.dev/views/minions/) If you still have trouble, let me know.

ThEWiZ76 commented 3 years ago

o/ I'm the guy that mailed today ;) But websocket is running fine, I have 22 active minions running on the master, with active keys. Websocket is running fine:

b91d6g44zdthtl

Jobs are showing up without an issue: b3597c4b8023be0bd478c42aa95696f6

mattLLVW commented 3 years ago

Yeah but no keys in Alcali DB! See: https://github.com/latenighttales/alcali/blob/a78052d1bb28f7a5eac467921252a92e345c90c1/api/views/alcali.py#L115-L119 maybe that's not how we should check which minions are available... Just refresh keys in the keys view, then refresh minions, and you should be fine

ThEWiZ76 commented 3 years ago

Thanks, after reviewing the code and tracing the steps I see the keys, but now I have a new issue 🙈 Refreshing the minions after seeing the keys available in the corresponding tab, still does not show the minions. I get a "minions refreshed" but no minions. After inspecting the api logging I see this. Does this give any hints? 2021-04-24 00:57:37,345 [salt.client :1095][WARNING ][19158] jid does not exist

mattLLVW commented 3 years ago

@ThEWiZ76 looking at the warning you're having it looks like a salt issue, more specifically: https://github.com/saltstack/salt/blob/2a5fd5e3e3defbb90375bafabb9f19eed180a51a/salt/client/__init__.py#L1095 it's used in event_return. how is it configured? see configuration example: https://alcali.dev/installation/#database-access-and-master-job-store-configuration