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

[BUG] salt/modules/network.py: def connect() not return ret['retcode'] #57783

Open
gaoweisgp opened this issue Jun 24, 2020 · 1 comment
Open
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@gaoweisgp
Copy link

Description
A clear and concise description of what the bug is.
Related code inside develop branch
https://github.com/saltstack/salt/blob/develop/salt/modules/network.py#L1385

salt/modules/network.py: def connect() does not return ret['retcode']. This causes
salt/states/module.py: def _get_result() to return True when the ret['result'] is False.
https://github.com/saltstack/salt/blob/develop/salt/states/module.py#L650

In the following case, the changes_ret inside salt/states/module.py: def _get_result() is not doing much as the changes was still just been initialized in salt/states/module.py: def run() at
https://github.com/saltstack/salt/blob/develop/salt/states/module.py#L423

Proposed solution option #1:
Don't change salt/states/module.py. Ensure those status checking modules (like network.py: def connect()) return dictionary include ret['retcode'] value

Proposed solution option #2:
Update salt/states/module.py: def _get_result() to handle module return dictionary with ret['result': True/False, 'comment': 'text string']

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info).

single salt master host with salt-master and salt-minion service up running

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)

# cat junk.sls 
test-network-connect:
  module.run:
    - network.connect:
      - host: junk
      - port: 22

# salt-call state.sls junk
inside salt/states/module.py def _get_result, func_ret: 
{'result': False, 'comment': 'Unable to resolve host junk on tcp port 22'}

changes: 
{}


local:
----------
          ID: test-network-connect
    Function: module.run
      Result: True
     Comment: network.connect: Unable to resolve host junk on tcp port 22
     Started: 12:57:27.062913
    Duration: 50.00000074505806 ms
     Changes:   
              ----------
              network.connect:
                  ----------
                  comment:
                      Unable to resolve host junk on tcp port 22
                  result:
                      False

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:  50.000 ms

Expected behavior
A clear and concise description of what you expected to happen.

Expect the state summary to have Failed: 1

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

Based on the code base, this should exist from 2017 ~ 3001

PASTE HERE

Additional context
Add any other context about the problem here.

Related unit test: https://github.com/saltstack/salt/blob/develop/tests/unit/modules/test_network.py#L245
few lines in this section could be changed to something like

'result': False}) ===> 'result': False, 'retcode': 0})
@gaoweisgp gaoweisgp added the Bug broken, incorrect, or confusing behavior label Jun 24, 2020
@krionbsd krionbsd added severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 labels Jun 25, 2020
@krionbsd krionbsd added this to the Approved milestone Jun 25, 2020
@krionbsd
Copy link
Contributor

@gaoweisgp thanks for the report, could you submit the patch to fix it, ping me if you need help for that.

@sagetherage sagetherage modified the milestones: Approved, Aluminium Jul 29, 2020
@sagetherage sagetherage added the Aluminium Release Post Mg and Pre Si label Jul 29, 2020
@sagetherage sagetherage removed Aluminium Release Post Mg and Pre Si P3 Priority 3 phase-plan labels Feb 5, 2021
@sagetherage sagetherage modified the milestones: Aluminium, Approved Feb 5, 2021
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 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

3 participants