salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-cloud: ExtraData: unpack(b) received extra data.

Open lrhazi opened this issue 11 years ago • 17 comments

Suddenly all my attempts at starting or stopping ec2 nodes fail with the bellow error....

salt-cloud --versions-report             
            Salt: 2014.7.0-1934-g91b9632
          Python: 2.7.5 (default, Nov  3 2014, 14:26:24)
          Jinja2: 2.7.3
        M2Crypto: 0.21.1
  msgpack-python: 0.4.2
    msgpack-pure: Not Installed
        pycrypto: 2.6.1
         libnacl: Not Installed
          PyYAML: 3.10
           ioflo: Not Installed
           PyZMQ: 14.3.1
            RAET: Not Installed
             ZMQ: 4.0.4
            Mako: 1.0.0
 Apache Libcloud: 0.16.0
sudo salt-cloud --map=/etc/salt/cloud.map --parallel -ldebug
...
[DEBUG   ] Generating minion keys for 'spark-worker-10'
[DEBUG   ] Generating minion keys for 'spark-worker-9'
[DEBUG   ] Generating minion keys for 'spark-worker-8'
[DEBUG   ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc
[DEBUG   ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Sending event - data = {'profile': 'spark_master', 'event': 'starting create', '_stamp': '2014-12-13T23:12:26.546275', 'name': 'spark-master', 'provider': 'aws-gu-spark:ec2'}
[ERROR   ] There was a query error: unpack(b) received extra data.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cloud/cli.py", line 316, in run
    ret = mapper.run_map(dmap)
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1992, in run_map
    out = self.create(master_profile, local_master=local_master)
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1240, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/ec2.py", line 2040, in create
    vm_['name'], vm_['profile'], 'ec2', vm_['provider']
  File "/usr/lib/python2.7/site-packages/salt/utils/cloud.py", line 2015, in cachedir_index_add
    index = msgpack.load(fh_)
  File "_unpacker.pyx", line 140, in msgpack._unpacker.unpack (msgpack/_unpacker.cpp:140)
  File "_unpacker.pyx", line 123, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:123)
ExtraData: unpack(b) received extra data.

lrhazi avatar Dec 14 '14 04:12 lrhazi

What was the last thing that happened before this started? Updating to latest develop? Updating your provider/profile/map file? Something else?

techhat avatar Dec 14 '14 14:12 techhat

I really dont remember changing anything on the system where I am running salt-cloud, before when it worked and when it stopped.. but might have forgotten. Well, I did add more nodes to the map, and changed the ami id, but tried undoing that to no avail.

I tired re-installing, un-installing, various versions, but seems like they all give me the same error now!

One thing I can confirm is the a simple image look up works, so it's not having this issue with every interaction with AWS.

➜  ~  sudo salt-cloud -f show_image ec2 image=ami-daa4c5b2

lrhazi avatar Dec 14 '14 19:12 lrhazi

@lrhazi Apologies that we never really came back to this issue. Are you still running into this issue on a newer version of salt?

rallytime avatar May 19 '15 20:05 rallytime

sorry, I gave up on it, as I could not make it work again... I'll see if I can soon try again. thanks a lot.

lrhazi avatar May 20 '15 06:05 lrhazi

No problem. I know we've cleaned up A LOT of the message pack errors like this in the last six months or so. If it's alright with you, I am going to close this. If you bump into this bug again, please leave a comment and we'd be happy to re-open this issue and take another look. Thanks again!

rallytime avatar Jun 02 '15 23:06 rallytime

I'm experiencing the same, any operation ends to

salt-cloud -p es_web example.company.com -ldebug
[DEBUG   ] Reading configuration from /etc/salt/cloud
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: ip-172-31-7-69.eu-west-1.compute.internal
[DEBUG   ] Reading configuration from /etc/salt/cloud.providers
[DEBUG   ] Including configuration from '/etc/salt/cloud.providers.d/digitalocean.conf'
...
[DEBUG   ] LazyLoaded rackspace.list_locations
[DEBUG   ] Using AWS endpoint: ec2.eu-west-1.amazonaws.com
[DEBUG   ] AWS Request: https://ec2.eu-west-1.amazonaws.com/?Action=DescribeInstances&Version=2014-10-01
[INFO    ] Starting new HTTPS connection (1): ec2.eu-west-1.amazonaws.com
[DEBUG   ] Setting read timeout to None
[DEBUG   ] "GET /?Action=DescribeInstances&Version=2014-10-01 HTTP/1.1" 200 None
[DEBUG   ] AWS Response Status Code: 200
[DEBUG   ] Generating minion keys for 'example.company.com'
[DEBUG   ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc
[DEBUG   ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Sending event - data = {'_stamp': '2015-06-15T04:59:55.199481'}
[DEBUG   ] Sending event - data = {'profile': 'es_web', 'event': 'starting create', '_stamp': '2015-06-15T04:59:55.200775', 'name': 'example.company.com', 'provider': 'ec2-eu-west-1-private-ips:ec2'}
[ERROR   ] There was a profile error: unpack(b) recieved extra data.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 254, in run
    self.config.get('names')
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1388, in run_profile
    ret[name] = self.create(vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1241, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 2068, in create
    vm_['name'], vm_['profile'], 'ec2', vm_['provider']
  File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 2012, in cachedir_index_add
    index = msgpack.load(fh_)
  File "_unpacker.pyx", line 130, in msgpack._unpacker.unpack (msgpack/_unpacker.cpp:132)
  File "_unpacker.pyx", line 114, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:114)
ExtraData: unpack(b) recieved extra data.

Versions:

salt-cloud --versions-report
                  Salt: 2015.5.0
                Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
                Jinja2: 2.7.2
              M2Crypto: 0.21.1
        msgpack-python: 0.3.0
          msgpack-pure: Not Installed
              pycrypto: 2.6.1
               libnacl: Not Installed
                PyYAML: 3.10
                 ioflo: Not Installed
                 PyZMQ: 14.0.1
                  RAET: Not Installed
                   ZMQ: 4.0.4
                  Mako: 0.9.1
       Apache Libcloud: 0.14.1
 Debian source package: 2015.5.0+ds-1trusty1

Edit: salt commands work as usual, only salt-cloud seems to be affected. Removing and reinstalling all salt related did not fix it. (apt-get remove salt-minion, salt-master, salt-cloud and install the same)

I also can't recall changing anything, nor did apt-get update (anything that I can see as relevant) after that last working setup. What could I provide to assist tracing this?

ghost avatar Jun 15 '15 05:06 ghost

@villeapvirtanen What cloud provider are you using when you see these messages?

rallytime avatar Jun 15 '15 14:06 rallytime

Hi,

the provider is

ec2-eu-west-1-private-ips:
  provider: ec2
  location: eu-west-1
  availability_zone: eu-west-1a
  id: ??????
  key: '?????'
  keyname: eu-west-1
  securitygroup: default
  private_key: keys/eu-west-1.pem
  rename_on_destroy: True
  ssh_interface: private_ips
  minion:
    master: my-master-dns

I have already since created a new master machine, in which all the contents of /etc/salt/ was copied over, and it just works. The old machine experienced multiple python, salt etc. updates, so maybe that's the reason? Anyhow, I think from my point of view, as the problem for me is fixed by creating another machine, we can drop chasing this and return to this if it happens again. (Luckily I have all data in git, so it was easy to transition to new master)

ghost avatar Jun 16 '15 05:06 ghost

@villeapvirtanen Thanks for the update and apologies for the trouble. I wonder if something was just being strange from the update. I'll close this for now and we can open it again if it pops up again, as you suggested. Thanks!

rallytime avatar Jun 23 '15 03:06 rallytime

For what it's worth, I ran into this issue today, specifically while working with the amazon ec2 provider. Everything had been running smoothly for several weeks then started receiving the same error.

As a quick version report:

 salt-cloud --versions-report
            Salt: 2015.5.2
          Python: 2.7.10 (default, Jul  9 2015, 11:14:13)
          Jinja2: 2.7.3
        M2Crypto: 0.22
  msgpack-python: 0.4.6
    msgpack-pure: Not Installed
        pycrypto: 2.6.1
         libnacl: Not Installed
          PyYAML: 3.11
           ioflo: Not Installed
           PyZMQ: 14.7.0
            RAET: Not Installed
             ZMQ: 4.1.2
            Mako: Not Installed
 Apache Libcloud: 0.17.0

It turned out that for me the quick fix was to rename the salt-cloud cache directory at /var/cache/salt/cloud, which came to my attention after looking at the cloud.py referenced in the stacktrace:

    base = init_cachedir(base)
    print "Base dir: %s" % base
    index_file = os.path.join(base, 'index.p')

    if os.path.exists(index_file):
        with salt.utils.fopen(index_file, 'r') as fh_:
            index = msgpack.load(fh_)
    else:
        index = {}

it seemed like it was failing on this index file that was found in the cache. If there's anything within the cache that you would like me to look at, I'll be happy to post.

I believe it started happening after I switched from us-west-1 to us-west-2 within my cloud providers file, but i can't be 100% certain.

josephgimenez avatar Jul 09 '15 22:07 josephgimenez

I also ran into this issue today after it working perfectly yesterday. Removing /var/cache/salt/cloud as recommended by @asyncsrc above got everything working again.

For what it's worth here is my version report:

            Salt: 2015.5.0
          Python: 2.7.6 (default, Sep  9 2014, 15:04:36)
          Jinja2: 2.7.3
        M2Crypto: 0.22
  msgpack-python: 0.4.6
    msgpack-pure: Not Installed
        pycrypto: 2.6.1
         libnacl: Not Installed
          PyYAML: 3.11
           ioflo: Not Installed
           PyZMQ: 14.7.0
            RAET: Not Installed
             ZMQ: 4.1.2
            Mako: Not Installed
         Tornado: Not Installed
 Apache Libcloud: Not Installed

jgill avatar Aug 05 '15 17:08 jgill

It also hit us. I think it is the cachedir_index_add and cachedir_index_del functions in salt/utils/cloud.py, where access to index.p does not seem to be locked. These functions are called from multiple processes if salt-cloud is called with -P.

eyj avatar Oct 07 '15 16:10 eyj

Oh, good info @eyj. We never were able to reproduce this one internally. I'll reopen this.

rallytime avatar Oct 07 '15 22:10 rallytime

Some more info: It was during a run of "salt-cloud -P -m mapfile" with 14 machines being pulled up simultaneously. The traceback:

TRACE: unpack(b) recieved extra data.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 60, in _call
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 2190, in create_multiprocessing
    local_master=parallel_data['local_master']
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1249, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 2217, in create
    vm_['name'], vm_['profile'], 'ec2', vm_['driver']
  File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 2368, in cachedir_index_add
    index = msgpack.load(fh_)
  File "_unpacker.pyx", line 130, in msgpack._unpacker.unpack (msgpack/_unpacker.cpp:132)
  File "_unpacker.pyx", line 114, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:114)
ExtraData: unpack(b) recieved extra data.



Error: There was a query error: Exception caught
Caught Exception, terminating workers
TRACE: unpack(b) recieved extra data.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 60, in _call
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 2190, in create_multiprocessing
    local_master=parallel_data['local_master']
  File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1249, in create
    output = self.clouds[func](vm_)
  File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 2217, in create
    vm_['name'], vm_['profile'], 'ec2', vm_['driver']
  File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 2368, in cachedir_index_add
    index = msgpack.load(fh_)
  File "_unpacker.pyx", line 130, in msgpack._unpacker.unpack (msgpack/_unpacker.cpp:132)
  File "_unpacker.pyx", line 114, in msgpack._unpacker.unpackb (msgpack/_unpacker.cpp:114)
ExtraData: unpack(b) recieved extra data.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

After this, the index.p file seemed to be corrupt, and any further attempt to run any salt-cloud operation (delete or create) failed with a similar traceback.

I guess one should pass in a multiprocessing.Lock for the index.p everywhere?

eyj avatar Oct 08 '15 07:10 eyj

having this issue with salt-cloud 2015.5.3 (Lithium)

damaex17 avatar Jan 27 '16 08:01 damaex17

Hi all - the locking issues should be resolved by #30671. Can anyone give that change a try and confirm this is fixed?

rallytime avatar Jan 27 '16 21:01 rallytime

Since we haven't heard back from anyone here, I am going to go ahead and close this. If this issue pops up again, please let us know and we can re-open this issue and take another look.

rallytime avatar Feb 24 '16 23:02 rallytime