missing=True does not work if I use external job caches solution PostgreSQL DB

47 views
Skip to first unread message

ARUN KUMAR PRAJAPATI

unread,
Jan 29, 2025, 11:48:39 PMJan 29
to Salt-users
Hi All,

I am using the custom returner postgres to store job caches, salt-returns and salt-events. in PostgreSQL database.

I fire a command in --async mode and get a JID. Now to track the progress of the JID I use salt-run jobs.lookup_jid <JID> --missing=True
I expect it should return me "minion did not return" for those who have not yet returned. But it's not happening. It did not return anything for the minions who have not yet returned.
This functionality works fine when I remove the postgrsSQL DB returner configuration and start using the local job cache.

Did anyone have faced this issue? or having any Idea how I can make --missing=True working while using external job caches PostgreSQL.

Thanks.

Phipps, Thomas

unread,
Jan 30, 2025, 12:15:28 PMJan 30
to salt-...@googlegroups.com
you need to implement the save_minions function in order for the minion information about what minions should return to show.

since this is your own custom postgres returner i assume you started with the internal one and made changes to it. the default one has a save_minions function but it doesn't actually do anything.

look to local cache for how it handles prep_jid and save_minions

prosgres just returns the jid in pre_jid. while local_caceh actually builds a data structure to save info in.
save_minions in local_cache actually saves information about the minions. while in postgres it does nothing.

basically look where local_cache is saving information and update your postgres to do the same.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/salt-users/297713fa-4eda-462b-a0f4-96a5ddca126fn%40googlegroups.com.

Sid Young

unread,
Jan 30, 2025, 2:57:44 PMJan 30
to Salt-users
If you are trying to track the progress, and you are initiating the job from the CLI then add state_events=true, this will send you progress events which I suspect would be captured by the returner and saved, if not, you could easily capture these and save them yourself.

I wrote my owner Event Returner to capture and save highstate job progress to the master's file system in /data/highstate/<minion_id>/<JID> I then get a JSON file for each step of the job, 

Sid

[root@salt wp-ha]# ls -la /data/highstate/wp-haproxy-01.xxxx/
total 12
drwxr-xr-x.  5 salt salt   90 Jan 30 15:39 .
drwxr-xr-x. 21 salt salt 8192 Jan 30 15:33 ..
drwxr-xr-x.  2 salt salt  135 Jan 30 15:33 20250130053323804932
drwxr-xr-x.  2 salt salt  135 Jan 30 15:37 20250130053733017313
drwxr-xr-x.  2 salt salt  135 Jan 30 15:39 20250130053933926931
[root@salt wp-ha]# ls -la /data/highstate/wp-haproxy-01.xxxx/20250130053933926931
total 36
drwxr-xr-x. 2 salt salt  135 Jan 30 15:39 .
drwxr-xr-x. 5 salt salt   90 Jan 30 15:39 ..
-rw-r--r--. 1 salt salt  614 Jan 30 15:39 0.json
-rw-r--r--. 1 salt salt  582 Jan 30 15:39 1.json
-rw-r--r--. 1 salt salt  570 Jan 30 15:39 2.json
-rw-r--r--. 1 salt salt  563 Jan 30 15:39 3.json
-rw-r--r--. 1 salt salt  605 Jan 30 15:39 4.json
-rw-r--r--. 1 salt salt  676 Jan 30 15:39 5.json
-rw-r--r--. 1 salt salt 1057 Jan 30 15:39 6.json
-rw-r--r--. 1 salt salt  626 Jan 30 15:39 7.json
-rw-r--r--. 1 salt salt   57 Jan 30 15:39 .progress
[root@salt wp-ha]# cat /data/highstate/wp-haproxy-01.xxxx/20250130053933926931/.progress
0|8|12
1|8|25
2|8|38
3|8|50
4|8|62
5|8|75
6|8|88
7|8|100
[root@salt wp-ha]#

The output file for this minion only has 8 state files  to run at this stage (in development), progress is from 0-7 and each step is 12% progress.

Sid

ARUN KUMAR PRAJAPATI

unread,
Feb 4, 2025, 2:57:54 AMFeb 4
to Salt-users
Thanks, this is a good idea. I will try it.

ARUN KUMAR PRAJAPATI

unread,
Feb 4, 2025, 3:35:34 AMFeb 4
to Salt-users
Thanks for your suggestions. 
Just to clarify, I was using the default postgres returner which comes with Salt pkg.

I went through the local_cache returner to understand how it stores the minion IDs that are supposed to return for a job.
Based on that I have developed a function in postgres returner that can collect the expected minion IDs for a job.
Currently, I have built my own postgres custom returner with the minion collection function which working as expected with missing=true.

I wanted to know if there is any plan to have this enhancement to the default postgres returner which comes with Salt pkg?

Phipps, Thomas

unread,
Feb 4, 2025, 4:46:59 PMFeb 4
to salt-...@googlegroups.com
very doubtful. there isn't a lot of call for the postgres master_job_cache. and no business need for it. and since the core team has been shrunk significantly the team is focusing mostly on business needs first.

that being said. you can always add a PR yourself to the github. it is open source after all.

ARUN KUMAR PRAJAPATI

unread,
Feb 7, 2025, 10:20:50 PMFeb 7
to salt-...@googlegroups.com
Thank you for your response.
Yes, I will raise a PR to the GitHub.

Reply all
Reply to author
Forward
0 new messages