Skip to content

Commit

Permalink
Merge branch '3006.x' into fix_env
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcmarrow authored Aug 24, 2023
2 parents 0d27aa0 + b43c1d9 commit ea6bff7
Show file tree
Hide file tree
Showing 44 changed files with 78 additions and 108 deletions.
1 change: 1 addition & 0 deletions changelog/60931.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg.latest no longer fails when multiple versions are reported to be installed (e.g. updating the kernel)
2 changes: 2 additions & 0 deletions doc/ref/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ The above example will force the minion to use the :py:mod:`systemd
<salt.modules.systemd>` module to provide service management, and the
:py:mod:`aptpkg <salt.modules.aptpkg>` module to provide package management.

For per-state provider overrides, see documentation on :ref:`state providers <state-providers>`.

.. __: https://github.com/saltstack/salt/issues/new

Logging Restrictions
Expand Down
3 changes: 0 additions & 3 deletions salt/beacons/smartos_imgadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,3 @@ def beacon(config):
IMGADM_STATE["first_run"] = False

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/beacons/smartos_vmadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,3 @@ def beacon(config):
VMADM_STATE["first_run"] = False

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/grains/mdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,3 @@ def mdata():
)

return grains


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/grains/smartos.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,3 @@ def smartos():
)

return grains


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/grains/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,3 @@ def zfs():
)

return grains


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/apcups.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,3 @@ def status_battery():
return not data["TONBATT"] == "0 Seconds"

return {"Error": "Battery status not available."}


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
1 change: 1 addition & 0 deletions salt/modules/at.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def at(*args, **kwargs): # pylint: disable=C0103
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
salt '*' at.at '"22:02"' 'bin/myscript' tag=nightly runas=jim
"""

if len(args) < 2:
Expand Down
3 changes: 0 additions & 3 deletions salt/modules/at_solaris.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,3 @@ def jobcheck(**kwargs):
return {"error": "You have given a condition"}

return _atq(**kwargs)


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,3 @@ def stp(br=None, state="disable", iface=None):
return _os_dispatch("stp", br, states[state], iface)
else:
return False


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/mdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,3 @@ def delete_(*keyname):
ret[k] = True

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/netbsd_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,3 @@ def persist(name, value, config="/etc/sysctl.conf"):
assign(name, value)

return "Updated"


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/netbsdservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,3 @@ def disabled(name):
salt '*' service.disabled <service name>
"""
return _get_svc("/etc/rc.d/{}".format(name), "NO")


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/pdbedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,3 @@ def modify(
ret = "updated"

return {login: ret}


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/pkgin.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,3 @@ def normalize_name(pkgs, **kwargs):
with the pkg_resource provider.)
"""
return pkgs


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/rbac_solaris.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,3 @@ def auth_rm(user, auth):
ret[a] = "Remove"

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/runit.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,3 @@ def remove(name):
log.error("Unable to remove symlink %s", svc_path)
return False
return True


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/slackware_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,3 @@ def disabled(name):
if _get_svc("{}.{}".format(prefix, name), "OFF") is None:
ret = False
return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/smartos_imgadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,3 @@ def source_add(source, source_type="imgapi"):
return ret

return sources(False)


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/smartos_nictagadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,3 @@ def delete(name, force=False):
if "stderr" not in res and res["stderr"] == ""
else res["stderr"]
}


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/smartos_vmadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,3 @@ def receive(uuid, source):
ret["Error"] = res["stderr"] if "stderr" in res else _exit_status(retcode)
return ret
return True


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/solaris_fmadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,3 @@ def healthy():
salt '*' fmadm.healthy
"""
return False if faulty() else True


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/zcbuildout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,3 @@ def _check_onlyif_unless(onlyif, unless, directory, runas=None, env=()):
if status["status"]:
ret = status
return ret


# vim:set et sts=4 ts=4 tw=80:
3 changes: 0 additions & 3 deletions salt/modules/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,3 @@ def get(*dataset, **kwargs):
del ds_data["property"]

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/zoneadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,3 @@ def clone(zone, source, snapshot=None):
del ret["message"]

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/modules/zonecfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,3 @@ def info(zone, show_all=False):
ret[resname].append(resdata)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/runners/smartos_vmadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,3 @@ def is_running(search):
salt-run vmadm.is_running search='alias=julia'
"""
return _action("is_running", search, False)


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/at.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,3 @@ def mod_watch(name, **kwargs):
ret = present(**kwargs)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/logadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,3 @@ def remove(name, log_file=None):
ret["comment"] = "No configuration for {} present.".format(log_file)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/pdbedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,3 @@ def present(name, **kwargs):
Alias for pdbedit.managed
"""
return managed(name, **kwargs)


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
2 changes: 1 addition & 1 deletion salt/states/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,7 @@ def latest(
x
for x in targets
if not changes.get(x)
or changes[x].get("new") != targets[x]
or targets[x] not in changes[x].get("new").split(",")
and targets[x] != "latest"
]
successful = [x for x in targets if x not in failed]
Expand Down
3 changes: 0 additions & 3 deletions salt/states/smartos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,3 @@ def vm_stopped(name):
ret["comment"] = "vm {} stopped".format(name)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,3 @@ def scheduled_snapshot(name, prefix, recursive=True, schedule=None):
ret["comment"] = "scheduled snapshots are up to date"

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,3 @@ def uninstalled(name):
ret["comment"] = "zone {} is not configured!".format(name)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/states/zpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,3 @@ def absent(name, export=False, force=False):
ret["comment"] = "storage pool {} is absent".format(name)

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions salt/utils/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,3 @@ def get_keep_jobs_seconds(opts):
)
keep_jobs_seconds = keep_jobs * 3600
return keep_jobs_seconds


# vim:set et sts=4 ts=4 tw=80:
3 changes: 0 additions & 3 deletions salt/utils/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,3 @@ def parse_command_result(res, label=None):
del ret["error"]

return ret


# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
3 changes: 0 additions & 3 deletions tests/integration/files/file/base/_states/salttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@

def hello(name):
return "hello " + name


# vim:set et sts=4 ts=4 tw=80:
8 changes: 8 additions & 0 deletions tests/pytests/unit/beacons/test_inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def configure_loader_modules():
return {inotify: {}}


@pytest.fixture(autouse=True)
def _close_inotify(configure_loader_modules):
try:
yield
finally:
inotify.close({})


def test_non_list_config():
config = {}

Expand Down
8 changes: 8 additions & 0 deletions tests/pytests/unit/beacons/test_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def configure_loader_modules():
return {watchdog: {}}


@pytest.fixture(autouse=True)
def _close_watchdog(configure_loader_modules):
try:
yield
finally:
watchdog.close({})


def assertValid(config):
ret = watchdog.validate(config)
assert ret == (True, "Valid beacon configuration")
Expand Down
56 changes: 56 additions & 0 deletions tests/pytests/unit/states/test_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,3 +1140,59 @@ def test_pacmanpkg_group_installed_with_repo_options(list_pkgs):
assert not ret["result"]
assert not ret["changes"]
assert ret["comment"] == "Repo options are not supported on this platform"


def test_latest():
"""
Test pkg.latest
"""
pkg_name = "fake_pkg"
old_version = "1.2.2"
new_version = "1.2.3"
latest_version_mock = MagicMock(return_value={pkg_name: new_version})
current_version_mock = MagicMock(return_value={pkg_name: old_version})
install_mock = MagicMock(
return_value={
pkg_name: {
"new": new_version,
"old": old_version,
},
}
)
salt_dict = {
"pkg.latest_version": latest_version_mock,
"pkg.version": current_version_mock,
"pkg.install": install_mock,
}
with patch.dict(pkg.__salt__, salt_dict):
ret = pkg.latest(pkg_name)
assert ret.get("result", False) is True


def test_latest_multiple_versions():
"""
This case arises most often when updating the kernel, where multiple versions are now installed.
See: https://github.com/saltstack/salt/issues/60931
"""
pkg_name = "fake_pkg"
old_version = "1.2.2"
new_version = "1.2.3"
latest_version_mock = MagicMock(return_value={pkg_name: new_version})
current_version_mock = MagicMock(return_value={pkg_name: old_version})
install_mock = MagicMock(
return_value={
pkg_name: {
"new": f"{old_version},{new_version}",
"old": old_version,
},
}
)
salt_dict = {
"pkg.latest_version": latest_version_mock,
"pkg.version": current_version_mock,
"pkg.install": install_mock,
}
with patch.dict(pkg.__salt__, salt_dict):
ret = pkg.latest(pkg_name)
assert ret.get("result", False) is True
1 change: 0 additions & 1 deletion tests/support/ext/console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# vim: sw=4 ts=4 fenc=utf-8
"""
getTerminalSize()
- get width and height of console
Expand Down
2 changes: 1 addition & 1 deletion tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent
GPG_KEY_FILENAME = "SALT-PROJECT-GPG-PUBKEY-2023"
SPB_ENVIRONMENT = os.environ.get("SPB_ENVIRONMENT") or "prod"
SPB_ENVIRONMENT = os.environ.get("SPB_ENVIRONMENT") or "test"
STAGING_BUCKET_NAME = f"salt-project-{SPB_ENVIRONMENT}-salt-artifacts-staging"
RELEASE_BUCKET_NAME = f"salt-project-{SPB_ENVIRONMENT}-salt-artifacts-release"
BACKUP_BUCKET_NAME = f"salt-project-{SPB_ENVIRONMENT}-salt-artifacts-backup"
Expand Down

0 comments on commit ea6bff7

Please sign in to comment.