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

Killing a script with ps.pkill also kills salt #62041

Open
Apteryx0 opened this issue May 9, 2022 · 1 comment
Open

Killing a script with ps.pkill also kills salt #62041

Apteryx0 opened this issue May 9, 2022 · 1 comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. needs-triage

Comments

@Apteryx0
Copy link

Apteryx0 commented May 9, 2022

Is your feature request related to a problem? Please describe.
It is not possible to use the ps.pkill command with the full=true option to kill a script without also killing the salt process doing the command. This is illustrated by pgrep, which returns the processes we are interested in but also the salt processes running the command:

support@test-cluster-1-master:~$ sudo salt \* ps.pgrep "status_check.py" full=true user=root
worker03:
    None
worker01:
    None
worker02:
    None
test-cluster-1-master:
    - 5104
    - 5105
    - 113618
    - 113629
support@test-cluster-1-master:~$ ps aux | grep "status_check.py"
support    6401  0.0  0.0  13144  1020 pts/1    S+   18:07   0:00 grep --color=auto status_check.py
root     113618  0.0  0.0   4632   820 ?        Ss   18:06   0:00 /bin/sh -c status_check.py check --with-purge 2>&1 | logger -t status_check
root     113629  4.1  0.1 3778936 233456 ?      Sl   18:06   0:04 python /usr/local/sbin/status_check.py check --with-purge
support@test-cluster-1-master:~$ 

Additionally the documentation talks about the parameter of both commands being a "pattern", however, looking at the source (https://github.com/saltstack/salt/blob/master/salt/modules/ps.py#L300) just a simple python str "in" operator is used.... so it isn't so much a pattern as a substring.

Both of these issues can be solved by allowing pattern to be a regex, similar to what is used in the ps.psaux function (https://github.com/saltstack/salt/blob/master/salt/modules/ps.py#L745)

There are though other solution that are possible. For example, the ps.psaux command removed salt instances from the results - making pkill/psaux consistent with this would also be welcome.

support@test-cluster-1-master:~$ sudo salt \* ps.psaux status_check.py
worker01:
    - status_check.py
    |_
    - 0 occurence(s).
worker03:
    - status_check.py
    |_
    - 0 occurence(s).
test-cluster-1-master:
    - status_check.py
    |_
      - root      94819  0.0  0.0   4632   892 ?        Ss   18:14   0:00 /bin/sh -c status_check.py check --with-purge 2>&1 | logger -t status_check
      - root      94833 34.1  0.1 3777428 231360 ?      Sl   18:14   0:03 python /usr/local/sbin/status_check.py check --with-purge
    - 2 occurence(s).
worker02:
    - status_check.py
    |_
    - 0 occurence(s).
support@test-cluster-1-master:~$ 

Describe the solution you'd like
Don't include salt commands in the process set and support regexs (or update the parameter name from 'pattern' to 'substring')

Describe alternatives you've considered
Just supporting pattern being a regex would be sufficient

Additional context
Add any other context or screenshots about the feature request here.

Please Note
If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

@Apteryx0 Apteryx0 added Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels May 9, 2022
@welcome
Copy link

welcome bot commented May 9, 2022

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant