Skip to content

Commit

Permalink
cmt-install: Fix never-fallback-distros issue
Browse files Browse the repository at this point in the history
Packages that were in the never-fallback-distros list wouldn't
get installed even if the distro package is available.

TODO: completely eliminate the *WITHOUT_FALLBACK list
and simplify the code.

Signed-off-by: David Weinehall <[email protected]>
  • Loading branch information
taotriad committed Jul 25, 2023
1 parent 81dd2a0 commit 87bf964
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 56 deletions.
4 changes: 2 additions & 2 deletions about.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

PROGRAM_SUITE_NAME = "CMT"
PROGRAM_SUITE_FULL_NAME = "Cluster Management Toolkit for Kubernetes"
PROGRAM_SUITE_VERSION = "0.5.0"
PROGRAM_SUITE_VERSION = "0.5.1"

UI_PROGRAM_NAME = "cmu"
UI_PROGRAM_VERSION = "0.4.4"
Expand All @@ -22,7 +22,7 @@
TOOL_PROGRAM_VERSION = "0.6.2"

INSTALL_PROGRAM_NAME = "cmt-install"
INSTALL_PROGRAM_VERSION = "0.13.0"
INSTALL_PROGRAM_VERSION = "0.13.1"

ADMIN_PROGRAM_NAME = "cmtadm"
ADMIN_PROGRAM_VERSION = "0.6.5"
Expand Down
74 changes: 20 additions & 54 deletions cmt-install
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ PACKAGES_WITH_PIP_FALLBACK = {
},
"python3-pyyaml": {
"fallback": "PyYAML",
"always-fallback-distros": [
"distros": [
# Until RHEL 9
"fedora",
"rhel",
],
"never-fallback-distros": [
"suse",
"debian",
"always-fallback-distros": [
# Until RHEL 9
"fedora",
"rhel",
],
},
"python3-ujson": {
Expand All @@ -138,6 +139,8 @@ PACKAGES_WITH_PIP_FALLBACK = {
],
},
"python3-urllib3": {
"recommended minimum": "1.26.0",
"reason": "TLSv1.1 is still enabled in older versions",
"fallback": "urllib3",
"always-fallback-distros": [
"suse",
Expand All @@ -161,13 +164,15 @@ PACKAGES_WITH_PIP_FALLBACK = {
},
"python3-yaml": {
"fallback": "PyYAML",
"distros": [
"debian",
"suse",
],
"always-fallback-distros": [
"suse",
],
"never-fallback-distros": [
"debian",
"fedora",
"rhel",
],
},
}
Expand All @@ -185,56 +190,11 @@ PACKAGES_WITHOUT_FALLBACK = {
"rhel",
],
},
"python3-cryptography": {
"distros": [
"debian",
# Enable from RHEL 9
# "fedora",
# "rhel",
],
},
"python3-natsort": {
"distros": [
"debian",
],
},
"python3-paramiko": {
"distros": [
"debian",
],
},
"python3-pip": {
"distros": [
"debian",
],
},
# Enable from RHEL 9
# "python3-pyyaml": {
# "distros": [
# "fedora",
# "rhel",
# ],
#},
"python3-ujson": {
"distros": [
"debian",
],
},
"python3-urllib3": {
"recommended minimum": "1.26.0",
"reason": "TLSv1.1 is still enabled in older versions",
"distros": [
"debian",
# Enable from RHEL 9
#"fedora",
#"rhel",
],
},
"python3-yaml": {
"distros": [
"debian",
],
},
"sshpass": {},
}

Expand Down Expand Up @@ -511,7 +471,7 @@ def trim_package_list(packages: Dict, distro: str = "", fallback: bool = False)
Parameters:
packages (union(dict, set)): A dict of packages to install
distro (str): Supported options "debian", "suse"
distro (str): Supported options "debian", "fedora" "rhel", "suse"
fallback (bool): Is a package list with fallbacks being processed
Returns:
trimmed_packages (dict): The trimmed dict of packages
Expand All @@ -527,9 +487,9 @@ def trim_package_list(packages: Dict, distro: str = "", fallback: bool = False)

if len(distros) > 0 and distro not in distros:
continue
if len(never_fallback_distros) > 0 and distro in never_fallback_distros and fallback:
continue
trimmed_packages[pkg] = data
if len(never_fallback_distros) > 0 and distro in never_fallback_distros and fallback:
trimmed_packages[pkg].pop("fallback")

return trimmed_packages

Expand Down Expand Up @@ -614,6 +574,10 @@ def install_software_with_pip_fallback(packages: Dict, pip_proxy: str = "", verb

for line in split_response:
_pkg = line.split(' ', 1)
# If we explicitly specify distros there are different names
# for the same package in different distros, so skip if irrelevant
if "distros" in deep_get(packages, DictPath(f"_pkg[0]"), {}) and distro not in deep_get(packages, DictPath(f"{_pkg[0]}#distros"), []):
continue
if distro not in deep_get(packages, DictPath(f"{_pkg[0]}#always-fallback-distros"), []):
if _pkg[0] in packages.keys() and _pkg[0] not in pkgs:
pkgs[_pkg[0]] = packages[_pkg[0]]
Expand Down Expand Up @@ -819,6 +783,8 @@ def install(options: List[Tuple[str, str]], args: List[str]) -> int:
ANSIThemeString(": This requires sudo permissions", "emphasis")])
for pkg in pkgs_without_fallback:
ansithemeprint([ANSIThemeString(f" {pkg}", "path")])
for pkg in pkgs:
ansithemeprint([ANSIThemeString(f" {pkg}", "path")])
for pkg in pkgs_fallback:
ansithemeprint([ANSIThemeString(f" {pkg}", "path"),
ANSIThemeString(" (Using package from PIP)", "emphasis")])
Expand Down

0 comments on commit 87bf964

Please sign in to comment.