Skip to content

salt.states.augeas.change returns None when test=True #37870

Closed

Description

@fj40crawler

Tested against 2016.3.3 (Boron) using augeas.change with test=True

when running a state with test=True that includes augeas.change None is returned rather than True with a comment including commands that would be run.

This can be seen in the state code (salt/states/augeas.py) on line 267. Looking at the code it does not matter what the contents of the state are - all states will return None when test=True.

This result is in contradiction to what should be returned since there is no test run showing things would be changed as a result of the state being applied. Ideally this would return true and then report which commands would be run to test if a change would be applied.

Activity

  1. Ch3LL commented on Nov 23, 2016

    @Ch3LL
    Contributor

    @fj40crawler good catch. Looks like we need to get this cleaned up on this state to not return None. Any chance you want to take crack at it and push a PR? If not one of our team members can get to it :)

  2. added
    bug
    Core
    P4
    on Nov 23, 2016
  3. added this to the Approved milestone on Nov 23, 2016
  4. added
    severity-medium
    on Nov 23, 2016
  5. fj40crawler commented on Nov 24, 2016

    @fj40crawler
    ContributorAuthor

    yeah, easy fix. Just need to grab a copy and change None to True.

  6. fj40crawler commented on Nov 24, 2016

    @fj40crawler
    ContributorAuthor

    Not sure what the deal is here. Have other things I need to do tonight.

    Zoe$ git log -m -p -1
    commit 1e44a06ac16dd9d19059ad059aa1698e1e6c4319
    Author: Daniel Boughton [email protected]
    Date: Wed Nov 23 20:35:41 2016 -0500

    Change return value for salt/states/augeas.py to be True instead of None for
    cases where salt is run with test=True.
    
    Fixes #37870
    

    diff --git a/salt/states/augeas.py b/salt/states/augeas.py
    index c9374bf..8321f5e 100644
    --- a/salt/states/augeas.py
    +++ b/salt/states/augeas.py
    @@ -265,7 +265,7 @@ def change(name, context=None, changes=None, lens=None,
    filename = re.sub('^/files|/$', '', context)

     if __opts__['test']:
    
    •    ret['result'] = None
      
    •    ret['result'] = True
         ret['comment'] = 'Executing commands'
         if context:
             ret['comment'] += ' in file "{0}":\n'.format(context)
      

    Zoe$ git push -u origin fix-augeas-return-for-test-true
    Username for 'https://github.com': fj40crawler
    Password for 'https://[email protected]':
    remote: Permission to saltstack/salt.git denied to fj40crawler.
    fatal: unable to access 'https://github.com/saltstack/salt/': The requested URL returned error: 403

  7. fj40crawler commented on Nov 24, 2016

    @fj40crawler
    ContributorAuthor

    and it whacked the friggin diff. Well one line of change there where ret['result'] = True

  8. added a commit that references this issue on Nov 25, 2016
    b0fe0cd
  9. fj40crawler commented on Nov 25, 2016

    @fj40crawler
    ContributorAuthor

    Pull request is in (finally)

  10. cachedout commented on Nov 29, 2016

    @cachedout
    Contributor

    Closed via #37895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreP4State-Modulebugseverity-medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions