8000 [3006.x] Added back Debian support for Sys V init.d service scripts by dmurphy18 · Pull Request #67909 · saltstack/salt · GitHub
[go: up one dir, main page]

Skip to content

[3006.x] Added back Debian support for Sys V init.d service scripts #67909

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

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Remove debug statements, and additions made from 67914 WIP Fix nightl…
…y build package test failures
  • Loading branch information
dmurphy18 committed Mar 26, 2025
commit 9e655760b0d54559d97393dd02d89468d6095ff3
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ def ci_test_onedir_pkgs(session):
except CommandFailed:
if os.environ.get("RERUN_FAILURES", "0") == "0":
# Don't rerun on failures
sys.exit(1)
return

# Don't print the system information, not the test selection on reruns
global PRINT_TEST_SELECTION
Expand Down Expand Up @@ -1947,7 +1947,7 @@ def ci_test_onedir_pkgs(session):
common_pytest_args[:]
+ cmd_args[:]
+ [
"--no-uninstall",
"--no-install",
"--junitxml=artifacts/xml-unittests-output/test-results-install.xml",
"--log-file=artifacts/logs/runtests-install.log",
]
Expand All @@ -1962,7 +1962,7 @@ def ci_test_onedir_pkgs(session):
except CommandFailed:
if os.environ.get("RERUN_FAILURES", "0") == "0":
# Don't rerun on failures
sys.exit(1)
return
cmd_args = chunks["install"]
pytest_args = (
common_pytest_args[:]
Expand Down
2 changes: 1 addition & 1 deletion salt/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def string(self):
version_string += f".{self.mbugfix}"
if self.pre_type:
version_string += f"{self.pre_type}{self.pre_num}"
if self.noc is not None and self.sha:
if self.noc and self.sha:
noc = self.noc
if noc < 0:
noc = "0na"
Expand Down
5 changes: 1 addition & 4 deletions tests/pytests/pkg/integration/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ def test_compare_versions(binary, install_salt):
"""
Test compare versions
"""
if install_salt.use_prev_version:
version = install_salt.prev_version
else:
version = install_salt.artifact_version
version = install_salt.artifact_version
if binary in install_salt.binary_paths:
if install_salt.upgrade:
install_salt.install()
Expand Down
24 changes: 1 addition & 23 deletions tests/pytests/pkg/upgrade/test_salt_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def salt_test_upgrade(
new_minion_pids = _get_running_named_salt_pid(process_minion_name)
new_master_pids = _get_running_named_salt_pid(process_master_name)

if sys.platform == "linux" and install_salt.distro_id not in ("ubuntu", "debian"):
if sys.platform == "linux":
assert new_minion_pids
assert new_master_pids
assert new_minion_pids != old_minion_pids
Expand Down Expand Up @@ -143,34 +143,20 @@ def test_salt_sysv_service_files(install_salt):
if not (salt.utils.path.which("dpkg") or salt.utils.path.which("rpm")):
pytest.skip("Not testing on a Debian or RedHat family platform, do not run")

print(
f"DGM test_salt_sysv_service_files entry install_salt, '{install_salt}'",
flush=True,
)

test_pkgs = install_salt.pkgs
print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True)
for test_pkg_name in test_pkgs:
test_pkg_basename = os.path.basename(test_pkg_name)
# Debian/Ubuntu name typically salt-minion_300xxxxxx
# Redhat name typically salt-minion-300xxxxxx
test_pkg_basename_dash_underscore = test_pkg_basename.split("300")[0]
test_pkg_basename_adj = test_pkg_basename_dash_underscore[:-1]
print(
f"DGM test_salt_sysv_service_files test_pkg_basename_dash_underscore '{test_pkg_basename_dash_underscore}', test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'",
flush=True,
)
if test_pkg_basename_adj in (
"salt-minion",
"salt-master",
"salt-syndic",
"salt-api",
):
test_initd_name = f"/etc/init.d/{test_pkg_basename_adj}"
print(
f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' to check against",
flush=True,
)
if salt.utils.path.which("dpkg"):
proc = subprocess.run(
["dpkg", "-c", f"{test_pkg_name}"],
Expand All @@ -186,16 +172,8 @@ def test_salt_sysv_service_files(install_salt):
found_line = False
for line in proc.stdout.decode().splitlines():
# If test_initd_name not present we should fail.
print(
f"DGM test_salt_sysv_service_files check line, '{line}'",
flush=True,
)
if test_initd_name in line:
found_line = True
print(
f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' was FOUND",
flush=True,
)
break

assert found_line
Expand Down
62 changes: 23 additions & 39 deletions tests/support/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,38 +724,28 @@ def install_previous(self, downgrade=False):
) as fp:
fp.write(
f"deb [signed-by={gpg_full_path} arch={arch}] "
f"{root_url}/saltproject-deb/ stable main"
f"{root_url}/saltproject-deb/ {self.distro_codename} main"
)
self._check_retcode(ret)
pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001")
pref_file.parent.mkdir(exist_ok=True)
pin = f"{self.prev_version.rsplit('.', 1)[0]}.*"
if downgrade:
pin = self.prev_version
with salt.utils.files.fopen(pref_file, "w") as fp:
fp.write(
f"Package: salt-*\n" f"Pin: version {pin}\n" f"Pin-Priority: 1001"
)

cmd = [self.pkg_mngr, "install", *self.salt_pkgs, "-y"]

# if downgrade:
# pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref")
# pref_file.parent.mkdir(exist_ok=True)
# # TODO: There's probably something I should put in here to say what version
# # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
# pref_file.write_text(
# textwrap.dedent(
# f"""\
# Package: salt*
# Pin: origin "{root_url}/saltproject-deb"
# Pin-Priority: 1001
# """
# ),
# encoding="utf-8",
# )
# cmd.append("--allow-downgrades")
cmd.append("--allow-downgrades")
if downgrade:
pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref")
pref_file.parent.mkdir(exist_ok=True)
# TODO: There's probably something I should put in here to say what version
# TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs
pref_file.write_text(
textwrap.dedent(
f"""\
Package: salt*
Pin: origin "{root_url}/saltproject-deb"
Pin-Priority: 1001
"""
),
encoding="utf-8",
)
cmd.append("--allow-downgrades")
env = os.environ.copy()
env["DEBIAN_FRONTEND"] = "noninteractive"
extra_args = [
Expand All @@ -768,22 +758,16 @@ def install_previous(self, downgrade=False):

cmd.extend(extra_args)

log.warning("Run cmd %s", cmd)

ret = self.proc.run(*cmd, env=env)

log.warning("cmd return %r", ret)

# Pre-relenv packages down get downgraded to cleanly programmatically
# They work manually, and the install tests after downgrades will catch problems with the install
# Let's not check the returncode if this is the case
# if not (
# downgrade
# and packaging.version.parse(self.prev_version)
# < packaging.version.parse("3006.0")
# ):
# self._check_retcode(ret)
if downgrade and not self.no_uninstall:
if not (
downgrade
and packaging.version.parse(self.prev_version)
< packaging.version.parse("3006.0")
):
self._check_retcode(ret)
pref_file.unlink()
self.stop_services()
elif platform.is_windows():
Expand Down
Loading
0