You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DOCS] Migrating from grains.get_or_set_hash to sdb.get_or_set_hash #62816
Description
According to the 3005 release note, grains.get_or_set_hash has been removed in favour of sdb.get_or_set_hash (#61691).
I've updated every occurrences of salt['grains.get_or_set_hash'](...) to salt['sdb.get_or_set_hash'](...) in the state tree. When applying it via sudo salt-call --local state.apply (note that I'm using salt in masterless mode), in place of the generated hash I had before, I'm now obtaining a False value.
Even the example from the documentation is failing to generate and return a value:
Another question: previously, I was sharing the grains file across the nodes of the cluster trough a glusterfs mount point in order to share data between masterless minions (master-minion model is not suitable in this specific situation); when using default sdb database (documentation is unclear if a default database even exists or if one must necessarily define one with a specific driver), where is the data-storage located?
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
Alternatively, put grains.get_or_set_hash back because it's not inherently insecure. Somebody just panicked because of the "trusting grains for key acceptance / pillar mapping" issue and deleted it.
The get-or-set logic is a bit clunky to do in jinja, but that is also an option.
As far as I'm concerned, there are two confusing aspects on this specific example:
Why is this returning the name of the key instead of the generated hash? In templating one needs the generated hash, not the querying key.
What is mymemcached, and where it is defined? As I understand it, I should setup a database in minion configuration file (@/etc/salt/minion); however, as stated in the initial report, no available driver seems to implement the .get_or_set_hash method.
Alternatively, put grains.get_or_set_hash back because it's not inherently insecure. Somebody just panicked because of the "trusting grains for key acceptance / pillar mapping" issue and deleted it.
In which version is this supposed to be available again? As of 3005.1 it still fails with
% sudo salt-call --local grains.get_or_set_hash 'SECRET_KEY' 50
'grains.get_or_set_hash' is not available.
The get-or-set logic is a bit clunky to do in jinja, but that is also an option.
Could you provide a ressource or an exemple of what you think of?
The name of an sbd profile. Most module documentation has this problem in that the actual documentation is in a guide somewhere else that it doesn't link to.
In which version is this supposed to be available again?
It isn't, that's the problem. In my opinion it should have never been removed.
Could you provide a ressource or an exemple of what you think of?
* [...] however, as stated in the initial report, no [available driver](https://docs.saltproject.io/en/latest/ref/sdb/all/index.html#sdb-modules) seems to implement the `.get_or_set_hash` method.
It is sufficient for the drivers to implement get and set, the get_or_set_hash logic is implemented in the utils module, which is used by the sdb execution module.
[...] however, as stated in the initial report, no available driver seems to implement the .get_or_set_hash method.
It is sufficient for the drivers to implement get and set, the get_or_set_hash logic is implemented in the utils module, which is used by the sdb execution module.
I agree with you @lkubb that, in theory, it should; however, in practice, it does not seem to be the case: I tried calling sdb.get_or_set_hash against a database defined with a yaml driver, and it resulted in an uncaught NotImplementedError on salt-call.
[...] I tried calling sdb.get_or_set_hash against a database defined with a yaml driver, and it resulted in an uncaught NotImplementedError on salt-call.
That's because the YAML sdb module does not implement set_:
That's because the YAML sdb module does not implement set_
I was expecting such a reason; however, my point here is that such an implementation defeats the purpose of a generic db interface: requiring manual edits in place of automatic generation is a non-sens for a database interface.
In summary, I think there are several issues reported in this thread:
grains.get_or_set_hash should be restored, and a post-mortem should conclude with the necessity of adding safeguards to prevent such breaking changes to be so casually deployed in the future.
All sdb drivers should fully implement the interface (or being tagged as not fully functional).
The documentation concerning the sdb module should be clarified: it harshly misses a generic description of how the backend works, and especially of a link to the documentation describing how to define a sdb database; then, this later page also misses a link to the list of available drivers, along with some explanation of what has been pointed-out in this thread.
Can either @OrangeDog or @hugo-ricateau provide some feedback about what action needs to be taken here from a docs perspective? I'll leave the needs-triage label on so that I take a look at this again next week.
I think that this is bigger than a docs issue. I'm going to remove the Docs label so that it will get picked up by the developer's triage process. The docs work will get picked up as a natural by-product of the development work requested here.
Is there any update on this? This issue is still happening on salt 3007, it returns the name of the key instead of the value. I can't use grains.get_or_set_hash either because it's been removed.
Reacted by Vicente Olivert Riera, Hugo Ricateau, Roman Bakaleyko and bdrx312
Activity
welcome commentedon Oct 5, 2022
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!
OrangeDog commentedon Oct 6, 2022
I already fixed that specific example in #62627.
Alternatively, put
grains.get_or_set_hashback because it's not inherently insecure. Somebody just panicked because of the "trusting grains for key acceptance / pillar mapping" issue and deleted it.The get-or-set logic is a bit clunky to do in jinja, but that is also an option.
hugo-ricateau commentedon Oct 6, 2022
Thanks for your reply @OrangeDog.
Okey, so let's analyse
As far as I'm concerned, there are two confusing aspects on this specific example:
mymemcached, and where it is defined? As I understand it, I should setup a database in minion configuration file (@/etc/salt/minion); however, as stated in the initial report, no available driver seems to implement the.get_or_set_hashmethod.In which version is this supposed to be available again? As of
3005.1it still fails withCould you provide a ressource or an exemple of what you think of?
OrangeDog commentedon Oct 6, 2022
That is still incorrect and needs further fixes.
The name of an sbd profile. Most module documentation has this problem in that the actual documentation is in a guide somewhere else that it doesn't link to.
It isn't, that's the problem. In my opinion it should have never been removed.
hugo-ricateau commentedon Oct 6, 2022
Do I need to open specific bug issues or is this one sufficient?
lkubb commentedon Oct 9, 2022
It is sufficient for the drivers to implement get and set, the get_or_set_hash logic is implemented in the utils module, which is used by the sdb execution module.
hugo-ricateau commentedon Oct 10, 2022
I agree with you @lkubb that, in theory, it should; however, in practice, it does not seem to be the case: I tried calling
sdb.get_or_set_hashagainst a database defined with ayamldriver, and it resulted in an uncaughtNotImplementedErroronsalt-call.lkubb commentedon Oct 10, 2022
That's because the YAML sdb module does not implement
set_:salt/salt/sdb/yaml.py
Lines 63 to 67 in 501e232
hugo-ricateau commentedon Oct 10, 2022
I was expecting such a reason; however, my point here is that such an implementation defeats the purpose of a generic db interface: requiring manual edits in place of automatic generation is a non-sens for a database interface.
In summary, I think there are several issues reported in this thread:
grains.get_or_set_hashshould be restored, and a post-mortem should conclude with the necessity of adding safeguards to prevent such breaking changes to be so casually deployed in the future.barbaricyawps commentedon Oct 10, 2022
Can either @OrangeDog or @hugo-ricateau provide some feedback about what action needs to be taken here from a docs perspective? I'll leave the
needs-triagelabel on so that I take a look at this again next week.barbaricyawps commentedon Oct 17, 2022
I think that this is bigger than a docs issue. I'm going to remove the Docs label so that it will get picked up by the developer's triage process. The docs work will get picked up as a natural by-product of the development work requested here.
vincent-olivert-riera commentedon May 23, 2023
Any update on this?
jbondhus commentedon Apr 14, 2024
Is there any update on this? This issue is still happening on salt 3007, it returns the name of the key instead of the value. I can't use grains.get_or_set_hash either because it's been removed.
dwoz commentedon Oct 28, 2026
Closing — consolidated into #70585. The checkbox for this item is in the appropriate theme section of that tracker. Please pick up the sub-item there.