If a process has already exited between when psutil.process_iter() was
invoked, and when we invoke the cmdline() func, it will raise an
exception. This commit catches this exception and skips these processes.
This allows for the shutdown function to also terminate any orphaned
processes which were spawned during the time between when
terminate_process is invoked, and when the processes are actually
killed.
This fixes the test failures recently observed in
integration.shell.test_master.MasterTest.test_exit_status_correct_usage.
The test failures were not a regression, but rather a symptom of a
greater problem with the TestProgram class' shutdown() func. When
terminating the process using the terminate_process helper from
pytest-salt, it does not pass kill_children, which defaults to False.
This makes the helper only kill the main PID, leaving all the other PIDs
running.
This means that every time the integration suite was being run, each
time the TestProgram class was used to spawn a temporary daemon, it
would leave all the child PIDs running when the shutdown() is invoked.
By passing kill_children=True, we ensure that the child PIDs are also
killed. This should provide a significant perfomance improvement in the
test suite.
* Change "unknown" user to "some_unknown_user_xyz" since "unknown"
*is* a valid user
* Add timeout to proxy test_exit_status_no_proxyid() since a known
failure case is to infinitely loop with an error.
* Always force the source code tree under test to be the first entry
in PYTHONPATH (excluding verbatim_env)
* Change "unknown" user to "some_unknown_user_xyz" since "unknown"
*is* a valid user
* Add timeout to proxy test_exit_status_no_proxyid() since a known
failure case is to infinitely loop with an error.
* Always force the source code tree under test to be the first entry
in PYTHONPATH (excluding verbatim_env)
* shared config settings go in `config_base` rather than *each* config
* Ensure that `name` attribute is a string
* Ensure that `dirtree` gets used from kwargs
* Adding 'XXXX' to the mkdtemp template is unnecessary
* Only template values if they are strings - otherwise just use them directly
* Change the .config attribute to .config_base and .configs as a dictionary of configs
* A config has multiple parts
:name: the key in the .configs dictionary
:path: the path where the config is written (when absent defaults to .config_dir and config name)
:map: the contents of the config (for salt programs this is a dictionary)
* Values can be substituted into the config contents using standard python string formatting labels
* Add a .config_attrs which maps object attributes into config space
* Directories for make_dirtree() can reference object attributes using leading '&'
* Automatically add --proxyid to salt-proxy arguments
* Add parameters to disable automatic adding of arguments and environment
settings: .run() now takes verbatim_args and verbatim_env
* salt-proxy uses salt-minion.pid file
* Simplify .shutdown()
+ pass timeout to .wait_for_daemon_pid()
+ attempt kill before checking timeout value
+ Testing for "no such pid" (case that process was already dead) was
previously incorrect, but was masked due to (what should have been) a
superfluous call to salt.utils.process.os_is_running()
* Add a ``testprogram.TestProgramCase()`` to simplify test classes
+ Has ``setUp()`` and ``tearDown()`` to create ephemeral test directory
(really should be moved to salttesting.TestCase)
+ Common ``assert_exit_status()`` for validating and reporting failures in
exit status.
* Add missing ``testprogram.TestDaemonSaltProxy`` class
* Remove specific setting of ``program`` parameter in initialization of
``TestDaemonSaltMinion`` since ``testprogram.TestSaltProgramMeta`` already
handles that unless a specific override is required.
* Automatically set ``user`` in config for master, minion and proxy test
classes if a specific user is not specified.
* Automatically set ``PYTHONPATH`` as ``sys.path`` unless it is specified.
* Add debug logging when a program is started
* Set a flag once a TestDaemon has been shutdown(); check flag in is_running()
* Add .config_path property
* salt.utils.process.clean_proc() only works with multiprocessing - replace it
* Automatically add --config-dir for TestSaltDaemon if it isn't already specified
* * Improve init script: specifically manage salt configurations rather than arbitrary salt processes
Unfortunately SysV init scripts tend to rummage through PIDs filtering for
appropriate processes to manage. Unfortunately the filters are usually weak
and don't account for similar processes run by other users, PIDs of dead
processes being re-used for completely different executables, etc.. These
weaknesses can result in killing unrelated processes with potentially serious
results.
These improvements to the SysV init script is a complete rewrite with the
following improvements:
* Specifically manage individual salt configurations rather than looking for
salt minion-like processes.
* Obtain salt minion information from the salt configuration - use the
information to manage the specifically configured process.
* Drop all of the platform-specific helper functions that allow the
previously-mentioned weaknesses.
+ Unfortunately this means that the output information may not match the
specific platform (this could easily be corrected).
* Now can manage multiple salt processes started by different users
+ Unfortunately starts/stops/restarts as a group and is unable to manage
them both as a group or as individual processes (this could easily be
corrected)
The new initscript also allows various control variables to be overridden by
environment variables or through settings put in ``/etc/sysconf/salt`` or
``/etc/default/salt``.
:SALTMINION_DEBUG: Dump each line expansion before execution, output system
information on failure. Default: unset
:SALTMINION_BINDIR: Location of ``salt-minion``, ``salt-call`` and other
executables. Default: ``/usr/bin``
:SALTMINION_SYSCONFDIR: The parent directory for the ``salt`` configuration
directory and the ``sysconfig`` or ``default``
directory.
* Add lines that went missing in the rebase+squash
This reverts most of commit 745f2d84835ae23800358cd4dcc9c8525b502714.
apparently I picked up some other changes I didn't mean to
Conflicts:
salt/utils/event.py
tests/integration/utils/test_reactor.py