RFC: proposed fix for multiple fileserver updates in masterless runs #34048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #30100.
salt.fileclient.get_file_client()
creates a new fileclient each time it is invoked. When theLocalClient
is being used (as happens in masterless runs), the instantiation of a new FSChan results in a fileserver update being performed.After investigating, I noticed that this problem has been in place as far back as the 2014.1 branch, so this is not new.
We use
salt.fileclient.get_file_client()
in a number of places, and most of them are deeper than the execution module layer, so we can't rely on the__context__
dunder to store a fileclient object for later reuse. The compromise in this PR is to drop a key into the minion opts if it is detected that we are using a local fileclient.If/when we decide to allow masterless Salt to run as a daemon, this code will need to be revisited, as it would prevent more than one fileserver update from being performed. We'd likely need to address this anyway however, since if we had a minion daemon running in masterless mode we would likely need a maintenance loop like we do in the traditional master/minion paradigm.