Merge pull request #313 from mmichal10/forbid-upgrade-in-cas-19

Forbid upgrade in flight when cas_disk is older than 20.01
This commit is contained in:
Michał Mielewczyk 2020-01-29 16:25:31 +01:00 committed by GitHub
commit 1a819ec469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -35,6 +35,8 @@ CAS_CACHE_KEY = "CAS Cache Kernel Module"
CAS_DISK_KEY = "CAS Disk Kernel Module"
CAS_CLI_KEY = "CAS CLI Utility"
CAS_DISK_MIN_VER = 20
OCL_BUILD_ROOT = f"{os.path.dirname(__file__)}/.."
@ -58,6 +60,11 @@ class InitUpgrade(UpgradeState):
except Exception as e:
return Failure(f"Failed to get current version of CAS {e}")
# Although there shouldn't be any problem with upgrade from CAS 19.9 to newer, this feature
# is not full validated so it is disabled by default.
if (int(version[CAS_DISK_KEY].split('.')[0]) < CAS_DISK_MIN_VER):
return Failure(f"Minimal cas_disk version required to perform upgrade is 20.01!")
if version[CAS_CLI_KEY] != version[CAS_CACHE_KEY]:
return Failure("Mismatch between CLI and cas_cache version")

View File

@ -162,9 +162,10 @@ class UpgradeState:
def insert_module(name, installed=True, **params):
cmd_params = [f"{param}={val}" for param, val in params.items()]
cmd = "modprobe --first-time" if installed else "insmod"
cmd = ["modprobe", "--first-time"] if installed else ["insmod"]
cmd += [name] + cmd_params
p = subprocess.run([cmd, name] + cmd_params, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.returncode:
raise Exception(p.stderr.decode("ascii").rstrip("\n"))