Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing progress with 'salt' command #46665

Open
kfdm opened this issue Mar 22, 2018 · 54 comments
Open

Showing progress with 'salt' command #46665

kfdm opened this issue Mar 22, 2018 · 54 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Milestone

Comments

@kfdm
Copy link
Contributor

kfdm commented Mar 22, 2018

One very minor advantage Ansible has for new users is that when you run a command, ansible-playbook it gives you progress about what steps are executing.

If you run the command on the minion side with salt-call, you can get some general output by adding -l info though it's a touch noisy if you don't know what you're looking for.

If you add state_events: True to your master configuration, then you can view the general progress by running salt-run state.events though this can also be a touch noisy.

If you run salt ... there is only the final report when everything is finished.

What would it take to be able to more easily watch the progress of a running state? Is this something that would make sense as an extension to the salt command or perhaps building it as a salt-run command would be better.

The local client provides a cmd_async command that returns a jobid which could be used to filter events

  • salt/job/<JID>/new
  • salt/job/<JID>/ret/<MID>
  • salt/job/<JID>/prog/<MID>/<RUN NUM>
    though perhaps there is a slight delay between getting the jid from cmd_async and being able to subscribe to salt.modules.state.event

Are there perhaps any other race conditions that one would need to be aware of?

Copied from: https://groups.google.com/d/msgid/salt-users/afa89988-d358-40de-a451-9417bdb90206%40googlegroups.com.

@garethgreenaway
Copy link
Contributor

@kfdm Thanks for the report. There is a progress out put module that can be used to show some progress during a Salt calls. It requires that the python progressbar library is installed where you're running Salt, eg. on the master.
https://docs.saltstack.com/en/latest/ref/output/all/salt.output.progress.html#module-salt.output.progress

Real time output from the minion is tricky since they don't return their output to the master until the run has completed.

@garethgreenaway garethgreenaway added this to the Blocked milestone Mar 22, 2018
@garethgreenaway garethgreenaway added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Mar 22, 2018
@kfdm
Copy link
Contributor Author

kfdm commented Mar 23, 2018

--progress is one way to show that the command is still running, but I'm curious about what it would take to show more details about what is running. Unlike ansible the commands are not run in sync (some minions will finish before others) but for a proof-of-concept I'm not worried about that.

While it would require state_events: True to be set, my initial brainstorm was something similar to this

salt '*' state.apply
salt/job/<JID>/prog/A/1 file.manage /path/to/foo
salt/job/<JID>/prog/B/1 file.manage /path/to/foo
salt/job/<JID>/prog/A/2 service.running bar
salt/job/<JID>/prog/A/3 service.running baz
salt/job/<JID>/prog/B/2 service.running bar
...
Normal output.highstate

Perhaps I should try a quick implementation as a salt runner to test this idea a bit more.

@kedare
Copy link

kedare commented Jun 17, 2018

I confirm this is more than needed.
We have some huge highstate (and on Windows...) that can take between 30 minutes and 1h to apply, it's very frustrating to not have any progress report

@dbernadett
Copy link

I have the same need.

@Oloremo
Copy link
Contributor

Oloremo commented Sep 14, 2018

+1

@adam12b1
Copy link

adam12b1 commented Sep 26, 2018

+1! And I would say, even within the current architectural constraints on getting realtime data back from minions, it would still be better than nothing to at least have a "Now running [state] on [target]..." or similar update from the Salt master as it moves through its work... although, hm, I guess that's still currently only known on the minion, eh?

@Mapel88
Copy link
Contributor

Mapel88 commented Oct 18, 2018

+1

1 similar comment
@bmaeck
Copy link

bmaeck commented Oct 19, 2018

+1

@pthirumalachar
Copy link

+1. + if this could report not only the state transitions, but could also capture the STD outs/warning of the underlying processes being run, is very much needed. And having the ability to list only the delta output would be very helpful

@digitalformula
Copy link

+1

@damon-atkins
Copy link
Contributor

The minion is polled to see if the job is running. But it does not return where it is up to. state_events: True is most likely the best way. You can push event onto slack or similar as well.

@digitalformula
Copy link

The minion is polled to see if the job is running. But it does not return where it is up to. state_events: True is most likely the best way. You can push event onto slack or similar as well.

Out of interest - how difficult would it be to add some sort of progress bar? I understand that there are reasons why SaltStack doesn't do that now, and that's 100% fine, but if there was a command line switch that showed something as simple as "Running state 3/17", that would be huge.

salt-call state.apply blender.install --progress

My use case is the cloning of source from Github, which then needs to be built (Blender, specifically). I've got it all working without issue but there's zero output until the end, when the state application has either succeeded or failed.

@damon-atkins
Copy link
Contributor

find_job response should lead to how many minions are working on it.

@tdonovic
Copy link

tdonovic commented Jan 8, 2019

+1 States (when im testing) and cant see why the state times out until 20 min later is really slowing things up. Being able to tail the logs to the master that executed the state would make my life incredibly easy

@amunoz951
Copy link

+1 - we have salt-calls that can take hours and it's extremely helpful to see stdout in realtime

@BeehiveSystems
Copy link

+1 - we have salt-calls that can take hours and it's extremely helpful to see stdout in realtime

Same here, this would be a very useful feature.

@nsu700
Copy link

nsu700 commented May 21, 2019

+1 , get used to the ansible progress output, and find it not safe enough to run a salt script without any progress and eventually throw me an error, killing me

@gigi206
Copy link

gigi206 commented Jun 19, 2019

+1

@rawkode
Copy link
Contributor

rawkode commented Sep 12, 2019

I'd love it if we could get real-time output when using salt-call --local.

Could this be implemented?

@klelifo
Copy link

klelifo commented Oct 11, 2019

+1

@damon-atkins
Copy link
Contributor

find_job response should lead to how many minions are working on it. Maybe even return the number of states completed.

@stale
Copy link

stale bot commented Jan 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jan 7, 2020
@Oloremo
Copy link
Contributor

Oloremo commented Jan 7, 2020

not stale

@stale
Copy link

stale bot commented Jan 7, 2020

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Jan 7, 2020
@stale
Copy link

stale bot commented Feb 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Feb 6, 2020
@stale
Copy link

stale bot commented Mar 8, 2020

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Mar 8, 2020
@KevoSoftworks
Copy link

KevoSoftworks commented Mar 12, 2020

+1 We have a number of systems with high resource usage peaks Being able to monitor the progress of applying states would benefit our workflow during these periods.

@theunsa
Copy link

theunsa commented May 21, 2020

+1 fwiw

@hemantaltair
Copy link

+1 otherwise it's very difficult to go on a minion and check logs which is not practical when you have 1000 of infrastructure.

@SJay3
Copy link

SJay3 commented Aug 5, 2020

+1 We need a progress for salt

@sagetherage sagetherage modified the milestones: Blocked, Approved Aug 13, 2020
@sagetherage sagetherage added Feature new functionality including changes to functionality and code refactors, etc. and removed Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged labels Aug 13, 2020
@MalloZup
Copy link
Contributor

+1

1 similar comment
@network-shark
Copy link
Contributor

+1

@alexkolomolo
Copy link

+999 This is really needed for anyone wanting to use salt seriously to manage their infra.

@amunoz951
Copy link

amunoz951 commented Dec 11, 2020 via email

@dmulyalin
Copy link

+1

Thoughts: might be possible to listen to events on master and write salt execution module in a way that logs will be emitted on event bus or fire events explicitly throughout module execution to indicate the progress. At the same time having a runner running on salt master to listen to this events or an output module that will be listening to such an events showing the progress.

IMHO, capability to subscribe to such progress events using Job ID sounds as useful feature as well.

@xyzst
Copy link

xyzst commented Apr 14, 2021

Would like to add my interest for this feature. I have a long running job on a minion, and I have to manually check the minion itself if the job has stalled or not.

@auphofBSF
Copy link

I Have observed in minion tail target-logs -f and journalctl -f rich sources of logging that could be useful in providing a more automated progress feedback., is there any work current or in planning at Saltstack to provide some progress reporting in running a particular salt state

I often find my salt-ssh <target> state.apply <some state> failing with what seems like an ssh timeout. however I have been able to monitor the to see the state.apply is still functioning, utilizing logs and journalctl

The following is a typical response I get , which is not very helpful

# Response from salt-ssh during a long running state
[ERROR   ] JSON Render failed for:
Connection to <target> closed by remote host.
[ERROR   ] Expecting value: line 1 column 1 (char 0)

@sticky-note
Copy link

sticky-note commented Sep 29, 2022

+ 1 to have this kind of real time reporting feature in SaltStack

@raqua
Copy link

raqua commented Oct 5, 2022

This is needed!

@Jibun-no-Kage
Copy link

THIS IS NEEDED!

@oijkn
Copy link

oijkn commented Nov 23, 2022

I use Gitlab-ci to deploy projects with Saltstack but effectively the real time events is missing. When the state.apply finished, then the full report appears.

Can you add this feature please?

@damon-atkins
Copy link
Contributor

The first step is the salt-minion to record more information in the job file. I think it would need a SEP.

@damon-atkins
Copy link
Contributor

damon-atkins commented Nov 27, 2022

What information do people want?
X/28 tasks complete
Or
List of all task ID and status e.g. Running/InProgress, Stable/Same/Identical, Changed/Mocked, Skipped, Failed

I do not think it should output the full data, however if it did then the user could control how much is displayed. However it would increase overhead.

@alexkolomolo
Copy link

alexkolomolo commented Nov 27, 2022 via email

@oijkn
Copy link

oijkn commented Dec 1, 2022

What is the X/28 tasks complete?

@floridop
Copy link

Hi and thanks for looking into this. It is one of my main reasons to use ansible instead on machines that can be reached directly via ssh.

It would be nice to have something like
machineX/stateY status

At least printed out when states have been completed or failed or anything, however they did

It would of course be nicer to know which task in the state is being processed, but for me is more about debugging in that case.

@winternet-studio
Copy link

winternet-studio commented May 11, 2023

This is definitely needed. Why aren't the devs picking up on this?

What information do people want? X/28 tasks complete Or List of all task ID and status e.g. Running/InProgress, Stable/Same/Identical, Changed/Mocked, Skipped, Failed

Not jut the number of tasks completed, but like an event log for each task that is being done. Output should include the minion name, the current task ID that is running, the time stamp, the event type (started/finished/failed/etc) and maybe a few other key information that could be available and useful. It should be sort of an abbreviated version of the report that is shown after the command is complete - but should all fit in one line per event. I guess that line could even include "task X of 28" (for the given minion) in abbreviated format "X/28", to show the total progress.

Best would be to see this on the salt master where the command is executed, but even if I would have to run a command on the minions to see this info I would be very happy. Even if we would simply need to just do a tail -f on a log file I would be exhilarated!! Seems like writing to a log file at least would be something very easy to implement!

@raqua
Copy link

raqua commented May 11, 2023

I hacked the log myself hooking to the events, so this is how it looks. That is what I would like it to look.

13:36:33 Starting Salt...
13:36:33 Started at: Tue May  9 13:36:33 CEST 2023
13:36:33 
13:36:41 Preparing ...
13:36:59    1/396       dev --> Install Nginx
13:36:59    2/396       dev --> Setup Nginx configuration file
13:37:00    3/396       dev --> Setup Exite configuration file for Nginx
13:37:00    4/396       dev --> Setup main.key for Nginx
13:37:00    5/396       dev --> Setup main.crt for Nginx
13:37:01    6/396       dev --> Setup Inbound.xsl for Nginx
13:37:01    7/396       dev --> Setup Outbound.xsl for Nginx
13:37:01    8/396       dev --> Setup inbound-outbound.xsd for Nginx
13:37:01    9/396       dev --> Start Nginx
13:37:02   10/396       dev --> Install Haproxy
13:37:02   11/396       dev --> Setup haproxy configuration file
13:37:02   12/396       dev --> Set up exite.pem certificate for haproxy
13:37:02   13/396       dev --> Ensure Haproxy is running
13:37:02   14/396       dev --> Ensure Haproxy is running
13:37:03   15/396       dev --> Ensure "tree" package is installed
13:37:03   16/396       dev --> Cron job that removes old log files
13:37:03   17/396       dev --> Ensure there is no hourly triggered log rotation
13:37:03   18/396       dev --> Ensure there is no daily triggered log rotation
13:37:03   19/396       dev --> Remove old log rotation for containers logs
13:37:04   20/396       dev --> Add default Linux log rotation caller and logger script
13:37:04   21/396       dev --> Cron job that will trigger default Linux log rotation on exact time
13:37:04   22/396       dev --> Add log rotation caller and logger script
13:37:04   23/396       dev --> Cron job that will trigger log rotation on exact time
13:37:04   24/396       dev --> Install bind
13:37:05   25/396       dev --> Setup Bind configuration file
13:37:05   26/396       dev --> Setup Bind internal overrides zone file
13:37:06   27/396       dev --> Install Java
13:37:06   28/396       dev --> Start docker
13:37:06   29/396       dev --> Installing Docker python module
13:37:06   30/396       dev --> Add startDockers.sh script
13:37:06   31/396       dev --> Ensure Jenkins user exists
.....

My solution has some issues, namely that it only shows what was already finished and not what goes on and that the number of expected events are only guessed based on previous run, which is highly incorrect and only makes sense if one does test run before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

No branches or pull requests