Skip to content

Pip fix - #33180

Merged
rallytime merged 4 commits into
saltstack:2015.5from
thatch45:pip_fix
May 11, 2016
Merged

Pip fix#33180
rallytime merged 4 commits into
saltstack:2015.5from
thatch45:pip_fix

Conversation

@thatch45

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix #33163, this makes the pip requirements object duck typed, so that we can use pip before 8.1.2 as well as post 8.1.2

What issues does this PR fix or reference?

Previous Behavior

Remove this section if not relevant

New Behavior

Remove this section if not relevant

Tests written?

Yes/No

This was referenced May 11, 2016
Comment thread salt/states/pip_state.py Outdated
ret['result'] = True
ret['prefix'] = install_req.req.project_name
ret['version_spec'] = install_req.req.specs
if hasattr(install_req.req, 'project_name'):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is still not a public API, but I believe you can handle both of these cases by just using install_req.name which should do the right thing in both scenarios.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I tried that at first and got this traceback with pip 8.1.1:

  File "/usr/lib/python2.7/site-packages/salt/state.py", line 1564, in call
    **cdata['kwargs'])
  File "/usr/lib/python2.7/site-packages/salt/states/pip_state.py", line 560, in installed
    out = _check_pkg_version_format(pkg)
  File "/usr/lib/python2.7/site-packages/salt/states/pip_state.py", line 167, in _check_pkg_version_format
    ret['prefix'] = re.sub('[^A-Za-z0-9.]+', '-', install_req.req.name)
AttributeError: Requirement instance has no attribute 'name'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install_req.name not install_req.req.name. Notice the missing extra .req.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh! doh! Thanks!

@rallytime rallytime added the pending-changes The pull request needs additional changes before it can be merged label May 11, 2016
@thatch45

Copy link
Copy Markdown
Contributor Author

changes pushed

@rallytime rallytime removed the pending-changes The pull request needs additional changes before it can be merged label May 11, 2016
@rallytime
rallytime merged commit 264ad34 into saltstack:2015.5 May 11, 2016
cachedout pushed a commit that referenced this pull request May 12, 2016
* Add run_on_start docs to schedule.rst (#32958)

Fixes #22580

* Backport #33021 manually to 2015.5 (#33044)

* Saltfile with pillar tests (#33045)

* add file.managed with pillar data tests

* do not require git for other tests

* Fix minor document error of test.assertion (#33067)

* test pillar.items output (#33060)

* File and User test fixes for 2015.5 on Fedora23 (#33055)

* Fix file_test.test_symlink on 2015.5

* Fix failing user present test

* add test for installing package while using salt-call --local (#33025)

* add test for installing package while using salt-call --local

* fix pylint

* ssh docs: install py-2.6 for RHEL 5

* Bugfix: Restore boolean values from the repo configuration

* Add test data for repos

* Add repo config test

* Bugfix (follow-up): setting priority requires non-positive integer

* modules.npm: do not log npm --version at info level (#33084)

* salt-cloud: fix ipv6-only virtual machines (#32865)

* salt-cloud: fix ipv6-only virtual machines

* fix hostname for rsync fallback in scp_file function

* use 4 spaces instead of 2

* remove global variable, use direct socket call instead

* Use saltstack repo in buildpackage.py on CentOS 5 (#33080)

* Lower display of msgpack failure msg to debug (#33078)

Closes #33074

* cloud.query needs to define mapper.opts (#33098)

* clarify docs that map is designed to be run once. is not stateful (#33102)

* Moved _finger_fail method to parent class.

Method _finger_fail method from SAuth to AsyncAuth class to make method available
in both class and fix an issue where _finger_Fail is called inside AsyncAuth.

* Fix 33058 (#33099)

* Fix servermanager module

- Added check for 2008 version of windows
- Added Import-Module ServerManager to _pshell_json.
  Apparently this needs to run each time we issue a
  servermanager command.

* Fix list_available

* salt.utils.gitfs: fix formatting for warning messages (#33064)

* salt.utils.gitfs: fix formatting for warning messages

When git_pillar support was added to salt.utils.gitfs, the
recommendation globals had string formatting placeholders added to them,
but the locations where these values are referenced do not call
``.format()`` to properly replace them. This commit fixes that
oversight.

* Remove more gitfs and master-specific wording from log messages

* Add a check that the cmdline of the found proc matches (#33129)

* Doc mock decorators (#33132)

* Add mock function for mocking decorators

* Mock the stdlib user module because importing it will open the repl

* Fix broken parsing of usermgmt.conf on OpenBSD (#33135)

When creating a new user, if a group of the same name already exists,
the usermgmt.conf file is consulted to determine the primary group.
It's in these cases that the parsing bug is triggered.

This code change addresses several of the existing issues:

- The previous split statement explicitly specified a single space.
  Since a config line may have any number of spaces and/or tabs
  surrounding the entries, the resulting array's elements may be
  incorrect.

- According to the man pages for usermgmt.conf, the "group" config
  entry accpets a single parameter -- so we shouldn't iterate.

- The "val[1]" was returning the 2nd letter of each word and not the
  second word on the config line as intended.

* Move salt-ssh thin dir location to /var/tmp (#33130)

* Move salt-ssh thin dir location to /var/tmp

Closes #32771

* Remove performance penelty language

* If cache_jobs: True is set, populate the local job cache when running salt-call (#33100)

* If cache_jobs: True is set, populate the local job cache

Fixes #32834

Allows a masterless minion to query the job cache.

* Refactor cache_jobs functionality to be DRY

* Skipping salt-call --local test

* Back-port #31769 to 2015.8 (#33139)

* Handle empty acl_name in linux_acl state

Calls to setfacl interpret an empty group or user name to mean to be the
owner of the file they're operating on. For example, for a directory
owned by group 'admin', the ACL 'default:group::rwx' is equivalent to
'default:group:admin:rwx'.

The output of the getfacl execution module returns ACLs in the format of
'group:admin:rwx' instead of 'group::rwx'. This commit changes the
acl.present state to look for the owner of the file if the acl_name
paremeter is empty.

* Fix acl.present/acl.absent changing default ACLs

The behaviour of the acl.present and acl.absent is to check the data
structure returned by getfacl contains a key by the name of acl_type.

However, this data structure does not contain any default ACLs if none
exist, so this check will fail. We omit the check if a default ACL was
passed into the state functions.

Unfortunately, the call to modfacl may fail if the user passes in an
acl_type such as 'default:random'. In this case the state will appear to
succeed, but do nothing.

This fixes the state module to allow setting default ACLs on files which
have none.

* Fix regression in 2016.3 HEAD when version is specified (#33146)

Resolves #33013.

* Hash fileclients by opts (#33142)

* Hash fileclients by opts

There was an issue whereby the cache of the fileclient was being overwritten
by dueling minion instances in multimaster mode. This protects them by hashing
by the id of opts.

Closes #25040

* Silly typo!

* Remove tests which do not test any actual functionality or are too tightly coupled to the implementation

* Strip ldap fqdn (#33127)

* Add option to strip off domain names on computer names that come from LDAP/AD

* Add strip_domains option for ldap.

* Add documentation for auth.ldap.minion_stripdomains.

* [2015.5] Update to latest bootstrap script v2016.05.10 (#33155)

* [2015.8] Update to latest bootstrap script v2016.05.10 (#33156)

* [2016.3] Update to latest bootstrap script v2016.05.10 (#33157)

* add 2015.5.11 release notes (#33160)

* add 2015.8.9 release notes (#33161)

* Pip fix (#33180)

* fix pip!!

* make it work with old pip as well

* Added resiliency

* Don't need to check, just get the right name

* [2015.5] Update to latest bootstrap script v2016.05.11 (#33185)
@tmehlinger

Copy link
Copy Markdown
Contributor

This is broken on Ubuntu Trusty with python-pip (1.5.4) installed from mainline apt. This is only valid for pip 6.0+.

@tmehlinger

Copy link
Copy Markdown
Contributor

@tmehlinger

Copy link
Copy Markdown
Contributor

D'oh, forgot the stack trace:

    Function: pip.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1624, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1492, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/pip_state.py", line 597, in installed
                  out = _check_pkg_version_format(pkg)
                File "/usr/lib/python2.7/dist-packages/salt/states/pip_state.py", line 181, in _check_pkg_version_format
                  specifier = install_req.req.specifier
              AttributeError: Requirement instance has no attribute 'specifier'
     Started: 20:19:45.883326
    Duration: 3.61 ms
     Changes:

@thatch45

Copy link
Copy Markdown
Contributor Author

Thanks for the heads up @tmehlinger I will try to get a fix in ASAP

@tmehlinger

Copy link
Copy Markdown
Contributor

No harm done, sorry I crapped up your feed posting that in the wrong place.

@thatch45

Copy link
Copy Markdown
Contributor Author

lol, no worries, I lost hope in a clean issue feed years ago :)

dschaller pushed a commit to lyft/salt that referenced this pull request May 20, 2016
* fix pip!!

* make it work with old pip as well

* Added resiliency

* Don't need to check, just get the right name
dschaller added a commit to lyft/salt that referenced this pull request May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants