mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Added debugging
This commit is contained in:
parent
81e39a3042
commit
eb07f58277
2 changed files with 39 additions and 6 deletions
|
@ -251,7 +251,7 @@ class GitProvider:
|
||||||
override_params,
|
override_params,
|
||||||
cache_root,
|
cache_root,
|
||||||
role="gitfs",
|
role="gitfs",
|
||||||
):
|
): # pylint: disable=logging-fstring-interpolation
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
self.role = role
|
self.role = role
|
||||||
|
|
||||||
|
@ -528,12 +528,27 @@ class GitProvider:
|
||||||
if HAS_PSUTIL:
|
if HAS_PSUTIL:
|
||||||
cur_pid = os.getpid()
|
cur_pid = os.getpid()
|
||||||
process = psutil.Process(cur_pid)
|
process = psutil.Process(cur_pid)
|
||||||
|
log.warning(
|
||||||
|
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'"
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider dunder init, cur_pid '{cur_pid}', process '{process}'"
|
||||||
|
)
|
||||||
if isinstance(process, salt.utils.process.Process):
|
if isinstance(process, salt.utils.process.Process):
|
||||||
cache_dir = self.opts.get("cachedir", None)
|
cache_dir = self.opts.get("cachedir", None)
|
||||||
gitfs_active = self.opts.get("gitfs_remotes", None)
|
gitfs_active = self.opts.get("gitfs_remotes", None)
|
||||||
|
log.warning(
|
||||||
|
f"DGM class GitProvider dunder init, cache_dir '{cache_dir}', gitfs_active '{gitfs_active}'"
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider dunder init, cache_dir '{cache_dir}', gitfs_active '{gitfs_active}'"
|
||||||
|
)
|
||||||
if cache_dir and gitfs_active:
|
if cache_dir and gitfs_active:
|
||||||
log.warning(
|
log.warning(
|
||||||
"DGM class GitProvider registering gitfs_zombie_cleanup"
|
f"DGM class GitProvider registering gitfs_zombie_cleanup with cache_dir '{cache_dir}'"
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider registering gitfs_zombie_cleanup with cache_dir '{cache_dir}'"
|
||||||
)
|
)
|
||||||
process.register_finalize_method(gitfs_zombie_cleanup, cache_dir)
|
process.register_finalize_method(gitfs_zombie_cleanup, cache_dir)
|
||||||
|
|
||||||
|
@ -3654,16 +3669,21 @@ class WinRepo(GitBase):
|
||||||
self.winrepo_dirs[repo.id] = cachedir
|
self.winrepo_dirs[repo.id] = cachedir
|
||||||
|
|
||||||
|
|
||||||
## DGM wip code
|
## DGM wip code
|
||||||
|
# pylint: disable=logging-fstring-interpolation
|
||||||
def gitfs_zombie_cleanup(cache_dir):
|
def gitfs_zombie_cleanup(cache_dir):
|
||||||
"""
|
"""
|
||||||
Clean up zombie processes that used gitfs
|
Clean up zombie processes that used gitfs
|
||||||
Initial wip
|
Initial wip
|
||||||
"""
|
"""
|
||||||
log.warning("DGM class GitProvider gitfs_zombie_cleanup entry")
|
log.warning(
|
||||||
|
f"DGM class GitProvider gitfs_zombie_cleanup entry, cache_dir '{cache_dir}'"
|
||||||
|
)
|
||||||
|
print(f"DGM class GitProvider gitfs_zombie_cleanup entry, cache_dir '{cache_dir}'")
|
||||||
cur_pid = os.getpid()
|
cur_pid = os.getpid()
|
||||||
mach_id = _get_machine_identifier().get("machine_id", "no_machine_id_available")
|
mach_id = _get_machine_identifier().get("machine_id", "no_machine_id_available")
|
||||||
log.debug("exiting for process id %s and machine identifer %s", cur_pid, mach_id)
|
log.debug("exiting for process id %s and machine identifer %s", cur_pid, mach_id)
|
||||||
|
print(f"exiting for process id '{cur_pid}' and machine identifer '{mach_id}'")
|
||||||
|
|
||||||
# need to clean up any resources left around like lock files if using gitfs
|
# need to clean up any resources left around like lock files if using gitfs
|
||||||
# example: lockfile
|
# example: lockfile
|
||||||
|
|
|
@ -562,11 +562,16 @@ class KillProcessTest(salt.utils.process.SignalHandlingProcess):
|
||||||
@pytest.mark.slow_test
|
@pytest.mark.slow_test
|
||||||
@pytest.mark.skip_unless_on_linux
|
@pytest.mark.skip_unless_on_linux
|
||||||
@pytest.mark.timeout_unless_on_windows(120)
|
@pytest.mark.timeout_unless_on_windows(120)
|
||||||
def test_git_provider_sigterm_cleanup(main_class):
|
def test_git_provider_sigterm_cleanup(
|
||||||
|
main_class,
|
||||||
|
): # pylint: disable=logging-fstring-interpolation
|
||||||
"""
|
"""
|
||||||
Start process which will obtain lock, and leave it locked
|
Start process which will obtain lock, and leave it locked
|
||||||
then kill the process via SIGTERM and ensure locked resources are cleaned up
|
then kill the process via SIGTERM and ensure locked resources are cleaned up
|
||||||
"""
|
"""
|
||||||
|
log.warning("DGM test_git_provider_sigterm_cleanup entry")
|
||||||
|
print("DGM test_git_provider_sigterm_cleanup entry")
|
||||||
|
|
||||||
provider = main_class.remotes[0]
|
provider = main_class.remotes[0]
|
||||||
|
|
||||||
with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
|
with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
|
||||||
|
@ -576,6 +581,11 @@ def test_git_provider_sigterm_cleanup(main_class):
|
||||||
while not proc.is_alive():
|
while not proc.is_alive():
|
||||||
time.sleep(1) # give some time for it to be started
|
time.sleep(1) # give some time for it to be started
|
||||||
|
|
||||||
|
log.warning(
|
||||||
|
f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}'"
|
||||||
|
)
|
||||||
|
print(f"DGM test_git_provider_sigterm_cleanup, post add_process, proc '{proc}'")
|
||||||
|
|
||||||
procmgr.run(asynchronous=True)
|
procmgr.run(asynchronous=True)
|
||||||
|
|
||||||
time.sleep(2) # give some time for it to terminate
|
time.sleep(2) # give some time for it to terminate
|
||||||
|
@ -583,12 +593,15 @@ def test_git_provider_sigterm_cleanup(main_class):
|
||||||
# child process should be alive
|
# child process should be alive
|
||||||
file_name = provider._get_lock_file("update")
|
file_name = provider._get_lock_file("update")
|
||||||
|
|
||||||
|
log.warning(f"DGM test_git_provider_sigterm_cleanup, file_name '{file_name}'")
|
||||||
|
print(f"DGM test_git_provider_sigterm_cleanup, file_name '{file_name}'")
|
||||||
|
|
||||||
assert pathlib.Path(file_name).exists()
|
assert pathlib.Path(file_name).exists()
|
||||||
assert pathlib.Path(file_name).is_file()
|
assert pathlib.Path(file_name).is_file()
|
||||||
|
|
||||||
procmgr.terminate() # sends a SIGTERM
|
procmgr.terminate() # sends a SIGTERM
|
||||||
|
|
||||||
time.sleep(1) # give some time for it to terminate
|
time.sleep(2) # give some time for it to terminate
|
||||||
|
|
||||||
assert not proc.is_alive()
|
assert not proc.is_alive()
|
||||||
assert not pathlib.Path(file_name).exists()
|
assert not pathlib.Path(file_name).exists()
|
||||||
|
|
Loading…
Add table
Reference in a new issue