Skip to content
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

Fixes #18841: rudder package upgrade-all does not upgrade each plugin independently #3479

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions relay/sources/rudder-pkg/lib/rudder-pkg/rudderPkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Expect a list of path as parameter.
Try to install the given rpkgs.
"""
def install_file(package_files):
def install_file(package_files, exit_on_error=True):
for package_file in package_files:
logger.info("Installing " + package_file)
# First, check if file exists
Expand All @@ -33,13 +33,14 @@ def install_file(package_files):
# wait until the end to make them visible.
# This should be moved before actual installation once implemented.
if not utils.install_dependencies(metadata):
exit(1)
if exit_on_error:
exit(1)
if exist:
logger.info("The package is already installed, I will upgrade it.")
script_dir = utils.extract_scripts(metadata, package_file)
utils.run_script("preinst", script_dir, exist)
utils.run_script("preinst", script_dir, exist, exit_on_error=exit_on_error)
utils.install(metadata, package_file, exist)
utils.run_script("postinst", script_dir, exist)
utils.run_script("postinst", script_dir, exist, exit_on_error=exit_on_error)
if metadata['type'] == 'plugin' and 'jar-files' in metadata:
for j in metadata['jar-files']:
utils.jar_status(j, True)
Expand Down Expand Up @@ -202,7 +203,7 @@ def package_install_specific_version(name, longVersion, mode="release", quiet=Fa
Install the latest available and compatible package for a given plugin.
If no release mode is given, it will only look in the released rpkg.
"""
def package_install_latest(name, mode="release", quiet=False):
def package_install_latest(name, mode="release", quiet=False, exit_on_error=True):
utils.readConf()
pkgs = plugin.Plugin(name[0])
pkgs.getAvailablePackages()
Expand All @@ -212,9 +213,9 @@ def package_install_latest(name, mode="release", quiet=False):
rpkg = pkgs.getLatestCompatibleNightly()
if rpkg is not None:
rpkgPath = utils.downloadByRpkg(rpkg, quiet)
install_file([rpkgPath])
install_file([rpkgPath], exit_on_error=exit_on_error)
else:
utils.fail("Could not find any compatible %s for %s"%(mode, name))
utils.fail("Could not find any compatible %s for %s"%(mode, name), exit_on_error=exit_on_error)

"""Remove a given plugin. Expect a list of name as parameter."""
def remove(package_names):
Expand Down Expand Up @@ -363,6 +364,6 @@ def upgrade_all(mode, quiet=False):
latestVersion = pkgs.getLatestCompatibleRelease().version
if currentVersion < latestVersion:
print("The plugin %s is installed in version %s. The version %s %s is available, the plugin will be upgraded."%(p, currentVersion.pluginLongVersion, mode, latestVersion.pluginLongVersion))
package_install_latest([p], mode, quiet)
package_install_latest([p], mode, quiet, exit_on_error=False)
else:
print("No newer %s compatible versions found for the plugin %s"%(mode, p))
11 changes: 6 additions & 5 deletions relay/sources/rudder-pkg/lib/rudder-pkg/rudderPkgUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ def shell(command, comment=None, keep_output=False, fail_exit=True, keep_error=F
fail(output, retcode)
return (retcode, output, error)

def fail(message, code=1):
def fail(message, code=1, exit_on_error=True):
logger.debug(traceback.format_exc())
logger.error(message)
exit(code)
if exit_on_error:
exit(code)

def sha512(fname):
hash_sha512 = hashlib.sha512()
Expand Down Expand Up @@ -322,16 +323,16 @@ def extract_scripts(metadata,package_file):
return package_dir


def run_script(name, script_dir, exist):
script = script_dir + "/" + name
def run_script(name, script_dir, exist, exit_on_error=True):
script = script_dir + "/" + name
if os.path.isfile(script):
if exist is None:
param = ""
elif exist:
param = "upgrade"
else:
param = "install"
shell(script + " " + param)
shell(script + " " + param, fail_exit=exit_on_error)


def jar_status(name, enable):
Expand Down