salt icon indicating copy to clipboard operation
salt copied to clipboard

Feature request: cleanup old mine data on master

Open marek-obuchowicz opened this issue 12 years ago • 29 comments

Whenever I remove a node, master still keeps it's mine information cached and sends it to all minions. Calling salt '*' mine.flush doesn't help, as master still has old mine data from not existing nodes. Calling salt-run cache.clear_mine on master also leaves all the cached data on master unchanged.

As a manual fix, I had to go to /var/cache/salt/master/minons and manually remove directories for minions, which don't exist anymore.

marek-obuchowicz avatar Mar 20 '14 17:03 marek-obuchowicz

Are you using salt-cloud to build and destroy servers?

https://github.com/saltstack/salt/blob/develop/salt/cloud/libcloudfuncs.py#L360

This is what I use (still needs to be fully documented) but if you have flush_mine_on_destroy: True in the cloud profile. Other than that, I would like to have something to just remove old mines as well.

gtmanfred avatar Mar 20 '14 17:03 gtmanfred

flush_mine_on_destroy: True works fine, thanks for the tip, didn't find it in the docs. I'm leaving issue open, as removing old mine data still seems helpful.

marek-obuchowicz avatar Mar 20 '14 17:03 marek-obuchowicz

This would be very useful, thanks!

basepi avatar Mar 24 '14 22:03 basepi

Ran into this and I thought it was strange that the master wouldn't expire mine data from non-existent minions. It was rather puzzling until I found this and saw that others encountered the same thing.

donnlee avatar Jun 26 '14 23:06 donnlee

Workaround that I use from within a state that sets up my salt-masters:

remove_stale_mine_data:
  cmd.run:
    - name: >
        find /var/cache/salt/master/minions/ -type f -name mine.p
        ! -newermt '-90 min' -exec bash '-c' 'rm -rf "$(dirname "{}")"' ';'

wt avatar Jun 27 '14 00:06 wt

Nice, thanks for the workaround!

basepi avatar Jun 27 '14 16:06 basepi

FWIW, I set my mine_interval at 60. So this means that files are only purged after 1.5x the interval. Salt should probably have similar logic in the master.

wt avatar Jul 01 '14 18:07 wt

Ran into the same issue. I didn't destroy some servers using salt-cloud, so flush_mine_on_destroy didn't work of course.

@marek-obuchowicz: Thanks for the workaround, that did the trick for me...

dansoap avatar Jan 21 '15 21:01 dansoap

Is there a reason not to just default that option to True? Seems like it'd be an strange default to keep the mine data.

wt avatar Jan 21 '15 22:01 wt

@wt You mean flush_mine_on_destroy? Yes, it does seem like True is a saner default there. I'll have to ask around for potential pitfalls there.

basepi avatar Jan 23 '15 23:01 basepi

@basepi ack

wt avatar Jan 24 '15 00:01 wt

For what it's worth, mine data being removed when salt-cloud destroyed a minion is what I expected. Ended up at this issue trying to figure out why that wasn't happening.

tkent-xetus avatar May 09 '15 01:05 tkent-xetus

@wt thanks for your example, I created a runner based on it over at salt-mine-refresh that can be called from events, scheduled, etc

rikonor avatar May 31 '15 19:05 rikonor

:+1: for this feature, it can cause some weird issues for formulas which relies on this information like HDFS

jgmchan avatar Jul 15 '15 05:07 jgmchan

Yea I can't use salt-cloud to destroy and just assumed when salt-key -d was used it would cleanup mine. Thought it was a bug. Workaround from @wt works for me, but wished it was automatic.

BretFisher avatar Jul 30 '15 04:07 BretFisher

I used salt-cloud to destroy an instance with flush_mine_on_destroy: True in salt 2015.5.3 and the data was left behind.

༼ ༎ຶ ෴ ༎ຶ༽

timcharper avatar Oct 27 '15 15:10 timcharper

I'd like to add my vote for this feature. It seems more like a bug fix to me though. I'm not the most advanced user, but I can't think of a scenario where keeping the mine data for deleted nodes by default would be expected behavior.

Can we at least get some doc updates about the current behavior? I'm finding myself having to look at GitHub issues and source code instead of the docs very frequently to get a handle on the actual way that SaltStack functions, which is unfortunate.

imchairmanm avatar Oct 28 '15 22:10 imchairmanm

I'm going to look into possibly adding this for Boron. No promises, though, I've assigned myself too much work for Boron already. ;)

basepi avatar Oct 29 '15 21:10 basepi

Thanks @basepi! I ran into this earlier today and while it was diagnosed fairly quickly, it certainly didn't seem like intended/expected functionality. I personally expected a minion's cached data to get deleted once their key is revoked. Even some sort of sync or refresh functionality for the master's cache would work I suppose.

Dravu avatar Oct 29 '15 21:10 Dravu

+1 I also thought this would be the default behaviour. Looking forward to get this feature in the next release.

danlsgiga avatar Feb 04 '16 19:02 danlsgiga