salt icon indicating copy to clipboard operation
salt copied to clipboard

KeyError in file.recurse state

Open WeLoveJesusChrist opened this issue 13 years ago • 29 comments

Hello everyone, I'm new to this forum as well as SaltStack.

So I have a few servers running SaltStack (1 Salt-Master, who is also a Salt-Minion, and the other servers are Salt Minions). I have an .sls file that install python onto all the servers upon calling the command : salt '*' state.highstate

However, on the function "file.recurse", I tell the Master to transfer all the files located under salt://mainFiles/ onto the appropriate places of all the servers (/etc /opt). When I tell each server to run their highstate command (salt 'system1' state.highstate), it is ALWAYS 100% successful. But when I run the command on all of them at the same time (salt '*' state.highstate), the file.recurse would randomly fail. It state that file.recurse failed, stating that the source file located under salt://|mainFiles/.... doesn't exist (notice the | bar right after the two forward slashes). Any help?

WeLoveJesusChrist avatar Nov 27 '13 17:11 WeLoveJesusChrist

Oh, I forgot to add. When I run it, it may fail, saying one file is missing. Then re-run it right afterward, then it says another file is missing. Sometimes, there are no failures at all! It's completely random! And yes, I made sure the files do exist. An example

Source file salt://|files/opt/ellington/ellington/chats/permissions.py not found

WeLoveJesusChrist avatar Nov 27 '13 17:11 WeLoveJesusChrist

Are you only using file_roots or are you using one of the alternative fileserver backends? Additionally, what version of salt are you running? (salt --versions-report)

basepi avatar Nov 27 '13 22:11 basepi

Hi Basepi. Sorry for the delay. Lots of things happened this passed 2 weeks so I had to put this project on hold.

"Are you only using file_roots or are you using one of the alternative fileserver backends?" I don't understand this question.. What do you mean?

Version: Salt: 0.17.2 Python: 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) Jinja2: 2.2.1 M2Crypto: 0.20.2 msgpack-python: 0.1.13 msgpack-pure: Not Installed pycrypto: 2.0.1 PyYAML: 3.10 PyZMQ: 2.2.0.1 ZMQ: 3.2.4

WeLoveJesusChrist avatar Dec 11 '13 22:12 WeLoveJesusChrist

If you can just show us your master config, that would answer my first question. =)

basepi avatar Dec 11 '13 22:12 basepi

Lol sorry basepi... I honestly am not doing this on purpose... Master config file... where is this? You don't mean the top.sls file do you?

edit: If referring to /etc/salt/master, that thing is completely commented out.

WeLoveJesusChrist avatar Dec 12 '13 06:12 WeLoveJesusChrist

Ah, thanks, /etc/salt/master was what I was wondering about.

This is a very strange issue, we'll see if we can reproduce it.

basepi avatar Dec 12 '13 16:12 basepi

Thanks. I really appreciate you guys taking the time to help me out. =) As I have stated...

salt ' * ' state.highstate causes 4 of my server having a chance of failing on the file.recurse.... salt 'mediaserver' state.highstate is 100% successful. Never an error.

It's when i tell all 4 servers to do it, that's when there is a chance of failing. But when i tell 1 specific to run, no errors...

WeLoveJesusChrist avatar Dec 12 '13 20:12 WeLoveJesusChrist

This is a weird one. Are there errors in the minion or master logs when these failures occur?

basepi avatar Dec 12 '13 23:12 basepi

I don't know the answer to that.... I am on the Salt-Master server, I run salt '*' state.highstate, and it will be printed out on my Salt-Master Server. I presume master? If I didn't answer the question, can you tell me the log's location so I may look into it? Thanks basepi, always.

WeLoveJesusChrist avatar Dec 23 '13 21:12 WeLoveJesusChrist

The logs are in /var/log/salt/master and /var/log/salt/minion

basepi avatar Dec 23 '13 23:12 basepi

thanks. It's in the Minion. The master doesn't have the error in its log.

WeLoveJesusChrist avatar Dec 24 '13 00:12 WeLoveJesusChrist

***doesn't have "that" specific error in the Master log.

WeLoveJesusChrist avatar Dec 24 '13 00:12 WeLoveJesusChrist

Do you see any errors or warnings in those logs? Just want to make sure there's not some underlying issue that's causing this.

basepi avatar Dec 26 '13 17:12 basepi

I looked into the log... there is a lot. I'm only going to give you the portion of the error/warning that occured after my last GIT update (which resolved a problem).


Cleaning up...

2013-12-10 14:10:49,801 [salt.loaded.int.render.yaml ][WARNING ] Duplicate Key: "mont1" found in salt:// environment=base 2013-12-10 14:11:13,380 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1278, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1955, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

2013-12-11 18:44:31,142 [salt.loaded.int.render.yaml ][WARNING ] Duplicate Key: "mont1" found in salt:// environment=base 2013-12-11 18:55:28,101 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1278, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1955, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

WeLoveJesusChrist avatar Dec 27 '13 21:12 WeLoveJesusChrist

Before you edited your comment, it looked as though there was a git error in your log -- was that the problem you said your git update resolved?

Also, would you mind upgrading to the recently-released 0.17.4? It looks like you may have an include bug that we have since resolved.

basepi avatar Dec 30 '13 20:12 basepi

May I ask how to do this?? Since I have already installed it using wget and curl as shown here: http://docs.saltstack.com/topics/installation/index.html

I ran it again but it is still version .17.2

WeLoveJesusChrist avatar Dec 31 '13 18:12 WeLoveJesusChrist

Oh, and just so you know, I did try yum update salt... it said it is up to date.

WeLoveJesusChrist avatar Jan 02 '14 23:01 WeLoveJesusChrist

Can you try again? 0.17.4 should have been pushed to epel stable end of last week.

basepi avatar Jan 06 '14 20:01 basepi

I have just update it and ran the state.highstate. FIrst few times it failed. Then it passed 100% twice in a row, then it failed again... I don't know, could this be a problem on my end instead of Saltstacks, basebi? Here is the Minion Log from one of my Salt-Minion server.

/var/log/salt/minion

2013-12-11 18:55:28,615 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1278, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1955, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

2013-12-12 11:37:44,402 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1278, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1955, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

2014-01-07 12:05:53,470 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1305, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1972, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

2014-01-07 12:12:06,752 [salt.state ][ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/salt/state.py", line 1305, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1655, in recurse manage_file(dest, src) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1578, in manage_file **pass_kwargs) File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed dir_mode) File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1972, in manage_file if source and source_sum['hsum'] != name_sum: KeyError: 'hsum'

WeLoveJesusChrist avatar Jan 07 '14 18:01 WeLoveJesusChrist

I get very similar errors as well even without file.recurse. If I execute a state that manages a file, it works perfectly fine when executed on one minion, but if I use a grain to target a group of minions (say the rack the hosts are in) or *, some random minions will fail with the same cryptic hsum error.

It's not physical host or vm specific from what I can tell, though I'm definitely seeing it a lot with the hadoop physical nodes I'm standing up which is really annoying.

Repeating the call to the failed minions works fine but as you can imagine this is incredibly tedious to trace through outputs and repeat the calls individually to each minion where it failed.

I don't recall this happening in v.16 though I don't know that I had as many minions back then (not sure if number of minions really matters but in a group of 16+ nodes, at least one seems to always fail and as KatoneVi has noted, it appears to be a random minion in the group.

    State: - file
    Name:      /managed/scripts/configure_phy_bonding.py
    Function:  managed
        Result:    False
        Comment:   An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 1305, in call
    *cdata['args'], **cdata['kwargs'])
  File "/usr/lib/python2.6/site-packages/salt/states/file.py", line 1157, in managed
    dir_mode)
  File "/usr/lib/python2.6/site-packages/salt/modules/file.py", line 1972, in manage_file
    if source and source_sum['hsum'] != name_sum:
KeyError: 'hsum'

shantanub avatar Feb 26 '14 03:02 shantanub