Skip to content

Commit

Permalink
Merge pull request #313 from mmichal10/forbid-upgrade-in-cas-19
Browse files Browse the repository at this point in the history
Forbid upgrade in flight when cas_disk is older than 20.01
  • Loading branch information
Michał Mielewczyk authored Jan 29, 2020
2 parents 7b0e816 + 6c57d28 commit 1a819ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions utils/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -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__)}/.."


Expand All @@ -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")

Expand Down
5 changes: 3 additions & 2 deletions utils/upgrade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ def exit_state(self):
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"))
Expand Down

0 comments on commit 1a819ec

Please sign in to comment.