Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: string indices must be integers, not str #21480

Closed
msciciel opened this issue Mar 10, 2015 · 55 comments
Closed

TypeError: string indices must be integers, not str #21480

msciciel opened this issue Mar 10, 2015 · 55 comments
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P1 Priority 1 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@msciciel
Copy link
Contributor

Occasionaly during highstate i got error (it looks like it occur on random machine with random time):

Salt highstate error: Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2834, in call_highstate
    top = self.get_top()
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2336, in get_top
    tops = self.get_tops()
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2209, in get_tops
    saltenv
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 147, in cache_file
    return self.get_url(path, '', True, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 521, in get_url
    return self.get_file(url, dest, makedirs, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 991, in get_file
    if not data['data']:
TypeError: string indices must be integers, not str
           Salt: 2014.7.1
         Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
         Jinja2: 2.7.2
       M2Crypto: 0.20.2
 msgpack-python: 0.1.13
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 4.0.4
           Mako: Not Installed

Any ideas what is wrong ?

@rallytime rallytime added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Mar 10, 2015
@rallytime rallytime added this to the Blocked milestone Mar 10, 2015
@rallytime
Copy link
Contributor

@msciciel Hmm...Any other information you can provide? You say it only happens occasionally and on different boxes each time? Any similarities between these boxes? And only when you run state.highstate? Any other configs you've changed?

@basepi or @jfindlay or @cachedout Any of you heard of anything similar to this lately?

@jfindlay
Copy link
Contributor

I think this is a duplicate of #20777. See also, #18729 (comment).

@msciciel
Copy link
Contributor Author

It looks random. I have check of last highstate run and it raports this error. I do not run highstate manually. If check report that error occured and then i login into machine and run highstate then it's always ok. It's happens always on few boxes from 1600.

#20777 - my master is in 2014.7.1 version
#18729 - in my case minions are not stuck in this state

Is this related to pillar data or maybe formulas ? I have pillar data updated from git repo with 5 minutes interval.

@mimianddaniel
Copy link

Didnt see this issue until upgraded to RC2.
Happens everytime for us using salt

Traceback (most recent call last):
  File "/opt/blue-python/2.7/lib/python2.7/site-packages/salt/master.py", line 1415, in run_func
    ret = getattr(self, func)(load)
  File "/opt/blue-python/2.7/lib/python2.7/site-packages/salt/master.py", line 1270, in _syndic_return
    self._return(ret)
  File "/opt/blue-python/2.7/lib/python2.7/site-packages/salt/master.py", line 1244, in _return
    self.opts, load, event=self.event, mminion=self.mminion)
  File "/opt/blue-python/2.7/lib/python2.7/site-packages/salt/utils/job.py", line 55, in store_job
    load.update({'user': ret_['user']})
TypeError: string indices must be integers, not str

Also, salt-run jobs.lookup_jid doesnt return anything now but i can see the ret events are flowing in.
for my issue, at least this commit looks suspicious: 7a8b7a2

           Salt: 2015.2.0
         Python: 2.7.9 (default, Dec 30 2014, 13:07:54)
         Jinja2: 2.7.3
       M2Crypto: 0.22
 msgpack-python: 0.4.2
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.11
          ioflo: Not Installed
          PyZMQ: 14.4.1
           RAET: Not Installed
            ZMQ: 4.0.5
           Mako: Not Installed

@bmcclure
Copy link

I am getting these errors, too. It seems mostly random. I have been commenting out things from my highstate to try to determine what could be happening.

It does NOT occur if I run state.highstate on one single minion. I also have NOT seen it occur if I don't use any formulas. However, if I have any formulas active, and if I am calling state.highstate on two or more minions, I often (not always) see the error on the first one, or several, minions, and the last one, or several, minions completes successfully.

    Data failed to compile:
----------
    Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2853, in call_highstate
    top = self.get_top()
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2355, in get_top
    tops = self.get_tops()
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 2228, in get_tops
    saltenv
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 147, in cache_file
    return self.get_url(path, '', True, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 522, in get_url
    return self.get_file(url, dest, makedirs, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 992, in get_file
    if not data['data']:
TypeError: string indices must be integers, not str
Versions:
                  Salt: 2014.7.2
                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
 Debian source package: 2014.7.2+ds-1trusty2

@bmcclure
Copy link

I am now seeing the same error when I run state.highstate with just one minion--it just seems less frequent.

@basepi basepi added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around cannot-reproduce cannot be replicated with info/context provided and removed Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged labels Mar 20, 2015
@basepi basepi modified the milestones: Approved, Blocked Mar 20, 2015
@cachedout
Copy link
Contributor

After reviewing the code in the about-to-be-released update to 2014.7, I believe this issue has been resolved. I am marking his as Fixed Pending Verification until somebody can verify a fix in the next release.

@cachedout cachedout added fixed-pls-verify fix is linked, bug author to confirm fix and removed cannot-reproduce cannot be replicated with info/context provided labels Mar 25, 2015
@gcamus
Copy link
Contributor

gcamus commented Mar 27, 2015

I am getting the same error too on versions 2014.7.2 or 2015.0.2rc1 but i think i find a workaround to set the saltenv on every command even if for base.

I remark that the problem appears when GitFs and ext_pillar git are activated and some branches exist on repositories

For exemple :
salt '*' state.highstate saltenv=base

@msciciel
Copy link
Contributor Author

I have ext pillar disabled and error sometimes occurs.

@wwentland
Copy link
Contributor

We are seeing this all the time ever since we upgraded to 2014.7.2, quite annoying

@basepi
Copy link
Contributor

basepi commented Mar 31, 2015

2014.7.4 has been tagged and we're just waiting on packagers. If someone wants to install from source or pip in the meantime and see if this is resolved, that would be lovely. Otherwise we'll wait until the official announcement.

@PitrJ
Copy link

PitrJ commented Apr 1, 2015

I am trying to solve this issue as well. I made a state that basically just did a file.manged and nothing more. From a client I did the following:

while [ $? == 0 ] ; do  salt-call -l debug state.sls testing/pieter; done

All went fine the first 14 times, after that it broke:

[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://testing/pieter.sls'
[ERROR   ] Data is 
Passed invalid arguments: string indices must be integers, not str
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/cli/caller.py", line 129, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/salt/modules/state.py", line 461, in sls
    high_, errors = st_.render_highstate({saltenv: mods})
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2743, in render_highstate
    sls, saltenv, mods, matches)
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2426, in render_state
    state_data = self.client.get_state(sls, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 423, in get_state
    dest = self.cache_file(path, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 147, in cache_file
    return self.get_url(path, '', True, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 522, in get_url
    return self.get_file(url, dest, makedirs, saltenv)
  File "/usr/lib/python2.6/site-packages/salt/fileclient.py", line 992, in get_file
    if not data['data']:
TypeError: string indices must be integers, not str

Here is my very simple sls file:

/tmp/test.pieter:
  file.managed:
    - source: salt://testing/pieter/testfile
    - user: root
    - group: root
    - mode: 644

@PitrJ
Copy link

PitrJ commented Apr 1, 2015

Forgot the versions:

           Salt: 2014.7.2
         Python: 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
         Jinja2: unknown
       M2Crypto: 0.20.2
 msgpack-python: 0.1.9.final
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.3.1
           RAET: Not Installed
            ZMQ: 4.0.4
           Mako: Not Installed

@gcamus
Copy link
Contributor

gcamus commented Apr 1, 2015

I think the problem is really due to GitFS and list of env issue. If you enable GitFS and you have multiple repos you have to create same branches on all your git repos or else use master conf (See below example) :

gitfs_env_blacklist:
  - release*

gitfs_env_whitelist:
  - base
  - bamboo

If you want you can check all declared GitFS envs names in file : /var/cache/salt/master/gitfs/envs.p

@PitrJ
Copy link

PitrJ commented Apr 1, 2015

We are using 1 repo as gitfs_remote.

@PitrJ
Copy link

PitrJ commented Apr 1, 2015

Running the same loop with saltenv=base did not solve the problem. Still broke after about 20 cycles.

@rallytime
Copy link
Contributor

@PitrJ It looks like you're on 2014.7.2, where we had some gitfs regressions. These have now been fixed in 2014.7.4, which was recently tagged and is now in the packaging stage. I'd recommend giving that tag a try, if you're able. If not, please let us know if you still hit this issue once the packages for 2014.7.4 are available and you've had a chance to retest.

@wwentland
Copy link
Contributor

@rallytime Which particular issue are you referring to and in which commit was it fixed? Given that .4 won't make it into the repositories for some time I might consider building and distributing a locally maintained version or fix it in whatever way is appropriate, but for that I'd need to know more details.

@rallytime
Copy link
Contributor

@BABILEN Unfortunately, I don't have a particular commit or pull request number offhand. I was going off of @cachedout's comment above about reviewing the code and marking this as fixed pending verification.

I think really we are just wondering if someone can test this on 2014.7.4, where the tag (v2014.7.4) is pushed to the saltstack repo, or on packages once they come out. We'll certainly leave this open until we have confirmed that this was fixed, or revisit it if more work needs to be done.

@luitzifa
Copy link
Contributor

2014.7.4 works fine, thank you very much!

Summary
---------------
Succeeded: 1650 (changed=1406)
Failed:       0
---------------
Total states run:     1650

@rallytime
Copy link
Contributor

Awesome! Thanks for testing this everyone! With at least 4 confirmations that this has been fixed, I feel comfortable closing this issue. If this pops up again after upgrading to 2014.7.4, please leave a comment and we can re-address the issue.

@romlok
Copy link

romlok commented Apr 24, 2015

I just encountered this error message as well, running under 2014.7.4.
I believe the cause of my troubles was different to the original problem, but the issue title is the error message, so I'm posting my experience here for future reference.

TL;DR: If you see this error, check file permissions.


Running salt-call state.sls postgres.installed:

----------
          ID: postgres-hba
    Function: file.managed
        Name: /etc/postgreql/9.1/main/pg_hba.conf
      Result: False
     Comment: Unable to manage file: string indices must be integers, not str
     Started: 14:11:06.492990
    Duration: 10.757 ms
     Changes:   
----------

The state in question:

postgres-hba:
  file.managed:
    - name: /etc/postgreql/9.1/main/pg_hba.conf
    - source: salt://postgres/pg_hba.conf.jinja
    - template: jinja

Relevant snippet of salt-call output:

[INFO    ] Running state [/etc/postgresql/9.1/main/pg_hba.conf] at time 14:28:14.608229
[INFO    ] Executing state file.managed for /etc/postgresql/9.1/main/pg_hba.conf
[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://postgres/pg_hba.conf.jinja'
[ERROR   ] Data is 
[DEBUG   ] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/states/file.py", line 1393, in managed
    **kwargs
  File "/usr/lib/python2.7/dist-packages/salt/modules/file.py", line 2521, in get_managed
    sfn = __salt__['cp.cache_file'](source, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/modules/cp.py", line 337, in cache_file
    result = __context__['cp.fileclient'].cache_file(path, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 147, in cache_file
    return self.get_url(path, '', True, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 522, in get_url
    return self.get_file(url, dest, makedirs, saltenv)
  File "/usr/lib/python2.7/dist-packages/salt/fileclient.py", line 993, in get_file
    if not data['data']:
TypeError: string indices must be integers, not str

[ERROR   ] Unable to manage file: string indices must be integers, not str
[INFO    ] Completed state [/etc/postgresql/9.1/main/pg_hba.conf] at time 14:28:14.618628

Versions:

# salt-call --versions-report
                  Salt: 2014.7.4
                Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
                Jinja2: 2.6
              M2Crypto: 0.21.1
        msgpack-python: 0.1.10
          msgpack-pure: Not Installed
              pycrypto: 2.6
               libnacl: Not Installed
                PyYAML: 3.10
                 ioflo: Not Installed
                 PyZMQ: 13.1.0
                  RAET: Not Installed
                   ZMQ: 3.2.3
                  Mako: 0.7.0
 Debian source package: 2014.7.4+ds-1~bpo70+1

However, when I removed template: jinja from the state, the error changed to:

Source file salt://postgres/pg_hba.conf.jinja not found

So, after close inspection of the filenames, and much copy & pasting of paths, I discovered that it was actually the file permissions of /srv/salt/postgres/pg_hba.conf.jinja which didn't allow the salt master access to the file...


So I guess the ultimate upshot here is that the core issue behind this ticket has not really been remedied, which is: Whatever is triggering this particular error message needs to be more careful about not masking other more useful error messages.

@jfindlay
Copy link
Contributor

@raumkraut, thanks for the report. I'll be looking into this.

@jfindlay jfindlay self-assigned this Apr 24, 2015
@jfindlay jfindlay reopened this Apr 24, 2015
@jfindlay jfindlay removed their assignment Apr 24, 2015
cachedout pushed a commit to cachedout/salt that referenced this issue Apr 28, 2015
@cachedout
Copy link
Contributor

I can reproduce this by establishing a ZMQ channel to the master and then bringing down the master and then bringing it back up. After doing so, all calls to the channel's send method will return an empty string, since the channel no longer has the right AES key. This is fixed in #23154

@msciciel
Copy link
Contributor Author

Any progress with fix ?

@rallytime
Copy link
Contributor

@msciciel Does the pull request mentioned above resolve this issue for you?

@msciciel
Copy link
Contributor Author

Is 2014.7.5 or 2015.5.0 fixed version ?

@rallytime
Copy link
Contributor

@msciciel It look like the fix didn't make it into an official release yet. The pull request was merged in 2015.5 right after we cut 2015.5.2. Therefore, the fix will be available when 2015.5.3 is released.

We can definitely keep this open until you've had a chance to test it.

@msciciel
Copy link
Contributor Author

Ok. I'll verify after release of 2015.5.3. I saw today that problem still exists.

@yermulnik
Copy link

Similar error appeared in archive.extracted after upgrading Salt to 2015.5.3

          ID: /usr/local/etc/salt/states/deploy/node_srvt/worker_oe/bin/1.6.0.3610.tmp
    Function: archive.extracted
      Result: False
     Comment: Unable to manage file: string indices must be integers, not str
     Started: 11:30:52.130212
    Duration: 2330.451 ms
     Changes:

How can this be fixed? It breaks our deployment system! =(

@rallytime
Copy link
Contributor

@yermulnik Do you have a similar stacktrace as the others in this thread? Or is this specifically only happening when using an archive.extracted state? I am just trying ascertain if this is the same bug or one more specific to the state you're running.

@yermulnik
Copy link

That's only what I get. No stacktrace. I've encountered it only when using archive.extracted.

@rallytime
Copy link
Contributor

@yermulnik Does it happen each time you run the state, or only intermittently? If it's consistently failing each time, it might be a different bug. If not, then something is still amiss here.

@yermulnik
Copy link

Yes, it happens each time I run the state. And it appeared since I had upgraded to 2015.5.3 yesterday.
I don't know if it's a different bug. I searched for the "string indices must be integers, not str" error and found 2 issues: this one and #21799 - so I decided to ask for help here and there.
Should I create new issue to not confuse similar but not same issues?

@rallytime
Copy link
Contributor

@yermulnik Would you mind opening a new one? That sounds different to me than these other ones and that way we can get some more eyes on it. Thanks!

@yermulnik
Copy link

Ok, no problem: #26090

@rallytime
Copy link
Contributor

@msciciel Just a follow-up ping here - were you able to confirm if this bug is fixed for you or not on a 2015.5.3 or newer release of salt?

@msciciel
Copy link
Contributor Author

I have now all minions in version 2015.5.8 and havent seen this problem since upgrade.

@romlok
Copy link

romlok commented Jan 29, 2016

Just to confirm, I ran a few tests with Salt 2015.5.3 in a simple VM, and the issue I was encountering earlier does also appear to have been fixed.

@rallytime
Copy link
Contributor

Awesome! Thank you for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P1 Priority 1 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests